glam/apps/archief-assistent/e2e/auth.setup.ts
kempersc 004d342935 chore: minor updates and evaluation results
- auth.setup.ts: require env vars for test credentials (no hardcoded defaults)
- manifest.json: update schema manifest
- full_evaluation_results.json: add RAG evaluation results
- petra-links.json: update birth date from web claim
2026-01-09 21:10:55 +01:00

55 lines
1.8 KiB
TypeScript

import { Page } from '@playwright/test'
/**
* Helper to login and navigate to chat page
*
* Uses environment variables for test credentials:
* - TEST_USER_EMAIL: Email for test account
* - TEST_USER_PASSWORD: Password for test account
*
* Run tests with credentials:
* TEST_USER_EMAIL=your@email.com TEST_USER_PASSWORD=yourpass pnpm test:e2e
*/
export async function loginAndNavigate(page: Page): Promise<void> {
await page.goto('/')
// Get credentials from environment variables
const email = process.env.TEST_USER_EMAIL
const password = process.env.TEST_USER_PASSWORD
if (!email || !password) {
throw new Error(
'TEST_USER_EMAIL and TEST_USER_PASSWORD environment variables are required.\n' +
'Run: TEST_USER_EMAIL=your@email.com TEST_USER_PASSWORD=yourpass pnpm test:e2e'
)
}
// Check if already logged in (chat-input visible)
const chatInput = page.getByTestId('chat-input')
try {
await chatInput.waitFor({ state: 'visible', timeout: 2000 })
return // Already logged in
} catch {
// Not logged in, continue with login flow
}
// Perform login
const emailInput = page.getByRole('textbox', { name: /e-mail/i })
const passwordInput = page.getByRole('textbox', { name: /wachtwoord/i })
const loginButton = page.getByRole('button', { name: /inloggen/i })
await emailInput.fill(email)
await passwordInput.fill(password)
await loginButton.click()
// Wait for chat page to load
await page.waitForSelector('[data-testid="chat-input"]', { timeout: 30000 })
}
/**
* Wait for chat interface to be ready
*/
export async function waitForChatReady(page: Page): Promise<void> {
await page.waitForSelector('[data-testid="chat-input"]', { timeout: 10000 })
await page.waitForSelector('[data-testid="send-button"]', { timeout: 10000 })
}