mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-12 20:06:57 +02:00
Every test in the `app` project submitted the login form through the authenticatedPage fixture: a page load, an Argon2 verification on the server, a redirect and a networkidle wait. Over 137 tests that was roughly half of the median test's 1.8s. A new `login-state` setup project (tests/e2e/auth.setup.ts) authenticates once after auth.spec has created the account and saves the session cookie to data/test-storage-state.json. The `app` project loads it into every context, so setupAndLogin takes its "session still valid" path and the fixture is reduced to a page load. pwa.spec and mcp.spec describe anonymous visitors and opt out with an empty storageState so their baseline is unchanged. Local run, 4 workers: summed test time 276s -> 256s, median 1.8s -> 1.6s. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
19 lines
849 B
TypeScript
19 lines
849 B
TypeScript
import { test as setup } from '@playwright/test';
|
|
import { setupAndLogin } from './helpers/fixtures';
|
|
import { STORAGE_STATE_FILE } from './global-setup';
|
|
|
|
/**
|
|
* Log in as the admin once and persist the session cookie. The `app` project
|
|
* loads this storage state into every browser context, so tests start already
|
|
* authenticated instead of each one submitting the login form (~0.8s per test,
|
|
* roughly half of a typical test's duration).
|
|
*
|
|
* The admin's own session is never revoked by any test: admin-users only
|
|
* resets/revokes victim accounts, and auth.spec's logout scenario runs in the
|
|
* auth-setup project with its own context before this setup executes.
|
|
*/
|
|
setup('authenticate as admin and save storage state', async ({ page }) => {
|
|
await setupAndLogin(page);
|
|
await page.context().storageState({ path: STORAGE_STATE_FILE });
|
|
});
|