More unit tests: OpenAI wiki flows, useBooks, image content stores#21
Merged
Conversation
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]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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%.
src/lib/openai.tssrc/composables/useBooks.tssrc/lib/imageContentStore.tssrc/composables/usePartImages.tssrc/composables/useWikiImages.tssrc/composables/useChapterImages.tsOpenAI (
openai.spec.ts, extended)generateWikiContent(create/update prompts, no-content + error fallbacks) andupdateWikiPagesFromChapter(create/update-with-contradictions/no-change/continue-on-error) via injected wiki DB functions.useBooks.spec.tscreateBooknormalization + re-exposed state (mockeduseDatabase).imageContentStoreClasses.spec.tsThe two
ImageContentStoreimplementations —IndexedDbImageContentStore(read validation/size-check branches, write/delete/exists/listStoredIds) andElectronImageContentStore(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
canStoreImageswatcher.useWikiImages/useChapterImagesalso cover hero/cover selection, set-as-cover;useChapterImagesadditionally covers add-illustrations and the delete flow (incl. cover-clear). All mockuseImageLibrary+useDatabase; no new dependencies.Testing
npm run lint,npm run type-check, andvitest runall 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.vueviews.🤖 Generated with Claude Code