Skip to content

Conversation

erikhfj
Copy link
Member

@erikhfj erikhfj commented Sep 7, 2026

Summary

Implements the data hook + App integration from #12 (issue stays open until navigation and jump list are wired in — per review agreement):

  • useBooks(subject): TanStack useQuery keyed ['books', subject] over searchBooksBySubject; exposes books / isLoading / isError
  • App: hardcoded fantasy subject (becomes the persisted choice in M3), loading state (role=status), error state (role=alert), empty state, BookCard in a labeled book viewer region
  • Test infrastructure: msw server + OpenLibrary handlers with a request counter, QueryClient test providers, and global onUnhandledRequest: error — tests physically cannot touch the network

Test evidence

  • Hook: caching test — rerender with the same subject keeps the request count at 1 (no unnecessary API calls); subject change triggers exactly one more
  • App: loading → first book → error (500) → empty — all four states, network always mocked
  • App snapshot updated deliberately (vitest -u)

Checklist

  • npm run lint — 0 warnings
  • npm test — 14 passed
  • npm run build — passes
  • npm run format:check — passes

AI-assisted: implementation generated with AI assistance, reviewed and verified.

- src/hooks/useBooks.ts: TanStack Query useQuery keyed ['books', subject]
  over searchBooksBySubject, exposing books/isLoading/isError
- App: hardcoded fantasy subject (replaced by persisted choice in M3),
  loading (role=status), error (role=alert) and empty states, BookCard
  wired into a book viewer region
- test infra: msw server + OpenLibrary handlers (request counter for
  cache assertions), QueryClient test providers, global onUnhandledRequest
  error so tests never touch the network
- tests: hook caching (fetch count stays 1 across re-renders), App
  loading/error/empty/first-book, App snapshot updated deliberately (-u)

Navigation and jump-list wiring lands in this PR as #13/#14 merge.

Closes #12
@erikhfj erikhfj requested a review from a team as a code owner September 7, 2026 00:51
@erikhfj erikhfj added this to the M2 — Core app milestone Sep 7, 2026
@erikhfj erikhfj added type: feature New functionality or requirement area: api OpenLibrary REST API and TanStack Query priority: high Required for first delivery ai-assisted Substantial AI-generated code (documented per spec) status: in-review PR is open and awaiting review labels Sep 7, 2026
@erikhfj erikhfj requested review from evenkkl and rachelks September 7, 2026 00:51
Copy link
Member

@robertky robertky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. One question before merging: this PR closes #12, but #12 also includes wiring NavigationControls and BookJumpList into App.

Since #13 and #14 are still being worked on, should we keep #12 open until that integration is complete, or move the integration to a separate issue? Otherwise, the issue may close before all its tasks are finished.

Copy link
Member

@robertky robertky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Data loading, error handling, and the test setup are well covered.

@robertky robertky merged commit 6644861 into main Sep 8, 2026
1 check passed
Sign in to join this conversation on GitHub.
Labels
ai-assisted Substantial AI-generated code (documented per spec) area: api OpenLibrary REST API and TanStack Query priority: high Required for first delivery status: in-review PR is open and awaiting review type: feature New functionality or requirement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants