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 notifications unsubscribe e2e test (#76362)

github-automation-metabase9901a4384dbe
diff --git a/e2e/test/scenarios/onboarding/notifications.cy.spec.js b/e2e/test/scenarios/onboarding/notifications.cy.spec.js
index f67afd05272..0029fa88822 100644
--- a/e2e/test/scenarios/onboarding/notifications.cy.spec.js
+++ b/e2e/test/scenarios/onboarding/notifications.cy.spec.js
@@ -145,9 +145,13 @@ describe("scenarios > account > notifications", () => {
cy.signInAsAdmin();
openUserNotifications();
+ cy.intercept("POST", "/api/notification/*/unsubscribe").as(
+ "alertUnsubscribe",
+ );
+
cy.findByTestId("notifications-list")
.findByText("Created by Robert Tableton", { exact: false })
- .should("exist");
+ .should("be.visible");
clickUnsubscribe();
@@ -156,9 +160,18 @@ describe("scenarios > account > notifications", () => {
cy.findByText("Unsubscribe").click();
});
- cy.findByTestId("notifications-list")
- .findByText("Created by Robert Tableton", { exact: false })
- .should("not.exist");
+ cy.wait("@alertUnsubscribe");
+
+ // This was the admin's only notification and they didn't create it, so
+ // unsubscribing empties the list and the notifications-list container
+ // unmounts into the empty state. Anchor on the success toast first, then
+ // assert the list is gone — don't scope the negative check inside the
+ // container that disappears.
+ H.undoToastList()
+ .findByText("Successfully unsubscribed.")
+ .should("be.visible");
+
+ cy.findByTestId("notifications-list").should("not.exist");
});
it("should be able to see created notifications that a user is not subscribed to", () => {