test: add Vitest and unit tests for the mosaic domain model #7

Merged
deiussum merged 1 commit from add-vitest-domain-model-tests into develop 2026-09-19 08:39:47 -05:00
Owner

Summary

  • No test framework was configured at all — adds Vitest with an npm test script
  • Standalone vitest.config.ts (node environment), kept separate from vite.config.ts since that config is tuned for the Tauri/browser build and not needed for Node-only unit tests
  • src/Mosaic.test.ts — 14 tests covering every requirement in openspec/specs/mosaic-domain-model/spec.md: row/column numbering, alternating-color/locked-edge construction, cell-toggle validity, written-pattern text formatting, and save/load round-tripping
  • Includes the archived OpenSpec change (openspec/changes/archive/2026-09-19-add-vitest-domain-model-tests/) with proposal, design, and tasks — skip_specs: true since this is tooling, not an app-behavior change

Notable finding while implementing

The initial design assumed non-toggle tests could construct new MosaicChart(...) directly. That's not possible — MosaicChart/MosaicRow/MosaicCell aren't exported at all — so every test drives the domain model through mosaic.initialize(...) and mosaic.data instead. Corrected in the change's design.md before writing tests.

Out of scope (deferred)

  • React component tests
  • dialogs-bridge.ts tests (would need Tauri/Jimp/pdfkit mocking)
  • CI wiring to run tests automatically

Test plan

  • npm test — 14/14 passing
  • npm run lint — 0 errors, including the new files
  • npx tsc --noEmit — clean
  • npx vite build — still succeeds

🤖 Generated with Claude Code

https://claude.ai/code/session_01KoLHnQugaAW2eknKo8FxVp

## Summary - No test framework was configured at all — adds Vitest with an `npm test` script - Standalone `vitest.config.ts` (node environment), kept separate from `vite.config.ts` since that config is tuned for the Tauri/browser build and not needed for Node-only unit tests - `src/Mosaic.test.ts` — 14 tests covering every requirement in `openspec/specs/mosaic-domain-model/spec.md`: row/column numbering, alternating-color/locked-edge construction, cell-toggle validity, written-pattern text formatting, and save/load round-tripping - Includes the archived OpenSpec change (`openspec/changes/archive/2026-09-19-add-vitest-domain-model-tests/`) with proposal, design, and tasks — `skip_specs: true` since this is tooling, not an app-behavior change ## Notable finding while implementing The initial design assumed non-toggle tests could construct `new MosaicChart(...)` directly. That's not possible — `MosaicChart`/`MosaicRow`/`MosaicCell` aren't exported at all — so every test drives the domain model through `mosaic.initialize(...)` and `mosaic.data` instead. Corrected in the change's `design.md` before writing tests. ## Out of scope (deferred) - React component tests - `dialogs-bridge.ts` tests (would need Tauri/Jimp/pdfkit mocking) - CI wiring to run tests automatically ## Test plan - [x] `npm test` — 14/14 passing - [x] `npm run lint` — 0 errors, including the new files - [x] `npx tsc --noEmit` — clean - [x] `npx vite build` — still succeeds 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KoLHnQugaAW2eknKo8FxVp
There was no test framework configured at all. Adds Vitest (standalone
vitest.config.ts, decoupled from the Tauri-oriented vite.config.ts) and
an npm test script, plus unit tests for src/Mosaic.ts covering every
requirement in openspec/specs/mosaic-domain-model/spec.md: numbering,
alternating-color/locked-edge construction, toggle validity, written-
pattern formatting, and save/load round-tripping.

Implementation surfaced a real design correction: MosaicChart/Row/Cell
aren't exported at all, so every test (not just toggle-rule tests) has
to go through mosaic.initialize(...) and mosaic.data rather than
constructing a chart directly - documented in the change's design.md.

React component tests, dialogs-bridge.ts tests, and CI wiring are
deliberately out of scope for this change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KoLHnQugaAW2eknKo8FxVp
deiussum merged commit 550fa9a1f2 into develop 2026-09-19 08:39:47 -05:00
deiussum deleted branch add-vitest-domain-model-tests 2026-09-19 08:39:47 -05:00
Sign in to join this conversation.
No reviewers
No labels
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
deiussum/tesserow-backup!7
No description provided.