-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix playwright flaky tests Signed-off-by: Michael Telatynski <[email protected]> * Wipe mailhog between test runs Signed-off-by: Michael Telatynski <[email protected]> * Delint Signed-off-by: Michael Telatynski <[email protected]> * Iterate Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
- Loading branch information
Showing
11 changed files
with
105 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,25 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com | |
Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import { expect, test } from "../../element-web-test"; | ||
import { expect, test as base } from "../../element-web-test"; | ||
import { selectHomeserver } from "../utils"; | ||
import { emailHomeserver } from "../../plugins/homeserver/synapse/emailHomeserver.ts"; | ||
import { isDendrite } from "../../plugins/homeserver/dendrite"; | ||
import { Credentials } from "../../plugins/homeserver"; | ||
|
||
const username = "user1234"; | ||
// this has to be password-like enough to please zxcvbn. Needless to say it's just from pwgen. | ||
const password = "oETo7MPf0o"; | ||
const email = "[email protected]"; | ||
|
||
const test = base.extend<{ credentials: Pick<Credentials, "username" | "password"> }>({ | ||
// eslint-disable-next-line no-empty-pattern | ||
credentials: async ({}, use, testInfo) => { | ||
await use({ | ||
username: `user_${testInfo.testId}`, | ||
// this has to be password-like enough to please zxcvbn. Needless to say it's just from pwgen. | ||
password: "oETo7MPf0o", | ||
}); | ||
}, | ||
}); | ||
|
||
test.use(emailHomeserver); | ||
test.use({ | ||
config: { | ||
|
@@ -45,31 +54,35 @@ test.describe("Forgot Password", () => { | |
await expect(page.getByRole("main")).toMatchScreenshot("forgot-password.png"); | ||
}); | ||
|
||
test("renders email verification dialog properly", { tag: "@screenshot" }, async ({ page, homeserver }) => { | ||
const user = await homeserver.registerUser(username, password); | ||
test( | ||
"renders email verification dialog properly", | ||
{ tag: "@screenshot" }, | ||
async ({ page, homeserver, credentials }) => { | ||
const user = await homeserver.registerUser(credentials.username, credentials.password); | ||
|
||
await homeserver.setThreepid(user.userId, "email", email); | ||
await homeserver.setThreepid(user.userId, "email", email); | ||
|
||
await page.goto("/"); | ||
await page.goto("/"); | ||
|
||
await page.getByRole("link", { name: "Sign in" }).click(); | ||
await selectHomeserver(page, homeserver.baseUrl); | ||
await page.getByRole("link", { name: "Sign in" }).click(); | ||
await selectHomeserver(page, homeserver.baseUrl); | ||
|
||
await page.getByRole("button", { name: "Forgot password?" }).click(); | ||
await page.getByRole("button", { name: "Forgot password?" }).click(); | ||
|
||
await page.getByRole("textbox", { name: "Email address" }).fill(email); | ||
await page.getByRole("textbox", { name: "Email address" }).fill(email); | ||
|
||
await page.getByRole("button", { name: "Send email" }).click(); | ||
await page.getByRole("button", { name: "Send email" }).click(); | ||
|
||
await page.getByRole("button", { name: "Next" }).click(); | ||
await page.getByRole("button", { name: "Next" }).click(); | ||
|
||
await page.getByRole("textbox", { name: "New Password", exact: true }).fill(password); | ||
await page.getByRole("textbox", { name: "Confirm new password", exact: true }).fill(password); | ||
await page.getByRole("textbox", { name: "New Password", exact: true }).fill(credentials.password); | ||
await page.getByRole("textbox", { name: "Confirm new password", exact: true }).fill(credentials.password); | ||
|
||
await page.getByRole("button", { name: "Reset password" }).click(); | ||
await page.getByRole("button", { name: "Reset password" }).click(); | ||
|
||
await expect(page.getByRole("button", { name: "Resend" })).toBeInViewport(); | ||
await expect(page.getByRole("button", { name: "Resend" })).toBeInViewport(); | ||
|
||
await expect(page.locator(".mx_Dialog")).toMatchScreenshot("forgot-password-verify-email.png"); | ||
}); | ||
await expect(page.locator(".mx_Dialog")).toMatchScreenshot("forgot-password-verify-email.png"); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,19 +17,30 @@ test.describe("OIDC Native", { tag: ["@no-firefox", "@no-webkit"] }, () => { | |
test.skip(isDendrite, "does not yet support MAS"); | ||
test.slow(); // trace recording takes a while here | ||
|
||
test("can register the oauth2 client and an account", async ({ context, page, homeserver, mailhogClient, mas }) => { | ||
test("can register the oauth2 client and an account", async ({ | ||
context, | ||
page, | ||
homeserver, | ||
mailhogClient, | ||
mas, | ||
}, testInfo) => { | ||
await page.clock.install(); | ||
|
||
const tokenUri = `${mas.baseUrl}/oauth2/token`; | ||
const tokenApiPromise = page.waitForRequest( | ||
(request) => request.url() === tokenUri && request.postDataJSON()["grant_type"] === "authorization_code", | ||
); | ||
|
||
await page.goto("/#/login"); | ||
await page.getByRole("button", { name: "Continue" }).click(); | ||
await registerAccountMas(page, mailhogClient, "alice", "[email protected]", "Pa$sW0rD!"); | ||
|
||
const userId = `alice_${testInfo.testId}`; | ||
await registerAccountMas(page, mailhogClient, userId, "[email protected]", "Pa$sW0rD!"); | ||
|
||
// Eventually, we should end up at the home screen. | ||
await expect(page).toHaveURL(/\/#\/home$/, { timeout: 10000 }); | ||
await expect(page.getByRole("heading", { name: "Welcome alice", exact: true })).toBeVisible(); | ||
await expect(page.getByRole("heading", { name: `Welcome ${userId}`, exact: true })).toBeVisible(); | ||
await page.clock.runFor(20000); // run the timer so we see the token request | ||
|
||
const tokenApiRequest = await tokenApiPromise; | ||
expect(tokenApiRequest.postDataJSON()["grant_type"]).toBe("authorization_code"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-99 Bytes
(99%)
...wright/snapshots/share-dialog/share-dialog.spec.ts/share-dialog-event-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd. | ||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import { AbstractStartedContainer, GenericContainer, StartedTestContainer, Wait } from "testcontainers"; | ||
import mailhog from "mailhog"; | ||
|
||
export class MailhogContainer extends GenericContainer { | ||
constructor() { | ||
super("mailhog/mailhog:latest"); | ||
|
||
this.withExposedPorts(8025).withWaitStrategy(Wait.forListeningPorts()); | ||
} | ||
|
||
public override async start(): Promise<StartedMailhogContainer> { | ||
return new StartedMailhogContainer(await super.start()); | ||
} | ||
} | ||
|
||
export class StartedMailhogContainer extends AbstractStartedContainer { | ||
public readonly client: mailhog.API; | ||
|
||
constructor(container: StartedTestContainer) { | ||
super(container); | ||
this.client = mailhog({ host: container.getHost(), port: container.getMappedPort(8025) }); | ||
} | ||
} |