Skip to content
Snippets Groups Projects
Unverified Commit 9f4e9137 authored by Anton Kulyk's avatar Anton Kulyk Committed by GitHub
Browse files

Fix a flaky test in revision history suite (#40359)

* Clean up test

* Fix race condition

* Wait for GET dashboard + for sidebar to close

* Add wait

* Add a sad comment
parent 61cacd7f
Branches
Tags
No related merge requests found
......@@ -46,7 +46,7 @@ export function sidebar() {
}
export function rightSidebar() {
return cy.findAllByTestId("sidebar-right");
return cy.findByTestId("sidebar-right");
}
export function leftSidebar() {
......
......@@ -12,6 +12,8 @@ import {
questionInfoButton,
rightSidebar,
openQuestionsSidebar,
editDashboard,
sidebar,
} from "e2e/support/helpers";
const PERMISSIONS = {
......@@ -34,12 +36,13 @@ describe("revision history", () => {
it("shouldn't render revision history steps when there was no diff (metabase#1926)", () => {
cy.createDashboard().then(({ body }) => {
visitAndEditDashboard(body.id);
visitDashboard(body.id);
editDashboard();
});
// Save the dashboard without any changes made to it (TODO: we should probably disable "Save" button in the first place)
saveDashboard();
cy.icon("pencil").click();
editDashboard();
saveDashboard();
openRevisionHistory();
......@@ -71,20 +74,32 @@ describe("revision history", () => {
});
it("shouldn't create a rearrange revision when adding a card (metabase#6884)", () => {
cy.intercept("GET", "/api/dashboard/*").as("fetchDashboard");
cy.intercept("POST", "/api/card/*/query").as("cardQuery");
cy.createDashboard().then(({ body }) => {
visitAndEditDashboard(body.id);
visitDashboard(body.id);
editDashboard();
});
openQuestionsSidebar();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders, Count").click();
sidebar().findByText("Orders, Count").click();
cy.wait("@cardQuery");
saveDashboard();
// this is dirty, but seems like the only reliable way
// to wait until SET_DASHBOARD_EDITING is dispatched,
// so it doesn't close the revisions sidebar
cy.wait("@fetchDashboard");
cy.wait(100);
openRevisionHistory();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(/added a card/)
.siblings("button")
.should("not.exist");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(/rearranged the cards/).should("not.exist");
rightSidebar().within(() => {
cy.findByText(/added a card/)
.siblings("button")
.should("not.exist");
cy.findByText(/rearranged the cards/).should("not.exist");
});
});
// skipped because it's super flaky in CI
......@@ -185,11 +200,6 @@ function clickRevert(event_name, index = 0) {
cy.findAllByLabelText(event_name).eq(index).click();
}
function visitAndEditDashboard(id) {
visitDashboard(id);
cy.icon("pencil").click();
}
function openRevisionHistory() {
cy.intercept("GET", "/api/revision*").as("revisionHistory");
cy.get("main header").within(() => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment