fix(e2e): fix WebAuthn and integration test failures

- Use localhost instead of 127.0.0.1 as TARGET_URL so the WebAuthn RP ID
  is a valid domain (the spec forbids IP addresses)
- Replace request.post('/logout') with page.context().clearCookies() since
  Playwright's request fixture has a separate cookie jar from the page
- Add registerPasskey() helper that waits for 'load' event to reliably
  detect the page reload after successful registration
- Track credential count with getCredentialCount() since credentials
  accumulate across serial tests sharing the same database
- Fix login.spec.js selector from #webauthn-login-form to #webauthn-login-btn
  to match the actual template

All 57 E2E tests now pass (50 migrated + 7 WebAuthn).
This commit is contained in:
Johan Lundberg 2026-02-18 12:45:03 +01:00
parent 71ddf5d8ff
commit 70c97233c5
No known key found for this signature in database
GPG key ID: A6C152738D03C7D1
4 changed files with 70 additions and 43 deletions

View file

@ -4,7 +4,7 @@ const { test, expect } = require('@playwright/test');
const fixtures = JSON.parse(process.env.E2E_FIXTURES || '{}');
test.describe('Full user journey', () => {
test('register via magic link, set password, logout, login', async ({ page, request }) => {
test('register via magic link, set password, logout, login', async ({ page }) => {
// Verify fixtures are loaded
expect(fixtures.register_token).toBeTruthy();
@ -40,7 +40,9 @@ test.describe('Full user journey', () => {
await expect(successMsg).toContainText('Password updated');
// ---- Step 3: Logout ----
await request.post('/logout');
// Clear the session cookie via the browser context (the request fixture
// has a separate cookie jar and cannot clear the page's session).
await page.context().clearCookies();
// Navigate to credentials — should redirect to login since we're logged out
await page.goto('/manage/credentials');