mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 12:47:47 +01:00
Eleven tests split by theme: the five that assert the loop declines to start or tears down cleanly stay put; the six that actually play the game move to usePuzzleGameLoopPlay.test.ts. Fixtures went to src/test/puzzleLoopFixtures.ts (62) -- that path is required, not stylistic, since coverage excludes src/test/** and a fixture beside the hook would be counted as production code and break the 100% gate. flushTick could not move as-is: it closed over the describe block's rafCallbacks. It is now installRafHarness(), which owns the queue and hands back a bound flushTick, so the two suites cannot leak frames into each other. The check that matters for a test split is the pair (15 files, 145 tests): file count up by one, test count unchanged. A name outside vitest's glob would have passed just as green with six tests never running. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
58 lines
4.4 KiB
JSON
58 lines
4.4 KiB
JSON
{
|
|
"intent": "Bring bucket_catch/packages/frontend/src/hooks/usePuzzleGameLoop.test.ts (332 lines) under the repo-wide 250-line cap without losing or weakening a single test.",
|
|
"scope": [
|
|
"bucket_catch/packages/frontend/src/hooks/usePuzzleGameLoop.test.ts — reduced to the five lifecycle and guard tests",
|
|
"bucket_catch/packages/frontend/src/hooks/usePuzzleGameLoopPlay.test.ts — new: the six gameplay, flash, rendering and clustering tests",
|
|
"bucket_catch/packages/frontend/src/test/puzzleLoopFixtures.ts — new: makeRef, makePiece, makeCanvas, flushPromises, installRafHarness",
|
|
"Non-goal: adding, deleting or rewriting any test; every assertion is carried across verbatim",
|
|
"Non-goal: the 45 pre-existing eslint errors in this package"
|
|
],
|
|
"changes": [
|
|
"Split the 11 tests by theme: the five that assert the loop declines to start or tears down cleanly stayed in usePuzzleGameLoop.test.ts; the six that play the game — catching, missing, the catch flash, drawImage, and the two assignXPositions clustering branches — moved to usePuzzleGameLoopPlay.test.ts.",
|
|
"Moved the shared fixtures to src/test/puzzleLoopFixtures.ts. That path is required rather than stylistic: the coverage config excludes src/test/**, so a fixture placed beside the hook would be counted as production code and break the 100% gate.",
|
|
"flushTick could not move as-is because it closed over the describe block's rafCallbacks array. Replaced it with installRafHarness(), which owns the queue and returns a flushTick bound to it, so each of the two suites gets an isolated set of callbacks instead of sharing module state — a shared array would have let one suite's pending frames leak into the other.",
|
|
"Test bodies are otherwise byte-identical, including the comments that record the arithmetic behind each seeded Math.random sequence."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "npm run coverage",
|
|
"result": "pass",
|
|
"evidence": "Test Files 15 passed (15) and Tests 145 passed (145). This pair is the discriminating check for a test-file split: the file count rose by exactly one while the test count held at 145, which proves the six moved tests are actually being collected. Had the new filename fallen outside vitest's test glob, the suite would still have passed — with six tests silently never run."
|
|
},
|
|
{
|
|
"command": "npm run coverage (thresholds)",
|
|
"result": "pass",
|
|
"evidence": "Statements 100% (584/584), Branches 100% (217/217), Functions 100% (98/98), Lines 100% (535/535) — identical to the totals after the source split. Unchanged coverage from an unchanged test count is the second half of the proof: if a moved test had stopped running, the branches it alone covers would have dropped below the enforced 100%."
|
|
},
|
|
{
|
|
"command": "npm run build (tsc -b && vite build)",
|
|
"result": "pass",
|
|
"evidence": "Exit 0."
|
|
},
|
|
{
|
|
"command": "npx eslint src, compared against the pre-split count",
|
|
"result": "fail",
|
|
"evidence": "45 errors, the same 45 as before this split and before the source split. The extraction introduced no new violation. These are pre-existing and out of scope, as recorded in the baseline commit."
|
|
},
|
|
{
|
|
"command": "wc -l on the three files",
|
|
"result": "pass",
|
|
"evidence": "usePuzzleGameLoop.test.ts 125, usePuzzleGameLoopPlay.test.ts 210, puzzleLoopFixtures.ts 62 — all three under the 250-line cap, down from a single 332-line file."
|
|
},
|
|
{
|
|
"command": "pre-commit run --files <changed files>",
|
|
"result": "pass",
|
|
"evidence": "All configured hooks pass on the three touched files."
|
|
}
|
|
],
|
|
"risks": [
|
|
"The two suites now install the RAF harness independently. That is stricter isolation than before, not weaker, but it does mean a future fixture change has to keep both suites in mind.",
|
|
"usePuzzleGameLoopPlay.test.ts at 210 lines has the least headroom of the three; adding two or three more gameplay tests would push it back over the cap and require a further split.",
|
|
"This package has no CI and is not covered by pre-commit, so the local coverage, build and eslint runs above are the only gate."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit — one edited file and two added files, with no data, config or schema migration.",
|
|
"After rollback, re-run npm run coverage; expect 14 test files and 145 tests passing at 100% coverage."
|
|
]
|
|
}
|