fix: add auth middleware to profile page and update visual snapshots

- Add `middleware: 'auth'` to member/profile.vue (was missing)
- Harden loginAsAdmin helper to wait for networkidle after redirect so
  auth-init plugin and admin middleware finish before tests navigate
- Regenerate visual baselines to reflect updated profile page UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jennie Robinson Faber 2026-04-07 15:00:23 +01:00
parent fb25e72215
commit 4271ed0c6f
5 changed files with 12 additions and 3 deletions

View file

@ -6,18 +6,23 @@
/**
* Login as admin via the dev test-login endpoint.
* Creates a test admin user if none exists and sets the auth cookie.
* Handles cases where the dev server is slow to redirect under load.
* Waits for networkidle so the client-side auth check (admin middleware +
* auth-init plugin) completes before the test navigates anywhere.
*/
export async function loginAsAdmin(page) {
await page.goto('/api/dev/test-login', { waitUntil: 'domcontentloaded' })
// The endpoint sets the cookie and redirects to /admin.
// Under heavy parallel load the redirect may not complete, so fall back to manual navigation.
// waitForURL fires as soon as the URL changes — not when JS finishes.
// waitForLoadState('networkidle') ensures the auth-init plugin and admin
// middleware have both completed their checkMemberStatus() calls before
// the test proceeds.
try {
await page.waitForURL(/\/admin/, { timeout: 15000 })
await page.waitForLoadState('networkidle')
} catch {
// Cookie should be set even if redirect failed — navigate manually
await page.goto('/admin', { waitUntil: 'domcontentloaded' })
await page.goto('/admin', { waitUntil: 'networkidle' })
await page.waitForURL(/\/admin/)
}
}