testsAndMisc/docs/superpowers/evidence/kcd2-test-split-2026-08-16.json
Krzysztof kuhy Rudnicki 776e04db89 Split the kcd2_dice_solver test files under the cap
Nine new modules from four over-cap test files. Every kcd2 test file is
now under 250 lines; only four source files remain.

App.test.tsx ended up with no describe blocks and vitest failed with
"No test suite found" - a split that empties a file has to delete it.
The shared `response`/`ordinary` fixtures went to src/test/fixtures.ts,
which vite.config.ts excludes from coverage; beside the source they
would have counted as production code and broken the 100% gate.

288 tests passing before and after, now across 24 files instead of 15,
coverage still 100% on all four metrics.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 20:03:33 +02:00

47 lines
3.1 KiB
JSON

{
"intent": "Clear every over-cap kcd2_dice_solver test file by partitioning at describe boundaries.",
"scope": [
"components.test.tsx (532) -> componentRows, componentPickers, componentResult, componentInventory",
"App.test.tsx (512) -> AppShell, AppLinks, AppRecovery, AppStorage; the original shell was deleted",
"inventoryIo.test.ts (302) -> inventoryHash.test.ts",
"simulate.test.ts (272) -> simulateTurns.test.ts",
"src/test/fixtures.ts (new, coverage-excluded by path)",
"Non-goal: no assertion changed, no test deleted or skipped"
],
"changes": [
"Nine new test modules, each carrying the original preamble so imports and local helpers resolve; the unused ones were then pruned by tsc's own TS6133/TS6192 output driving an iterative cleanup, rather than guessed.",
"App.test.tsx ended up with no describe blocks at all and vitest failed the run with 'No test suite found in file'. The empty shell was deleted - a split that empties a file has to remove it, not leave it.",
"The `response` and `ordinary` fixtures were used by two halves of the component split, so they moved to src/test/fixtures.ts. That directory is in vite.config.ts's coverage exclude list; putting a fixture beside the source would have counted it as production code and broken the 100% gate - the same trap recorded for poker-stakes."
],
"verification": [
{
"command": "npm test -- --run",
"result": "fail twice, then pass",
"evidence": "288 passed across 24 files, identical to the 288 in 15 files before. The two failures were real: the empty App.test.tsx, and 7 tests failing with 'Cannot find name response' when a shared fixture stayed behind in one half."
},
{
"command": "npm run coverage",
"result": "pass",
"evidence": "100% statements (863/863), branches (375/375), functions (181/181), lines (810/810) - unchanged, confirming src/test/fixtures.ts is excluded rather than counted."
},
{
"command": "npm run lint",
"result": "pass",
"evidence": "tsc --noEmit and eslint clean, with no eslint-disable added. Roughly 40 imports and several orphaned local helpers were removed across the new files."
},
{
"command": "bash ~/utils/scripts/check_file_length.sh --all | grep kcd2",
"result": "pass",
"evidence": "Four entries remain, all source files: search.ts, scoring.ts, badgeValue.ts and App.tsx. Every test file is under the cap."
}
],
"risks": [
"Carrying the whole preamble into each new file then pruning by compiler output is reliable for imports but not for local helpers: tsc only flags a helper as unused, it cannot tell you the other half needed it. The `response` fixture was caught by the test run, not the compiler.",
"24 test files where there were 15 means more preamble duplication. The shared fixtures module offsets some of it, but each file still repeats its render helpers."
],
"rollback": [
"git revert the commit; the four originals return and the nine new modules plus src/test/fixtures.ts disappear.",
"After rollback, re-run npm test and expect 288 passed in 15 files."
]
}