feat(e2e): add email login flow tests and mock responses for email user

This commit is contained in:
2026-06-29 17:43:27 +08:00
parent 187bf3469e
commit e951d56076
5 changed files with 86 additions and 96 deletions
@@ -0,0 +1,48 @@
import { expect, test } from "@playwright/test";
import { mockCoreApis } from "../../fixtures/api-mocks";
test.beforeEach(async ({ context, page }) => {
await context.clearCookies();
await mockCoreApis(page);
});
test("user can email login from other sign-in options and return to chat", async ({
page,
}) => {
await page.goto("/splash");
await page.getByRole("button", { name: "Skip" }).click();
await expect(page).toHaveURL(/\/chat$/);
await page
.getByRole("button", { name: "Sign up to unlock more features" })
.click();
await expect(page).toHaveURL(/\/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");
const loginRequestPromise = page.waitForRequest("**/api/auth/login");
await page.getByRole("button", { name: "Login" }).click();
const loginRequest = await loginRequestPromise;
expect(loginRequest.postDataJSON()).toMatchObject({
email: "chanwillian0@gmail.com",
password: "12345678",
platform: "web",
isTestAccount: true,
});
await expect(page).toHaveURL(/\/chat$/);
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
});
-39
View File
@@ -1,39 +0,0 @@
import { expect, test } from "@playwright/test";
import { mockCoreApis } from "../../fixtures/api-mocks";
test.beforeEach(async ({ context, page }) => {
await context.clearCookies();
await mockCoreApis(page);
});
test("guest can skip splash, enter chat, and send a message", async ({ page }) => {
await page.goto("/splash");
await page.getByRole("button", { name: "Skip" }).click();
await expect(page).toHaveURL(/\/chat$/);
const messageInput = page.getByRole("textbox", { name: "Message" });
await expect(messageInput).toBeVisible();
await messageInput.fill("hello e2e");
await page.getByRole("button", { name: "Send message" }).click();
await expect(page.getByText("hello e2e")).toBeVisible();
await expect(page.getByText("Hello from the E2E boyfriend.")).toBeVisible();
});
test("subscription page renders mocked plans without touching real payment", async ({
page,
}) => {
await page.goto("/splash");
await page.getByRole("button", { name: "Skip" }).click();
await expect(page).toHaveURL(/\/chat$/);
await page.goto("/subscription?type=vip");
await expect(page.getByText("Subscribe to become the VIP Member")).toBeVisible();
await expect(page.getByText("Monthly")).toBeVisible();
await expect(page.getByText("Quarterly")).toBeVisible();
await expect(page.getByRole("button", { name: /Pay and Activiate/i })).toBeVisible();
});