2024-02-21 10:43:47 +00:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2024-02-21 10:43:47 +00:00
|
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-09 14:57:16 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2024-02-21 10:43:47 +00:00
|
|
|
*/
|
|
|
|
|
|
2026-02-09 08:39:11 +00:00
|
|
|
import { type MailpitClient } from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js";
|
2025-02-05 13:25:06 +00:00
|
|
|
import { type Page } from "@playwright/test";
|
2024-02-21 10:43:47 +00:00
|
|
|
|
2025-01-07 18:11:44 +00:00
|
|
|
import { expect } from "../../element-web-test";
|
2024-02-21 10:43:47 +00:00
|
|
|
|
2025-06-17 11:31:08 +01:00
|
|
|
/**
|
|
|
|
|
* Click through registering a new user in the MAS UI.
|
|
|
|
|
*/
|
2024-02-21 10:43:47 +00:00
|
|
|
export async function registerAccountMas(
|
|
|
|
|
page: Page,
|
2025-01-27 15:35:06 +00:00
|
|
|
mailpit: MailpitClient,
|
2024-02-21 10:43:47 +00:00
|
|
|
username: string,
|
|
|
|
|
email: string,
|
|
|
|
|
password: string,
|
|
|
|
|
): Promise<void> {
|
|
|
|
|
await expect(page.getByText("Please sign in to continue:")).toBeVisible();
|
|
|
|
|
|
|
|
|
|
await page.getByRole("link", { name: "Create Account" }).click();
|
|
|
|
|
await page.getByRole("textbox", { name: "Username" }).fill(username);
|
|
|
|
|
await page.getByRole("textbox", { name: "Email address" }).fill(email);
|
|
|
|
|
await page.getByRole("textbox", { name: "Password", exact: true }).fill(password);
|
|
|
|
|
await page.getByRole("textbox", { name: "Confirm Password" }).fill(password);
|
|
|
|
|
await page.getByRole("button", { name: "Continue" }).click();
|
|
|
|
|
|
2026-07-30 10:07:03 +01:00
|
|
|
let code!: string;
|
2024-02-21 10:43:47 +00:00
|
|
|
await expect(async () => {
|
2025-01-27 15:35:06 +00:00
|
|
|
const messages = await mailpit.listMessages();
|
|
|
|
|
expect(messages.messages[0].To[0].Address).toEqual(email);
|
|
|
|
|
const text = await mailpit.renderMessageText(messages.messages[0].ID);
|
2026-07-30 10:07:03 +01:00
|
|
|
[, code] = text.match(/Your verification code to confirm this email address is: (\d{6})/)!;
|
2024-02-21 10:43:47 +00:00
|
|
|
}).toPass();
|
|
|
|
|
|
|
|
|
|
await page.getByRole("textbox", { name: "6-digit code" }).fill(code);
|
|
|
|
|
await page.getByRole("button", { name: "Continue" }).click();
|
2025-05-28 18:28:10 +00:00
|
|
|
await page.getByRole("textbox", { name: "Display Name" }).fill(username);
|
|
|
|
|
await page.getByRole("button", { name: "Continue" }).click();
|
2025-12-04 11:28:25 +01:00
|
|
|
await expect(page.getByText("Continue to Element?")).toBeVisible();
|
2024-02-21 10:43:47 +00:00
|
|
|
await page.getByRole("button", { name: "Continue" }).click();
|
|
|
|
|
}
|
2025-06-17 11:31:08 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Click through entering username and password into the MAS login prompt.
|
|
|
|
|
*/
|
|
|
|
|
export async function logInAccountMas(page: Page, username: string, password: string): Promise<void> {
|
|
|
|
|
await expect(page.getByText("Please sign in to continue:")).toBeVisible();
|
|
|
|
|
|
|
|
|
|
await page.getByRole("textbox", { name: "Username" }).fill(username);
|
|
|
|
|
await page.getByRole("textbox", { name: "Password", exact: true }).fill(password);
|
|
|
|
|
await page.getByRole("button", { name: "Continue" }).click();
|
|
|
|
|
|
2025-12-04 11:28:25 +01:00
|
|
|
await expect(page.getByText("Continue to Element?")).toBeVisible();
|
2025-06-17 11:31:08 +01:00
|
|
|
await page.getByRole("button", { name: "Continue" }).click();
|
|
|
|
|
}
|