test: add auto-focus test for Briefwechsel hero typeahead #189

Open
opened 2026-04-07 09:06:58 +02:00 by marcel · 0 comments
Owner

Context

The CorrespondenzHero component auto-focuses the PersonTypeahead input on mount via onMount + tick() + element.focus(). This is a key UX requirement from #179 (users shouldn't have to click).

Currently there's no automated test for this behaviour — it was deferred during PR #186 because document.activeElement assertions are unreliable in headless Playwright with vitest-browser-svelte.

Proposed change

Investigate whether a reliable focus test can be written, e.g.:

  • await expect(document.activeElement?.id).toBe('senderId-search') after render
  • Or a Playwright E2E test that checks focus state after navigation to /briefwechsel

If it remains flaky, document the manual verification step in the test file as a comment.

Origin

Flagged by @saraholt during PR #186 review.

## Context The `CorrespondenzHero` component auto-focuses the PersonTypeahead input on mount via `onMount` + `tick()` + `element.focus()`. This is a key UX requirement from #179 (users shouldn't have to click). Currently there's no automated test for this behaviour — it was deferred during PR #186 because `document.activeElement` assertions are unreliable in headless Playwright with `vitest-browser-svelte`. ## Proposed change Investigate whether a reliable focus test can be written, e.g.: - `await expect(document.activeElement?.id).toBe('senderId-search')` after render - Or a Playwright E2E test that checks focus state after navigation to `/briefwechsel` If it remains flaky, document the manual verification step in the test file as a comment. ## Origin Flagged by @saraholt during PR #186 review.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#189