Files
jacobh2 ed5680253e Check in a browser what the unit tests cannot see
Every serious defect in this project was found by opening the app, most
recently a feature that rendered blank cards to every user while its tests
passed, and a progress bar labelled in the wrong unit. Five checks now run
without a person: that the age-four figures on screen match what the API
computed, that a multi-week period draws as one bar rather than fragments,
that Sundays and holidays are red where Saturdays are not, that no identifier
leaks into visible text, and that no page logs an error.

Three of them were confirmed by reintroducing the original bug and watching
the right test fail. Dates are derived rather than written down: Easter is
computed independently instead of asked of the system under test, and the
fixture period is placed relative to today, so the suite does not expire.

It runs as its own job and does not block a merge until it has proved itself
stable.
2026-09-17 19:46:17 +02:00

30 lines
1.2 KiB
TypeScript

/**
* Playwright "setup" project: logs in through the real UI as the seeded
* demo user and saves the resulting storage state (the httpOnly refresh
* cookie + the `workspaceId` the app writes to localStorage on login) for
* every other project to reuse.
*
* The access token itself lives only in React state (see AuthContext.tsx)
* so it can't be persisted this way — but that's fine: on the next page
* load, `AuthProvider` calls `POST /api/auth/refresh` using the persisted
* refresh cookie and re-obtains one automatically.
*/
import { test as setup, expect } from '@playwright/test'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { DEMO_EMAIL, DEMO_PASSWORD } from './support/api'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
export const AUTH_FILE = path.join(__dirname, '.auth/user.json')
setup('authenticate as the seeded demo user', async ({ page }) => {
await page.goto('/auth')
await page.getByTestId('auth-email').fill(DEMO_EMAIL)
await page.getByTestId('auth-password').fill(DEMO_PASSWORD)
await page.getByTestId('auth-submit').click()
await expect(page.getByTestId('dashboard')).toBeVisible({ timeout: 15_000 })
await page.context().storageState({ path: AUTH_FILE })
})