docs: say component tests are allowed, not absent by rule

CLAUDE.md read as a prohibition — "Vitest for its own pure helpers only, no
React, no DOM". It was only ever a description of what was installed, and it
was talking future contributors out of a test they are allowed to write.

Tests now states what exists, that component tests are allowed, and what the
first one costs: jsdom or happy-dom, @testing-library/react v16+ for React 19,
environment and a *.spec.tsx include. Notes that babel-plugin-react-compiler is
in devDependencies but not enabled in next.config.ts, so there is no transform
mismatch to work around.

Adds which to reach for. A decision belongs in a pure test, extracted into
components/{feature}/. A defect only a real render shows — ref-versus-state
timing, effect ordering — belongs in a component test, because no pure test can
see it. VoiceReviewSheet is the cheap first one; TreatmentWorkspace needs six
axios mocks and earns its keep only for a bug that needs it.

Same correction in vitest.config.ts's docblock and the spec's §12 line, which
each carried their own copy of "no React, no DOM".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-11 19:57:45 +08:00
parent 2c3e28ac79
commit c57abbe895
3 changed files with 21 additions and 8 deletions

View File

@@ -1062,10 +1062,12 @@ enabling this for real clinics.
- `cd backend && npm run prisma:migrate && npm run prisma:seed` — the new `CatalogEntityKind`
values and their translation rows. The seed never wipes, so re-running it is safe.
- `cd frontend && npx vitest run`**new**. One dev dependency, one config, one script,
covering the pure helpers only: `prosthesisTree.ts` (stack legality, `applyLeafToJobs`
precedence, `toothRegionColors`) and `voiceReviewRows.ts` (row availability, the merged
row, folding chips into the result). No React, no DOM. `CLAUDE.md` is updated in the same
commit — "there are no frontend tests" stops being true.
covering `prosthesisTree.ts` (stack legality, `applyLeafToJobs` precedence,
`toothRegionColors`), `voiceReviewRows.ts` (row availability, the merged row, folding chips
into the result), `toothSelectionGroups.ts` and `voiceApply.ts` (the apply decision).
Pure functions, so no DOM environment is configured — a limit of what exists, not a rule
against component tests; `CLAUDE.md` > Tests says what adding one costs. `CLAUDE.md` is
updated in the same commit — "there are no frontend tests" stops being true.
- `cd frontend && npx tsc --noEmit` — frontend type gate.
- `cd frontend && npm run build` — production build.
- ESLint on every touched file, no new warnings.