Skip to content
Snippets Groups Projects
Unverified Commit 56e78863 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Fix a race condition in loading questions for pinned items (#23466)

parent 20b67aac
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ const PinnedQuestionLoader = ({
return (
<Questions.Loader id={id} loadingAndErrorWrapper={false}>
{({ loading, question: card }: QuestionLoaderProps) => {
if (loading) {
if (loading || !card.dataset_query) {
return children({ loading: true });
}
......
import { popover, restore } from "__support__/e2e/cypress";
import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database";
const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
const DASHBOARD_NAME = "Orders in a dashboard";
const QUESTION_NAME = "Orders, Count";
const MODEL_NAME = "Orders";
const PIVOT_QUESTION_DETAILS = {
name: "Pivot table",
display: "pivot",
query: {
"source-table": ORDERS_ID,
breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
aggregation: [["count"]],
},
visualization_settings: {
"table.pivot_column": "CREATED_AT",
"table.cell_column": "count",
"pivot_table.column_split": {
rows: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
columns: [],
values: [["aggregation", 0]],
},
},
};
describe("scenarios > collection pinned items overview", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.intercept("POST", `/api/card/*/query`).as("getCardQuery");
cy.intercept("GET", "/api/collection/*/items?pinned_state=is_pinned*").as(
"getPinnedItems",
);
cy.intercept("POST", `/api/card/**/query`).as("getCardQuery");
cy.intercept("GET", "/api/**/items?pinned_state*").as("getPinnedItems");
});
it("should be able to pin a dashboard", () => {
......@@ -42,6 +62,21 @@ describe("scenarios > collection pinned items overview", () => {
});
});
it("should be able to pin a pivot table", () => {
cy.createQuestion(PIVOT_QUESTION_DETAILS).then(({ body: { id } }) => {
cy.request("PUT", `/api/card/${id}`, { collection_position: 1 });
});
openRootCollection();
cy.wait("@getCardQuery");
getPinnedSection().within(() => {
cy.findByText(PIVOT_QUESTION_DETAILS.name).should("be.visible");
cy.findByText("Created At: Month").should("be.visible");
cy.findByText("Count").should("be.visible");
});
});
it("should be able to pin a model", () => {
cy.request("PUT", "/api/card/1", { dataset: true });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment