test: core-logic unit tests + coverage tooling (46% -> 54%)#1245
Conversation
Adds @vitest/coverage-v8, a `test:coverage` script, and coverage config, then 273 unit tests across the most under-covered core modules — each goes from 0-43% to 88-100% statement coverage: - services/choiceService 0 -> 99% - utils/packageTraversal 0 -> 98% - services/packageExportService 0 -> 98% - services/packageImportService 0 -> 95% - formatters/completeFormatter 43 -> 88% - ai/OpenAIRequest 3 -> 100% - quickAddApi 35 -> 93% Overall statements 45.86% -> 54.14%. The tests surfaced an incorrect type on the public `suggester` API: the displayItems mapper was declared `(value, index?, arr?) => string[]`, but it is applied per-item via `actualItems.map(...)` and must return a single `string` (the old type rejected correct user-script callbacks). Fixed both signatures — type-only, no runtime change. Other suspected bugs found while writing the tests are filed as a separate issue and deliberately NOT locked into the tests (the suite asserts correct behavior).
Deploying quickadd with
|
| Latest commit: |
e220d0c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://bf541b40.quickadd.pages.dev |
| Branch Preview URL: | https://test-core-coverage.quickadd.pages.dev |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThis PR adds comprehensive test coverage across the QuickAdd codebase using Vitest: coverage infrastructure (gitignore, npm script, config), a minor refinement to the ChangesTest Coverage & API Refinement
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Builds out the runtime-behavior safety net for the core logic (we had 1126 tests but zero coverage visibility).
Coverage tooling
@vitest/coverage-v8+ atest:coveragescript + config (coverage/gitignored). Baseline was 45.86% statements.273 new tests across the most under-covered core modules
Overall statement coverage 45.86% → 54.14%. All tests self-contained (mock Obsidian via
vi.mock/ fakes; deterministic), and they assert correct behavior — where the code looked wrong, the behavior was not locked in.One type fix (surfaced by the tests)
The public
suggesterAPI declared itsdisplayItemsmapper as(value, index?, arr?) => string[], but it's applied per-item viaactualItems.map(...)and must return a singlestring. The old type would reject a correct=> stringuser-script callback. Fixed both signatures — type-only, no runtime change.Suspected bugs
The tests surfaced 6 suspected bugs (1 medium, 5 low) — filed as a follow-up issue, not encoded into the tests. The notable one:
quickAddApi.executeChoicelogs an error for an unknown choice but then still callsexecute(undefined)instead of returning early.Verification
bun run test(1399 pass),bun run build-with-lintclean (tsc + eslint + esbuild),bun run check(svelte-check) clean.Summary by CodeRabbit
Release Notes
New Features
suggesterAPI to accept display items as a function returning a single string per item, in addition to arrays of strings.Tests
Chores