Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix flaky document-comment split test (#77391)

github-automation-metabase6d2c060ef14b
diff --git a/e2e/test/scenarios/documents/comments.cy.spec.ts b/e2e/test/scenarios/documents/comments.cy.spec.ts
index 8ddfc2c4a4f..801bc8d271a 100644
--- a/e2e/test/scenarios/documents/comments.cy.spec.ts
+++ b/e2e/test/scenarios/documents/comments.cy.spec.ts
@@ -142,7 +142,15 @@ describe("document comments", () => {
H.documentContent().click();
cy.realType("{leftarrow}".repeat("lor sit amet.".length));
cy.realType("{enter}");
+ cy.intercept("PUT", "/api/document/*").as("updateDocument");
cy.findByRole("button", { name: "Save" }).click();
+ // Wait for the save to fully persist. On success the page schedules a
+ // navigation back to /document/:id; if that navigation resolves late
+ // (e.g. under network throttling) it clobbers the comments route opened
+ // below and the sidebar never mounts. Waiting for the request + the
+ // "Document saved" toast forces that navigation to settle first.
+ cy.wait("@updateDocument");
+ H.undoToast().findByText("Document saved").should("be.visible");
cy.findByRole("button", { name: "Save" }).should("not.exist");
Comments.getDocumentNodeButton({
@@ -160,7 +168,7 @@ describe("document comments", () => {
.should("have.length", 2)
.last()
.should("not.contain.text", "1")
- .click();
+ .realClick();
Comments.getSidebar().within(() => {
cy.findByRole("heading", { name: "Comments about this" }).should(