Files
Radosław SmolińskiandClaude Fable 5.2 e77c607bca R4-3: pnpm e2e:built (webpack and Turbopack); Playwright runs reset the test admins first
The command builds the reference site with both bundlers, checks the public files for a package manifest and runs
the late-staff spec and the published-files check against each built site. A global setup resets the test admins
and their stored 2FA attempt counts before every run, so a spec no longer depends on what ran before it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 02:53:41 +01:00

15 lines
986 B
TypeScript

import { execFileSync } from 'node:child_process'
/**
* Before every Playwright run: the test admins are made (or reset) and their stored 2FA attempt counts cleared
* (e2e/create-test-admin.ts). The count is kept in the database — 5 verify attempts per account in 10 minutes —
* so without this a second run within ten minutes, or one spec run after the whole suite, would find the test
* admin locked out: the result would depend on what ran before. Skipped when the test admin is not configured
* (the specs that need it skip themselves) or with E2E_SKIP_ADMIN_SETUP=1.
*/
export default function globalSetup(): void {
const { E2E_ADMIN_EMAIL, E2E_ADMIN_PASSWORD, E2E_SKIP_ADMIN_SETUP, E2E_TOTP_SECRET } = process.env
if (E2E_SKIP_ADMIN_SETUP === '1' || !E2E_ADMIN_EMAIL || !E2E_ADMIN_PASSWORD || !E2E_TOTP_SECRET) {return}
execFileSync('pnpm', ['payload', 'run', 'e2e/create-test-admin.ts'], { env: { ...process.env, NODE_ENV: 'development' }, stdio: 'inherit' })
}