diff --git a/e2e/support/helpers/e2e-dashboard-helpers.ts b/e2e/support/helpers/e2e-dashboard-helpers.ts index 54a2de215c55fed311019d7278a0e94450315aec..5f52930e5bdac49070e94d7cbbfb5276930cbd54 100644 --- a/e2e/support/helpers/e2e-dashboard-helpers.ts +++ b/e2e/support/helpers/e2e-dashboard-helpers.ts @@ -88,12 +88,10 @@ export function saveDashboard({ cy.button(buttonLabel).click(); if (awaitRequest) { - cy.wait("@saveDashboardCards").then(() => { - cy.findByText(editBarText).should("not.exist"); - }); - } else { - cy.findByText(editBarText).should("not.exist"); + cy.wait("@saveDashboardCards"); } + + cy.findByText(editBarText).should("not.exist"); cy.wait(waitMs); // this is stupid but necessary to due to the dashboard resizing and detaching elements } diff --git a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js index 5ea64001fa6a423cb486a01fa134c156ff68f5b0..1945dc9009738a05c60916aa1ef802d29df4800d 100644 --- a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js +++ b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js @@ -326,119 +326,120 @@ describe("issue 16559", () => { restore(); cy.signInAsAdmin(); - cy.createDashboard(dashboardDetails).then( - ({ body: { id: dashboardId } }) => { - visitDashboard(dashboardId); - }, - ); - }); - - it( - "should always show the most recent revision (metabase#16559)", - { tags: "@flaky" }, - () => { - openDashboardInfoSidebar(); - sidesheet().within(() => { - cy.findByRole("tab", { name: "History" }).click(); - cy.log("Dashboard creation"); - cy.findByTestId("dashboard-history-list") - .findAllByRole("listitem") - .eq(0) - .findByText("You created this.") - .should("be.visible"); - }); - closeDashboardInfoSidebar(); - - cy.log("Edit dashboard"); - editDashboard(); - openQuestionsSidebar(); - sidebar().findByText("Orders, Count").click(); - cy.button("Save").click(); - - openDashboardInfoSidebar(); - sidesheet().within(() => { - cy.findByRole("tab", { name: "History" }).click(); - cy.findByTestId("dashboard-history-list") - .findAllByRole("listitem") - .eq(0) - .findByText("You added a card.") - .should("be.visible"); - }); - closeDashboardInfoSidebar(); + createDashboard(dashboardDetails).then(response => { + visitDashboard(response.body.id); + }); - cy.log("Change dashboard name"); - cy.findByTestId("dashboard-name-heading") - .click() - .type(" modified") - .blur(); + cy.intercept("GET", "/api/collection/tree?*").as("getCollections"); + cy.intercept("PUT", "/api/dashboard/*").as("saveDashboard"); + cy.intercept("POST", "/api/card/*/query").as("cardQuery"); + }); - openDashboardInfoSidebar(); - sidesheet().within(() => { - cy.findByRole("tab", { name: "History" }).click(); + it("should always show the most recent revision (metabase#16559)", () => { + openDashboardInfoSidebar(); + sidesheet().within(() => { + cy.findByRole("tab", { name: "History" }).click(); + cy.log("Dashboard creation"); + cy.findByTestId("dashboard-history-list") + .findAllByRole("listitem") + .eq(0) + .findByText("You created this.") + .should("be.visible"); + }); + closeDashboardInfoSidebar(); - cy.findByTestId("dashboard-history-list") - .findAllByRole("listitem") - .eq(0) - .findByText( - 'You renamed this Dashboard from "16559 Dashboard" to "16559 Dashboard modified".', - ) - .should("be.visible"); + cy.log("Edit dashboard"); + editDashboard(); + openQuestionsSidebar(); + sidebar().findByText("Orders, Count").click(); + cy.wait("@cardQuery"); + cy.button("Save").click(); + cy.wait("@saveDashboard"); + + openDashboardInfoSidebar(); + sidesheet().within(() => { + cy.findByRole("tab", { name: "History" }).click(); + cy.findByTestId("dashboard-history-list") + .findAllByRole("listitem") + .eq(0) + .findByText("You added a card.") + .should("be.visible"); + }); + closeDashboardInfoSidebar(); - cy.log("Add description"); - cy.findByRole("tab", { name: "Overview" }).click(); + cy.log("Change dashboard name"); + cy.findByTestId("dashboard-name-heading").click().type(" modified").blur(); + cy.wait("@saveDashboard"); - cy.findByPlaceholderText("Add description") - .click() - .type("16559 description") - .blur(); + openDashboardInfoSidebar(); + sidesheet().within(() => { + cy.findByRole("tab", { name: "History" }).click(); - cy.findByRole("tab", { name: "History" }).click(); + cy.findByTestId("dashboard-history-list") + .findAllByRole("listitem") + .eq(0) + .findByText( + 'You renamed this Dashboard from "16559 Dashboard" to "16559 Dashboard modified".', + ) + .should("be.visible"); - cy.findByTestId("dashboard-history-list") - .findAllByRole("listitem") - .eq(0) - .findByText("You added a description.") - .should("be.visible"); + cy.log("Add description"); + cy.findByRole("tab", { name: "Overview" }).click(); - cy.log("Toggle auto-apply filters"); - }); - closeDashboardInfoSidebar(); + cy.findByPlaceholderText("Add description") + .click() + .type("16559 description") + .blur(); + cy.wait("@saveDashboard"); - openDashboardSettingsSidebar(); - sidesheet().findByText("Auto-apply filters").click(); - closeDashboardSettingsSidebar(); + cy.findByRole("tab", { name: "History" }).click(); - openDashboardInfoSidebar(); - sidesheet().within(() => { - cy.findByRole("tab", { name: "History" }).click(); + cy.findByTestId("dashboard-history-list") + .findAllByRole("listitem") + .eq(0) + .findByText("You added a description.") + .should("be.visible"); - cy.findByTestId("dashboard-history-list") - .findAllByRole("listitem") - .eq(0) - .findByText("You set auto apply filters to false.") - .should("be.visible"); - }); - closeDashboardInfoSidebar(); - - cy.log("Move dashboard to another collection"); - dashboardHeader().icon("ellipsis").click(); - popover().findByText("Move").click(); - entityPickerModal().within(() => { - cy.findByText("First collection").click(); - cy.button("Move").click(); - }); + cy.log("Toggle auto-apply filters"); + }); + closeDashboardInfoSidebar(); + + openDashboardSettingsSidebar(); + sidesheet().findByText("Auto-apply filters").click(); + cy.wait("@saveDashboard"); + closeDashboardSettingsSidebar(); + + openDashboardInfoSidebar(); + sidesheet().within(() => { + cy.findByRole("tab", { name: "History" }).click(); + + cy.findByTestId("dashboard-history-list") + .findAllByRole("listitem") + .eq(0) + .findByText("You set auto apply filters to false.") + .should("be.visible"); + }); + closeDashboardInfoSidebar(); + + cy.log("Move dashboard to another collection"); + dashboardHeader().icon("ellipsis").click(); + popover().findByText("Move").click(); + entityPickerModal().within(() => { + cy.findByText("First collection").click(); + cy.button("Move").click(); + cy.wait(["@saveDashboard", "@getCollections"]); + }); - openDashboardInfoSidebar(); - sidesheet().within(() => { - cy.findByRole("tab", { name: "History" }).click(); - cy.findByTestId("dashboard-history-list") - .findAllByRole("listitem") - .eq(0) - .findByText("You moved this Dashboard to First collection.") - .should("be.visible"); - }); - }, - ); + openDashboardInfoSidebar(); + sidesheet().within(() => { + cy.findByRole("tab", { name: "History" }).click(); + cy.findByTestId("dashboard-history-list") + .findAllByRole("listitem") + .eq(0) + .findByText("You moved this Dashboard to First collection.") + .should("be.visible"); + }); + }); }); describe("issue 17879", () => {