import type { Page } from '@playwright/test'; export const TEST_USER = { email: process.env['E2E_USER_EMAIL'] ?? 'e2e@example.com', password: process.env['E2E_USER_PASSWORD'] ?? 'password123', name: 'E2E Test User', }; export const ADMIN_USER = { email: process.env['E2E_ADMIN_EMAIL'] ?? 'admin@example.com', password: process.env['E2E_ADMIN_PASSWORD'] ?? 'adminpass123', name: 'E2E Admin User', }; /** * Fill the login form and submit, then wait for the post-login redirect to * /chat. On failed login the wait times out and is swallowed: the page stays * on /login, and the callers' `test.skip(!url.includes('/chat'))` guards see * that. Without this wait, every guard read page.url() before the redirect * happened and skipped its suite even when login succeeded (#1445). */ export async function loginAs(page: Page, email: string, password: string): Promise { await page.goto('/login'); await page.getByLabel('Email').fill(email); await page.getByLabel('Password').fill(password); await page.getByRole('button', { name: /sign in/i }).click(); await page.waitForURL(/\/chat/, { timeout: 10_000 }).catch(() => {}); }