test(e2e): update specs for multi-character routes

This commit is contained in:
2026-07-17 16:49:20 +08:00
parent 8a53a07e0e
commit 78e97c3612
10 changed files with 60 additions and 28 deletions
+9 -1
View File
@@ -8,6 +8,13 @@ export const e2eEmailCredentials = {
};
export const splashStartChatButtonName = "Start Chatting";
export const defaultCharacterSlug = "elio";
export const defaultCharacterSplashPath = `/characters/${defaultCharacterSlug}/splash`;
export const defaultCharacterChatPath = `/characters/${defaultCharacterSlug}/chat`;
export const defaultCharacterSidebarPath = `/characters/${defaultCharacterSlug}/sidebar`;
export const defaultCharacterChatUrl = new RegExp(
`/characters/${defaultCharacterSlug}/chat(?:\\?.*)?$`,
);
export function getSplashStartChatButton(page: Page) {
return page.getByRole("button", { name: splashStartChatButtonName });
@@ -24,8 +31,9 @@ export async function setEmailSessionStorage(page: Page) {
}
export async function seedEmailSession(page: Page) {
await page.goto("/splash");
await page.goto(defaultCharacterSplashPath);
await setEmailSessionStorage(page);
await page.reload();
}
export async function switchToEmailSignIn(page: Page) {
+13 -4
View File
@@ -1,6 +1,11 @@
import { expect, type BrowserContext, type Page } from "@playwright/test";
import { seedEmailSession } from "./auth";
import {
defaultCharacterChatPath,
defaultCharacterChatUrl,
defaultCharacterSplashPath,
seedEmailSession,
} from "./auth";
export async function clearBrowserState(context: BrowserContext, page: Page, baseURL?: string) {
await context.clearCookies();
@@ -12,8 +17,12 @@ export async function clearBrowserState(context: BrowserContext, page: Page, bas
}
export async function enterChatFromSplash(page: Page, options: { expectedUrl?: RegExp; timeout?: number; waitUntil?: "commit" | "domcontentloaded" | "load" | "networkidle" } = {}) {
const { expectedUrl = /\/chat$/, timeout = 10_000, waitUntil } = options;
await page.goto("/splash", { waitUntil });
const {
expectedUrl = defaultCharacterChatUrl,
timeout = 10_000,
waitUntil,
} = options;
await page.goto(defaultCharacterSplashPath, { waitUntil });
const startChatButton = page.getByRole("button", { name: "Start Chatting" });
await expect(startChatButton).toBeVisible({ timeout });
await expect(startChatButton).toBeEnabled();
@@ -34,7 +43,7 @@ export async function dismissChatInterruptions(page: Page) {
export async function signInWithEmailAndOpenChat(page: Page) {
await seedEmailSession(page);
const historyResponsePromise = page.waitForResponse("**/api/chat/history**");
await page.goto("/chat");
await page.goto(defaultCharacterChatPath);
await historyResponsePromise;
await dismissChatInterruptions(page);
await expect(page.getByRole("textbox", { name: "Message" })).toBeEnabled({ timeout: 20_000 });