test(login): fix login logout test

This commit is contained in:
Edouard Vanbelle
2026-08-09 16:34:58 +02:00
parent 3b11b804e2
commit c61341b890
2 changed files with 17 additions and 2 deletions
+9
View File
@@ -91,9 +91,18 @@ it('exchanges an oidc code on mount and redirects', async () => {
});
it('skips the form when already authenticated', async () => {
// The existing-session probe is gated on `hasSessionHint()` — no
// `oxicloud_csrf` cookie ⇒ probe is skipped and no `fetchMe` fires
// (see login/+page.svelte step 2 for the rationale). Plant the
// cookie the backend would have set on a live session so the
// probe path is exercised end-to-end here.
document.cookie = 'oxicloud_csrf=test-token; Path=/';
m(auth.fetchMe).mockResolvedValue({ id: '1' });
render(LoginPage);
await waitFor(() => expect(goto).toHaveBeenCalled());
// Clean up so the following tests don't inherit the hint and
// unexpectedly probe on their own boot.
document.cookie = 'oxicloud_csrf=; Path=/; Max-Age=0';
});
it('enters setup mode on a fresh install', async () => {