Skip to content

More unit tests: OpenAI wiki flows, useBooks, image content stores#21

Merged
catherineluse merged 9 commits into
mainfrom
more-tests-2
Jul 16, 2026
Merged

More unit tests: OpenAI wiki flows, useBooks, image content stores#21
catherineluse merged 9 commits into
mainfrom
more-tests-2

Conversation

@catherineluse

@catherineluse catherineluse commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Continues the coverage work. Adds 65 tests across 6 files, bringing seven more modules to full or near-full coverage. Overall line coverage rises from ~18% to ~24%.

Module Before After
src/lib/openai.ts ~70% 100%
src/composables/useBooks.ts 0% 100%
src/lib/imageContentStore.ts ~47% 100%
src/composables/usePartImages.ts 0% ~93%
src/composables/useWikiImages.ts 0% ~90%
src/composables/useChapterImages.ts 0% ~88%

OpenAI (openai.spec.ts, extended)

generateWikiContent (create/update prompts, no-content + error fallbacks) and updateWikiPagesFromChapter (create/update-with-contradictions/no-change/continue-on-error) via injected wiki DB functions.

useBooks.spec.ts

createBook normalization + re-exposed state (mocked useDatabase).

imageContentStoreClasses.spec.ts

The two ImageContentStore implementations — IndexedDbImageContentStore (read validation/size-check branches, write/delete/exists/listStoredIds) and ElectronImageContentStore (bridge read/write/delete, missing-path, error paths).

Image composables (usePartImages, useWikiImages, useChapterImages)

Each covers refresh (empty/loaded/error), lightbox open/close, computed active-image state, prev/next navigation, saving notes/tags, download, and the canStoreImages watcher. useWikiImages/useChapterImages also cover hero/cover selection, set-as-cover; useChapterImages additionally covers add-illustrations and the delete flow (incl. cover-clear). All mock useImageLibrary + useDatabase; no new dependencies.

Testing

npm run lint, npm run type-check, and vitest run all pass (Node 22). Full suite: 223 tests across 29 files.

Remaining large untested surfaces (for later)

cloudSync.ts, useDatabase.ts, googleOAuth.ts (native flow), and the .vue views.

🤖 Generated with Claude Code

gennitdev and others added 3 commits July 15, 2026 21:50
Extends openai.spec.ts with generateWikiContent (create vs. update
prompts, no-content and error fallbacks) and updateWikiPagesFromChapter
(create-new, update-with-changes, no-change mention-only, and the
continue-on-error path) using injected wiki DB functions. openai.ts
reaches 100% line coverage.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Mocks useDatabase and verifies the re-exposed state/loaders and that
createBook persists a normalized book (empty chapter/part order, null
cover, ISO created_at) and returns it with chapterCount 0. useBooks.ts
reaches 100% coverage.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Complements the existing imageContentStore conversion tests by covering
the two ImageContentStore implementations:
- IndexedDbImageContentStore: null/legacy-Blob/structured-record reads,
  the not-a-Blob and size-check failures, write record shape, delete,
  exists, and string-only listStoredIds (mocked indexedDbStorage)
- ElectronImageContentStore: bridge read/write/delete, the missing
  file-path paths, and exists-false on a bridge error

imageContentStore.ts reaches 100% line coverage.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-beta-reader-frontend Ready Ready Preview, Comment Jul 16, 2026 5:31am

Request Review

gennitdev and others added 3 commits July 15, 2026 22:01
Mocks useImageLibrary and useDatabase (jsdom env) and covers
refreshPartImages (empty/loaded/error), the lightbox open/close for
internal and external images, computed active-image state, prev/next
navigation, saving notes and tags (success + error), the download-link
flow, and the canStoreImages watcher. usePartImages.ts reaches ~93%
line coverage.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Covers refreshWikiImages (empty/loaded/error), hero-image selection
(cover preference + first-image fallback), openHeroLightbox, set-as-cover
(success + error), navigation, saving notes/tags, download, and the
canStoreImages watcher. useWikiImages.ts reaches ~90% line coverage.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Covers refreshChapterImages (empty/loaded/error), handleAddIllustrations
(prepend/no-op/error), the delete flow (request/cancel/delete incl.
cover-clear and error), set-as-cover, modal open/close + navigation,
saving notes/tags, and download + hero lightbox. useChapterImages.ts
reaches ~88% line coverage.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

gennitdev and others added 3 commits July 15, 2026 22:24
Adds tests for the console.warn catch paths (failed source/tag/wiki-page
loads during refresh), save-notes/tags/cover error branches, external
image save+download flows (usePartImages), active-image computed reads,
delete-active-image lightbox close, and the no-active-image no-ops. Also
restores spies between tests (afterEach) to prevent document.createElement
spy stacking.

usePartImages ~98%, useWikiImages 100%, useChapterImages ~97%.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
useChapterSummaryContext: buildPriorChapterSummariesInBook, part-number
mapping, cache clearing/reuse, book-order and created_at ordering
fallbacks, and malformed-id-array handling (now 100%).

usePartSummaryContext: partNumber/chapterTitleMap computeds, reset and
error paths, created_at ordering for unordered chapters, and
parseJsonArray edge cases (now ~99%).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
- platform: the Capacitor-throws path of isDesktopAppRuntime (100%)
- exportHelpers: single-file book export with part headings +
  uncategorized section, and parseJsonArray edge cases (100%)
- browserStorage: remaining browserStorageError name branches, the
  persist-throws path, large/Infinity byte formatting, and the snapshot
  error path (~96%; the IndexedDB success path needs a real IDB)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@catherineluse
catherineluse merged commit eb044b5 into main Jul 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants