glam/apps/archief-assistent/e2e/auth.setup.ts
kempersc ea35da02dc test(archief-assistent): add Playwright E2E test suite
- Add chat.spec.ts for RAG query testing
- Add count-queries.spec.ts for aggregation validation
- Add map-panel.spec.ts for geographic feature testing
- Add cache.spec.ts for response caching verification
- Add auth.setup.ts for authentication handling
- Configure playwright.config.ts for multi-browser testing
- Tests run against production archief.support
2026-01-09 21:09:56 +01:00

47 lines
1.5 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
*
* Set these in .env.test or export them before running tests.
*/
export async function loginAndNavigate(page: Page): Promise<void> {
await page.goto('/')
// Default test credentials (override with environment variables)
const email = 'test@example.com'
const password = 'testpassword'
// 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 })
}