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:
parent
fb25e72215
commit
4271ed0c6f
5 changed files with 12 additions and 3 deletions
|
|
@ -325,6 +325,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
definePageMeta({
|
||||||
|
middleware: 'auth',
|
||||||
|
});
|
||||||
|
|
||||||
const { memberData, checkMemberStatus } = useAuth();
|
const { memberData, checkMemberStatus } = useAuth();
|
||||||
const { openLoginModal } = useLoginModal();
|
const { openLoginModal } = useLoginModal();
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 232 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 292 KiB After Width: | Height: | Size: 293 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 333 KiB After Width: | Height: | Size: 300 KiB |
|
|
@ -6,18 +6,23 @@
|
||||||
/**
|
/**
|
||||||
* Login as admin via the dev test-login endpoint.
|
* Login as admin via the dev test-login endpoint.
|
||||||
* Creates a test admin user if none exists and sets the auth cookie.
|
* 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) {
|
export async function loginAsAdmin(page) {
|
||||||
await page.goto('/api/dev/test-login', { waitUntil: 'domcontentloaded' })
|
await page.goto('/api/dev/test-login', { waitUntil: 'domcontentloaded' })
|
||||||
|
|
||||||
// The endpoint sets the cookie and redirects to /admin.
|
// 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 {
|
try {
|
||||||
await page.waitForURL(/\/admin/, { timeout: 15000 })
|
await page.waitForURL(/\/admin/, { timeout: 15000 })
|
||||||
|
await page.waitForLoadState('networkidle')
|
||||||
} catch {
|
} catch {
|
||||||
// Cookie should be set even if redirect failed — navigate manually
|
// 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/)
|
await page.waitForURL(/\/admin/)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue