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' }) }