test(app): broaden frontend coverage (batch 2) — hooks #45

Merged
rbrooks merged 1 commit from test/app-coverage-batch-2 into main 2026-06-25 22:44:15 +00:00
Owner

Batch 2 of frontend coverage — the three app hooks, which had zero tests. +16 tests.

What's covered

Hook Tests Focus
useAuth 4 loadingauthenticated on a 200 /auth/me; → unauthenticated on 401 and on unexpected (500) errors (the no-infinite-loop fallback).
useTheme 6 Default 'system', persisted read from localStorage, dark/light class + localStorage side effects, and 'system' resolving to the OS preference both ways (overriding the matchMedia polyfill).
useOfflineQueue 6 enqueue assigns id/queued_at and persists (verified by surviving a remount); sync POSTs queued entries with the right body and clears them on success; leaves items on a network failure or a non-ok response; auto-flushes on the window online event.

Notes

  • New dev dependency: fake-indexeddb (^6.0.0) — jsdom has no IndexedDB, and useOfflineQueue is built on it. Each test gets a fresh IDBFactory for isolation. This is the only production-adjacent change; no app code touched.
  • Verified on the dev server: full app suite green, no act() warnings.
  • Independent of batch 1 (#44) — different files; the only shared file is app/package.json, where batch 1 made no change, so no conflict.

Remaining coverage targets for a possible batch 3: higher-traffic pages (EntryListPage/EntryDetailPage) against a mocked api, and lib/useMetaTags.

🤖 Generated with Claude Code

Batch 2 of frontend coverage — the three app hooks, which had zero tests. **+16 tests.** ## What's covered | Hook | Tests | Focus | |---|---|---| | `useAuth` | 4 | `loading` → `authenticated` on a 200 `/auth/me`; → `unauthenticated` on 401 and on unexpected (500) errors (the no-infinite-loop fallback). | | `useTheme` | 6 | Default `'system'`, persisted read from `localStorage`, `dark`/`light` class + `localStorage` side effects, and `'system'` resolving to the OS preference **both** ways (overriding the `matchMedia` polyfill). | | `useOfflineQueue` | 6 | `enqueue` assigns `id`/`queued_at` and persists (verified by surviving a remount); `sync` POSTs queued entries with the right body and clears them on success; **leaves** items on a network failure or a non-ok response; auto-flushes on the `window` `online` event. | ## Notes - **New dev dependency: `fake-indexeddb`** (`^6.0.0`) — jsdom has no IndexedDB, and `useOfflineQueue` is built on it. Each test gets a fresh `IDBFactory` for isolation. This is the only production-adjacent change; no app code touched. - Verified on the dev server: full app suite green, **no `act()` warnings**. - Independent of batch 1 (#44) — different files; the only shared file is `app/package.json`, where batch 1 made no change, so no conflict. Remaining coverage targets for a possible batch 3: higher-traffic pages (`EntryListPage`/`EntryDetailPage`) against a mocked `api`, and `lib/useMetaTags`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
test(app): cover the hooks — useAuth, useTheme, useOfflineQueue
All checks were successful
CI / App — typecheck, test & build (push) Successful in 1m27s
CI / API — typecheck & tests (push) Successful in 2m28s
CI / App — typecheck, test & build (pull_request) Successful in 1m37s
CI / API — typecheck & tests (pull_request) Successful in 2m35s
e5169766c6
Batch 2 of frontend coverage. Adds 16 tests across the three hooks:

- useAuth: loading → authenticated on 200 /auth/me, → unauthenticated on
  401 and on unexpected (500) errors.
- useTheme: default 'system', persisted read, dark/light class + localStorage
  side effects, and 'system' resolving to the OS preference both ways.
- useOfflineQueue: enqueue assigns id/queued_at and persists (survives a
  remount), sync POSTs queued entries and clears them on success, leaves
  items on a network failure or a non-ok response, and auto-flushes on the
  window 'online' event.

Adds fake-indexeddb (dev dep) since jsdom has no IndexedDB. Verified on the
dev server: full app suite green, no act() warnings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
rbrooks scheduled this pull request to auto merge when all checks succeed 2026-06-25 22:42:39 +00:00
rbrooks deleted branch test/app-coverage-batch-2 2026-06-25 22:44:16 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rbrooks/TeaLeaves!45
No description provided.