Milestone A of the frontend test plan. Sets up the test rig — config, globalSetup that probes the backend and seeds an admin session into storageState, lightweight fixtures, and a 3-test smoke spec — without yet covering any user journeys (those land in Milestone B). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
22 lines
927 B
TypeScript
22 lines
927 B
TypeScript
import type { Page } from '@playwright/test';
|
|
import { expect } from '@playwright/test';
|
|
|
|
const ADMIN_USERNAME = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
|
const ADMIN_PASSWORD = process.env.E2E_ADMIN_PASSWORD ?? 'admin';
|
|
|
|
// Drive the login form like a real user. globalSetup already saves a
|
|
// storageState for the shared admin, so most tests don't need this —
|
|
// it's reserved for specs that explicitly cover the login UI.
|
|
export async function loginAsAdmin(page: Page): Promise<void> {
|
|
await page.goto('/admin/login');
|
|
await page.getByLabel('Username').fill(ADMIN_USERNAME);
|
|
await page.getByLabel('Password').fill(ADMIN_PASSWORD);
|
|
await page.getByRole('button', { name: /sign in/i }).click();
|
|
await expect(page).toHaveURL(/\/admin\/apps$/);
|
|
}
|
|
|
|
export async function logout(page: Page): Promise<void> {
|
|
await page.getByRole('button', { name: /logout/i }).click();
|
|
await expect(page).toHaveURL(/\/admin\/login$/);
|
|
}
|