teqo/tests/e2e/setup.e2e.spec.ts
Francisco Ignácio Fontoura Solla 763f64080a Deliver B40: biometric login for /campanha.
WebAuthn platform passkeys: opt-in enrollment after a password login, a
password-less sign-in that mints the same 14-day campaign-token, and
revocation from the profile. The session is minted through Payload's public
pieces (checkLoginPermission, addSessionToUser, getFieldsToSign, jwtSign)
inside a transaction with an advisory lock, so a passkey login neither
bypasses a lockout nor evicts the account's other sessions. The rpID is
derived from NEXT_PUBLIC_SITE_URL and resolves to null when the request host
disagrees, so previews never offer a ceremony the browser would refuse.
2026-07-28 10:59:23 -03:00

42 lines
1.5 KiB
TypeScript

import { expect, test } from '@playwright/test'
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? 'http://localhost:3000'
test('prewarms shared Next route bundles sequentially', async ({ request }) => {
test.slow()
for (const path of [
'/campanha/login',
'/campanha',
'/campanha/municipios',
'/campanha/territorios',
'/campanha/municipios/e2e-prewarm',
'/campanha/perfil',
'/campanha/demandas',
'/campanha/liderancas',
'/campanha/conceitos',
'/campanha/convite/e2e-prewarm',
'/',
]) {
const response = await request.get(`${baseURL}${path}`)
expect(response.ok(), `Failed to prewarm ${path}`).toBe(true)
}
// POST-only API route handlers (auto-save popovers): Next dev compiles a
// route on its first hit, and that compile can trigger a full-page reload
// for any client currently connected — which aborts an in-flight fetch mid
// test. An unauthenticated POST never succeeds, but it still forces the
// compile before any spec's client makes the real request.
for (const path of [
'/campanha/municipios/advisors',
'/campanha/municipios/engagement-level',
'/campanha/municipios/expected-votes',
'/campanha/municipios/political-trend',
'/campanha/liderancas/support-status',
'/campanha/webauthn/login-options',
'/campanha/webauthn/login',
'/campanha/webauthn/register-options',
'/campanha/webauthn/register',
]) {
await request.post(`${baseURL}${path}`, { data: {} }).catch(() => undefined)
}
})