From f94b4567ec9b441a8d3caa3440c1d4ffe0a791e4 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 10 Apr 2026 12:58:12 +0100 Subject: [PATCH 1/5] In lifecycle tests, dismiss the Verify toast if it appears --- .../element-web/e2e/widget-lifecycle.spec.ts | 11 ++++-- playwright/element-web-test.ts | 35 ++++++++++++++++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/modules/widget-lifecycle/element-web/e2e/widget-lifecycle.spec.ts b/modules/widget-lifecycle/element-web/e2e/widget-lifecycle.spec.ts index 83ad62ec..36022edb 100644 --- a/modules/widget-lifecycle/element-web/e2e/widget-lifecycle.spec.ts +++ b/modules/widget-lifecycle/element-web/e2e/widget-lifecycle.spec.ts @@ -63,7 +63,9 @@ test.describe("Widget Lifecycle", () => { }, }); - test("auto-approves preload and identity", async ({ page, user, homeserver }, testInfo) => { + test("auto-approves preload and identity", async ({ page, user, homeserver, toasts }, testInfo) => { + toasts.rejectToastIfExists("Verify this device"); + // A bot creates a room with the widget pinned to the top panel, then invites the test user. // Because the widget was added by a different user (the bot), Element would normally show a // preload consent dialog before loading it — this test verifies that dialog is skipped. @@ -119,7 +121,9 @@ test.describe("Widget Lifecycle", () => { ).toBeVisible(); }); - test("prompts for capabilities not in the allowlist", async ({ page, user, homeserver }, testInfo) => { + test("prompts for capabilities not in the allowlist", async ({ page, user, homeserver, toasts }, testInfo) => { + toasts.rejectToastIfExists("Verify this device"); + const bot = await homeserver.registerUser(`bot_${testInfo.testId}`, "password", "Bot"); const { room_id: roomId } = await homeserver.csApi.request<{ room_id: string }>( "POST", @@ -180,7 +184,10 @@ test.describe("Widget Lifecycle", () => { page, user, homeserver, + toasts, }, testInfo) => { + toasts.rejectToastIfExists("Verify this device"); + const bot = await homeserver.registerUser(`bot_${testInfo.testId}`, "password", "Bot"); const { room_id: roomId } = await homeserver.csApi.request<{ room_id: string }>( "POST", diff --git a/playwright/element-web-test.ts b/playwright/element-web-test.ts index ca8ca83f..0f171700 100644 --- a/playwright/element-web-test.ts +++ b/playwright/element-web-test.ts @@ -6,13 +6,14 @@ Please see LICENSE files in the repository root for full details. */ import { test as base, expect, type TestFixtures } from "@element-hq/element-web-playwright-common"; +import { Locator, Page } from "@playwright/test"; export interface Options { moduleDir: string; modules: string[]; } -export const test = base.extend({ +export const test = base.extend({ moduleDir: ["", { option: true }], modules: async ({ moduleDir }, use) => { await use([`${moduleDir}/lib/index.js`]); @@ -30,6 +31,38 @@ export const test = base.extend({ await use(page); }, + + toasts: async ({ page }, use) => { + await use(new Toasts(page)); + }, }); export { expect }; + +class Toasts { + public constructor(private readonly page: Page) {} + + /** + * Find a toast with the given title, if it exists. + * + * @param title - title of the toast. + * @returns the Locator for the matching toast, or an empty locator if it + * doesn't exist. + */ + public getToastIfExists(title: string): Locator { + return this.page.locator(".mx_Toast_toast", { hasText: title }).first(); + } + + /** + * Reject a toast with the given title, if it exists. Only works for the + * first toast in the stack. + * + * @param title - title of the toast + */ + public async rejectToastIfExists(title: string): Promise { + const toast = this.getToastIfExists(title).locator('.mx_Toast_buttons button[data-kind="secondary"]'); + if ((await toast.count()) > 0) { + await toast.click(); + } + } +} From 2910bcb94e89ef753bbb31fafaf40dd2705cfd96 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 14 Apr 2026 13:35:38 +0100 Subject: [PATCH 2/5] Remove local `toasts` fixture to replace with one from element-web-playwright-common v3.1.0 --- playwright/element-web-test.ts | 35 +--------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/playwright/element-web-test.ts b/playwright/element-web-test.ts index 0f171700..ca8ca83f 100644 --- a/playwright/element-web-test.ts +++ b/playwright/element-web-test.ts @@ -6,14 +6,13 @@ Please see LICENSE files in the repository root for full details. */ import { test as base, expect, type TestFixtures } from "@element-hq/element-web-playwright-common"; -import { Locator, Page } from "@playwright/test"; export interface Options { moduleDir: string; modules: string[]; } -export const test = base.extend({ +export const test = base.extend({ moduleDir: ["", { option: true }], modules: async ({ moduleDir }, use) => { await use([`${moduleDir}/lib/index.js`]); @@ -31,38 +30,6 @@ export const test = base.extend({ await use(page); }, - - toasts: async ({ page }, use) => { - await use(new Toasts(page)); - }, }); export { expect }; - -class Toasts { - public constructor(private readonly page: Page) {} - - /** - * Find a toast with the given title, if it exists. - * - * @param title - title of the toast. - * @returns the Locator for the matching toast, or an empty locator if it - * doesn't exist. - */ - public getToastIfExists(title: string): Locator { - return this.page.locator(".mx_Toast_toast", { hasText: title }).first(); - } - - /** - * Reject a toast with the given title, if it exists. Only works for the - * first toast in the stack. - * - * @param title - title of the toast - */ - public async rejectToastIfExists(title: string): Promise { - const toast = this.getToastIfExists(title).locator('.mx_Toast_buttons button[data-kind="secondary"]'); - if ((await toast.count()) > 0) { - await toast.click(); - } - } -} From 0a3e5fe59b7ce40a7b6886808a06a063e354716d Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 14 Apr 2026 13:49:05 +0100 Subject: [PATCH 3/5] Update element-web-playwright-common --- yarn.lock | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index e1e4384a..d132d14c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -571,6 +571,20 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz#bbe12dca5b4ef983a0d0af4b07b9bc90ea0ababa" integrity sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA== +"@element-hq/element-web-playwright-common@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@element-hq/element-web-playwright-common/-/element-web-playwright-common-3.1.0.tgz#fa80f14ec17a5ab77a9d8a0ab88458113d20bc4a" + integrity sha512-5mChlmiYzEwDnak5tY9zTWFRzzmOI8DerLkGjsnbGcNGJFfJCCNP0IRCzBVIw2mn5UsainweZp3qfyUzowK9FQ== + dependencies: + "@axe-core/playwright" "^4.10.1" + "@testcontainers/postgresql" "^11.0.0" + glob "^13.0.5" + lodash-es "^4.17.23" + mailpit-api "^1.2.0" + strip-ansi "^7.1.0" + testcontainers "^11.0.0" + yaml "^2.7.0" + "@emnapi/core@^1.7.1": version "1.8.1" resolved "https://registry.yarnpkg.com/@emnapi/core/-/core-1.8.1.tgz#fd9efe721a616288345ffee17a1f26ac5dd01349" @@ -2189,9 +2203,9 @@ "@types/lodash" "*" "@types/lodash@*": - version "4.17.16" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.16.tgz#94ae78fab4a38d73086e962d0b65c30d816bfb0a" - integrity sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g== + version "4.17.24" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.24.tgz#4ae334fc62c0e915ca8ed8e35dcc6d4eeb29215f" + integrity sha512-gIW7lQLZbue7lRSWEFql49QJJWThrTFFeIMJdp3eH4tKoxm1OvEPg02rm4wCCSHS0cL3/Fizimb35b7k8atwsQ== "@types/node@*": version "22.13.10" @@ -7549,16 +7563,11 @@ typed-array-length@^1.0.7: possible-typed-array-names "^1.0.0" reflect.getprototypeof "^1.0.6" -typescript@5.9.3, typescript@^5.7.3: +typescript@5.9.3, typescript@^5.7.3, typescript@^5.8.2: version "5.9.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== -typescript@^5.8.2: - version "5.8.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.2.tgz#8170b3702f74b79db2e5a96207c15e65807999e4" - integrity sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ== - ufo@^1.5.4: version "1.5.4" resolved "https://registry.yarnpkg.com/ufo/-/ufo-1.5.4.tgz#16d6949674ca0c9e0fbbae1fa20a71d7b1ded754" From bd9ad3cf48e39762ef4173365067b689153c031e Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 14 Apr 2026 13:57:26 +0100 Subject: [PATCH 4/5] Remove yarn.lock effects of explicit version for element-web-playwright-common --- yarn.lock | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2bc2c5a7..d23bfc28 100644 --- a/yarn.lock +++ b/yarn.lock @@ -552,20 +552,6 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz#bbe12dca5b4ef983a0d0af4b07b9bc90ea0ababa" integrity sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA== -"@element-hq/element-web-playwright-common@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@element-hq/element-web-playwright-common/-/element-web-playwright-common-3.1.0.tgz#fa80f14ec17a5ab77a9d8a0ab88458113d20bc4a" - integrity sha512-5mChlmiYzEwDnak5tY9zTWFRzzmOI8DerLkGjsnbGcNGJFfJCCNP0IRCzBVIw2mn5UsainweZp3qfyUzowK9FQ== - dependencies: - "@axe-core/playwright" "^4.10.1" - "@testcontainers/postgresql" "^11.0.0" - glob "^13.0.5" - lodash-es "^4.17.23" - mailpit-api "^1.2.0" - strip-ansi "^7.1.0" - testcontainers "^11.0.0" - yaml "^2.7.0" - "@emnapi/core@^1.7.1": version "1.8.1" resolved "https://registry.yarnpkg.com/@emnapi/core/-/core-1.8.1.tgz#fd9efe721a616288345ffee17a1f26ac5dd01349" From 004fe2459573c9ac9bc5ddb6527aa4668ccbdf9f Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 14 Apr 2026 14:19:28 +0100 Subject: [PATCH 5/5] Depend on @element-hq/element-web-playwright-common v3.1.0 --- package.json | 2 +- yarn.lock | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 9d41d8bd..c3fee019 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@action-validator/cli": "^0.6.0", "@action-validator/core": "^0.6.0", "@element-hq/element-web-module-api": "*", - "@element-hq/element-web-playwright-common": "^3.0.0", + "@element-hq/element-web-playwright-common": "^3.1.0", "@playwright/test": "^1.52.0", "@stylistic/eslint-plugin": "^5.0.0", "@types/node": "^22.12.0", diff --git a/yarn.lock b/yarn.lock index d23bfc28..9683118a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -552,6 +552,20 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz#bbe12dca5b4ef983a0d0af4b07b9bc90ea0ababa" integrity sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA== +"@element-hq/element-web-playwright-common@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@element-hq/element-web-playwright-common/-/element-web-playwright-common-3.1.0.tgz#fa80f14ec17a5ab77a9d8a0ab88458113d20bc4a" + integrity sha512-5mChlmiYzEwDnak5tY9zTWFRzzmOI8DerLkGjsnbGcNGJFfJCCNP0IRCzBVIw2mn5UsainweZp3qfyUzowK9FQ== + dependencies: + "@axe-core/playwright" "^4.10.1" + "@testcontainers/postgresql" "^11.0.0" + glob "^13.0.5" + lodash-es "^4.17.23" + mailpit-api "^1.2.0" + strip-ansi "^7.1.0" + testcontainers "^11.0.0" + yaml "^2.7.0" + "@emnapi/core@^1.7.1": version "1.8.1" resolved "https://registry.yarnpkg.com/@emnapi/core/-/core-1.8.1.tgz#fd9efe721a616288345ffee17a1f26ac5dd01349" @@ -2198,18 +2212,6 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== -"@types/lodash-es@^4.17.12": - version "4.17.12" - resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.12.tgz#65f6d1e5f80539aa7cfbfc962de5def0cf4f341b" - integrity sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ== - dependencies: - "@types/lodash" "*" - -"@types/lodash@*": - version "4.17.24" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.24.tgz#4ae334fc62c0e915ca8ed8e35dcc6d4eeb29215f" - integrity sha512-gIW7lQLZbue7lRSWEFql49QJJWThrTFFeIMJdp3eH4tKoxm1OvEPg02rm4wCCSHS0cL3/Fizimb35b7k8atwsQ== - "@types/node@*": version "22.13.10" resolved "https://registry.yarnpkg.com/@types/node/-/node-22.13.10.tgz#df9ea358c5ed991266becc3109dc2dc9125d77e4" @@ -7681,7 +7683,7 @@ typed-array-length@^1.0.7: possible-typed-array-names "^1.0.0" reflect.getprototypeof "^1.0.6" -typescript@5.9.3, typescript@^5.7.3, typescript@^5.8.2: +typescript@5.9.3, typescript@^5.7.3: version "5.9.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==