test(enrich): E2E coverage for WhoWhenSection autofocus and upload cancel flow #268

Open
opened 2026-04-18 14:53:41 +02:00 by marcel · 0 comments
Owner

Background

Deferred during PR #267 review cycle 3 (Sara Holt's concerns).

Concern

Three behaviors in the enrich page upload/field flow have no automated test coverage:

  1. WhoWhenSection autofocus conditional logicautofocus={!initialDateIso} on date input, autofocus={!!initialDateIso} on sender input. The unit test approach (checking autofocus attribute or document.activeElement in vitest-browser) proved unreliable because PersonTypeahead's internal initialization interferes with focus state in the test environment. Requires E2E testing where the full page renders in isolation.

  2. Upload cancel flowcancelUpload() calls abortController?.abort() and resets isUploading. The AbortError guard in handleFile (if ((e as Error).name === 'AbortError') return;) is untested. This logic lives in +page.svelte and cannot easily be unit-tested in isolation.

  3. handleReplaceFile — extracts a file from the change event and delegates to handleFile. The "Datei ersetzen" path is untested at unit level; requires E2E or integration testing against the full page.

Why deferred

All three require either:

  • A full-page E2E test (Playwright + Docker Compose stack) that renders the enrich page with a real document
  • Or extraction of the upload state machine into a testable hook

Both are architectural decisions that are out of scope for this PR.

Reference

PR: http://heim-nas:3005/marcel/familienarchiv/pulls/267

## Background Deferred during PR #267 review cycle 3 (Sara Holt's concerns). ## Concern Three behaviors in the enrich page upload/field flow have no automated test coverage: 1. **WhoWhenSection autofocus conditional logic** — `autofocus={!initialDateIso}` on date input, `autofocus={!!initialDateIso}` on sender input. The unit test approach (checking `autofocus` attribute or `document.activeElement` in vitest-browser) proved unreliable because PersonTypeahead's internal initialization interferes with focus state in the test environment. Requires E2E testing where the full page renders in isolation. 2. **Upload cancel flow** — `cancelUpload()` calls `abortController?.abort()` and resets `isUploading`. The `AbortError` guard in `handleFile` (`if ((e as Error).name === 'AbortError') return;`) is untested. This logic lives in `+page.svelte` and cannot easily be unit-tested in isolation. 3. **`handleReplaceFile`** — extracts a file from the change event and delegates to `handleFile`. The "Datei ersetzen" path is untested at unit level; requires E2E or integration testing against the full page. ## Why deferred All three require either: - A full-page E2E test (Playwright + Docker Compose stack) that renders the enrich page with a real document - Or extraction of the upload state machine into a testable hook Both are architectural decisions that are out of scope for this PR. ## Reference PR: http://heim-nas:3005/marcel/familienarchiv/pulls/267
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#268