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
@@ -1,5 +1,11 @@
import { expect, test } from "@playwright/test";
import {
enterChatFromSplash,
submitEmailLogin,
switchToEmailSignIn,
} from "../../fixtures/test-helpers";
const preReleaseHost = "frontend-test.banlv-ai.com";
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? "";
@@ -12,13 +18,11 @@ test.describe("pre-release email login smoke", () => {
test("guest can switch to email login from other sign-in options and return to chat", async ({
page,
}) => {
await page.goto("/splash", { waitUntil: "domcontentloaded" });
await expect(page.getByRole("button", { name: "Skip" })).toBeVisible();
await Promise.all([
page.waitForURL(/\/chat(?:\?.*)?$/, { timeout: 20_000 }),
page.getByRole("button", { name: "Skip" }).click(),
]);
await enterChatFromSplash(page, {
expectedUrl: /\/chat(?:\?.*)?$/,
timeout: 20_000,
waitUntil: "domcontentloaded",
});
await expect(
page.getByRole("button", { name: "Sign up to unlock more features" }),
@@ -30,21 +34,12 @@ test.describe("pre-release email login smoke", () => {
.click(),
]);
await page.getByRole("button", { name: "Other Sign In Options" }).click();
await expect(
page.getByRole("dialog", { name: "Other sign-in options" }),
).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 Promise.all([
page.waitForURL(/\/chat(?:\?.*)?$/, { timeout: 20_000 }),
page.getByRole("button", { name: "Login" }).click(),
]);
await switchToEmailSignIn(page);
await submitEmailLogin(page, {
expectedUrl: /\/chat(?:\?.*)?$/,
waitForRequest: false,
urlTimeout: 20_000,
});
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();