test(e2e): update specs for multi-character routes
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user