Ensure no race condition between page load and waitForRequest set up (#109)

Fixes https://github.com/element-hq/element-web/issues/27572

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/28192/head
Michael Telatynski 2024-10-02 11:21:44 +01:00 committed by GitHub
parent 2da5d9b1c1
commit 2a183c76c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -8,6 +8,7 @@ Please see LICENSE files in the repository root for full details.
import { test, expect, registerAccountMas } from "."; import { test, expect, registerAccountMas } from ".";
import { isDendrite } from "../../plugins/homeserver/dendrite"; import { isDendrite } from "../../plugins/homeserver/dendrite";
import { ElementAppPage } from "../../pages/ElementAppPage.ts";
test.describe("OIDC Native", () => { test.describe("OIDC Native", () => {
test.skip(isDendrite, "does not yet support MAS"); test.skip(isDendrite, "does not yet support MAS");
@ -17,7 +18,7 @@ test.describe("OIDC Native", () => {
labsFlags: ["feature_oidc_native_flow"], labsFlags: ["feature_oidc_native_flow"],
}); });
test("can register the oauth2 client and an account", async ({ context, page, homeserver, mailhog, app, mas }) => { test("can register the oauth2 client and an account", async ({ context, page, homeserver, mailhog, mas }) => {
const tokenUri = `http://localhost:${mas.port}/oauth2/token`; const tokenUri = `http://localhost:${mas.port}/oauth2/token`;
const tokenApiPromise = page.waitForRequest( const tokenApiPromise = page.waitForRequest(
(request) => request.url() === tokenUri && request.postDataJSON()["grant_type"] === "authorization_code", (request) => request.url() === tokenUri && request.postDataJSON()["grant_type"] === "authorization_code",
@ -36,6 +37,7 @@ test.describe("OIDC Native", () => {
const deviceId = await page.evaluate<string>(() => window.localStorage.mx_device_id); const deviceId = await page.evaluate<string>(() => window.localStorage.mx_device_id);
const app = new ElementAppPage(page);
await app.settings.openUserSettings("Account"); await app.settings.openUserSettings("Account");
const newPagePromise = context.waitForEvent("page"); const newPagePromise = context.waitForEvent("page");
await page.getByRole("button", { name: "Manage account" }).click(); await page.getByRole("button", { name: "Manage account" }).click();