From 3de2bcdc1ab3aeff8cde1b32f758796aff06db8f Mon Sep 17 00:00:00 2001 From: Kerry Date: Thu, 29 Jun 2023 09:02:58 +1200 Subject: [PATCH] Fix: cypress `toasts/analytics-toast.spec.ts` failures (#11153) * Revert "skip broken analytics tests (#11144)" This reverts commit 83ee1946ea073cec20d13176a136ef51d222de7c. * reset window notification permission between tets --- cypress/e2e/settings/security-user-settings-tab.spec.ts | 2 +- cypress/e2e/toasts/analytics-toast.spec.ts | 2 +- cypress/support/login.ts | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/settings/security-user-settings-tab.spec.ts b/cypress/e2e/settings/security-user-settings-tab.spec.ts index aed3eeb689..341624dee3 100644 --- a/cypress/e2e/settings/security-user-settings-tab.spec.ts +++ b/cypress/e2e/settings/security-user-settings-tab.spec.ts @@ -25,7 +25,7 @@ describe("Security user settings tab", () => { cy.stopHomeserver(homeserver); }); - describe.skip("with posthog enabled", () => { + describe("with posthog enabled", () => { beforeEach(() => { // Enable posthog cy.intercept("/config.json?cachebuster=*", (req) => { diff --git a/cypress/e2e/toasts/analytics-toast.spec.ts b/cypress/e2e/toasts/analytics-toast.spec.ts index c1c6edc902..4cc8baa838 100644 --- a/cypress/e2e/toasts/analytics-toast.spec.ts +++ b/cypress/e2e/toasts/analytics-toast.spec.ts @@ -39,7 +39,7 @@ function rejectToast(expectedTitle: string): void { }); } -describe.skip("Analytics Toast", () => { +describe("Analytics Toast", () => { let homeserver: HomeserverInstance; afterEach(() => { diff --git a/cypress/support/login.ts b/cypress/support/login.ts index b830c23f1e..5a65da1761 100644 --- a/cypress/support/login.ts +++ b/cypress/support/login.ts @@ -137,7 +137,14 @@ Cypress.Commands.add( prelaunchFn?.(); return cy - .visit("/") + .visit("/", { + onBeforeLoad(win) { + // reset notification permissions so we have predictable behaviour + // of notifications toast + // @ts-ignore allow setting default + cy.stub(win.Notification, "permission", "default"); + }, + }) .then(() => { // wait for the app to load return cy.get(".mx_MatrixChat", { timeout: 30000 });