test(e2e): extract shared playwright helpers

This commit is contained in:
2026-07-01 16:31:25 +08:00
parent c477737c0d
commit 1fbdd41da8
11 changed files with 321 additions and 334 deletions
+7 -17
View File
@@ -1,30 +1,20 @@
import { expect, test } from "@playwright/test";
import { mockCoreApis } from "../../fixtures/api-mocks";
import {
clearBrowserState,
signInWithEmailAndOpenChat,
} from "../../fixtures/test-helpers";
test.beforeEach(async ({ context, page }) => {
await context.clearCookies();
test.beforeEach(async ({ baseURL, context, page }) => {
await clearBrowserState(context, page, baseURL);
await mockCoreApis(page);
});
test("user can log out from the sidebar after email login", async ({
page,
}) => {
await page.goto("/auth");
await page.getByRole("button", { name: /Other Sign In Options/i }).click();
await expect(
page.getByRole("dialog", { name: /Other sign-in options/i }),
).toBeVisible();
await page.getByRole("button", { name: "Email Sign In" }).click();
await expect(page.getByPlaceholder("Email")).toHaveValue(
"chanwillian0@gmail.com",
);
await expect(page.getByPlaceholder("Password")).toHaveValue("12345678");
await page.getByRole("button", { name: "Login" }).click();
await expect(page).toHaveURL(/\/chat$/);
await signInWithEmailAndOpenChat(page);
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
await page.getByRole("button", { name: "Menu" }).click();