fix: Svelte 5 test event delegation + login auth regression #46

Merged
marcel merged 2 commits from fix/svelte5-test-delegation-and-login-auth into main 2026-03-22 14:56:14 +01:00
Owner

Summary

  • Fix Svelte 5 test failures: Playwright locator .click() dispatches events via the CDP bridge which doesn't trigger Svelte 5's $.delegated event handlers. Replaced all affected locator clicks with native element.click() / element.focus() DOM calls. Also added missing cleanup() to afterEach in several spec files, and fixed TagInput.svelte to use untrack() when reading bindable state after an await.
  • Fix login regression: handleFetch was short-circuiting with 401 for any API request without an auth_token cookie — which blocked the login action itself, since it explicitly sends Basic auth credentials before a cookie exists. Fix: pass requests that already carry an Authorization header straight through to the backend.

Test plan

  • Run npm run test in frontend/ — all 142 tests should pass
  • Open the app, log in with valid credentials — should redirect to / instead of staying on /login?/login
  • Open the app, log in with invalid credentials — should show the error message on the login page
## Summary - **Fix Svelte 5 test failures**: Playwright locator `.click()` dispatches events via the CDP bridge which doesn't trigger Svelte 5's `$.delegated` event handlers. Replaced all affected locator clicks with native `element.click()` / `element.focus()` DOM calls. Also added missing `cleanup()` to `afterEach` in several spec files, and fixed `TagInput.svelte` to use `untrack()` when reading bindable state after an `await`. - **Fix login regression**: `handleFetch` was short-circuiting with `401` for any API request without an `auth_token` cookie — which blocked the login action itself, since it explicitly sends Basic auth credentials before a cookie exists. Fix: pass requests that already carry an `Authorization` header straight through to the backend. ## Test plan - [ ] Run `npm run test` in `frontend/` — all 142 tests should pass - [ ] Open the app, log in with valid credentials — should redirect to `/` instead of staying on `/login?/login` - [ ] Open the app, log in with invalid credentials — should show the error message on the login page
marcel changed target branch from feat/35-profile-page to main 2026-03-22 14:54:38 +01:00
marcel added 2 commits 2026-03-22 14:54:38 +01:00
Replace Playwright locator .click() calls with native DOM element.click()
for all tests that trigger Svelte 5 delegated onclick handlers ($.delegated).
Playwright's CDP-based synthetic events don't propagate through Svelte 5's
document-level handle_event_propagation delegation mechanism, while native
DOM .click() does.

Also replace locator.click() with element.focus() for onfocus handler tests,
and add cleanup() to afterEach in all spec files missing it to prevent test
pollution between runs. Fix TagInput.svelte to use untrack() when reading
bindable state after an await to avoid track_reactivity_loss errors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix(auth): pass through explicit Authorization header in handleFetch
Some checks failed
CI / Unit & Component Tests (pull_request) Successful in 2m9s
CI / Backend Unit Tests (pull_request) Successful in 2m2s
CI / E2E Tests (pull_request) Failing after 17m15s
CI / Unit & Component Tests (push) Successful in 2m4s
CI / Backend Unit Tests (push) Successful in 2m0s
CI / E2E Tests (push) Failing after 16m27s
9731afb776
The login action sends Basic auth via an explicit Authorization header.
handleFetch was intercepting this request and returning 401 because no
auth_token cookie exists yet (the user isn't logged in), never forwarding
the credentials to the backend.

Fix: if the outgoing request already has an Authorization header, pass it
through unchanged. Only inject the cookie-based token for requests that
don't provide their own auth.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marcel merged commit 9731afb776 into main 2026-03-22 14:56:14 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#46