Skip to content

Golden tests for the pure logic - #8

Open
tomeyer97 wants to merge 1 commit into
mainfrom
test/goldens
Open

tomeyer97 wants to merge 1 commit into
mainfrom
test/goldens

Conversation

@tomeyer97

@tomeyer97 tomeyer97 commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

A byte-for-byte regression net for the pure logic, to land before a big refactor: a refactor should leave test/goldens/ untouched.

What is pinned

98 golden files from 32 golden tests (test/golden-*.test.ts, test/cli/golden-understanding.test.mjs):

  • journey/ (38): every fixture journey as parseJourney reads it, old-format files it refuses, 23 crafted rule breaks (the refusal or the problems), anchors / code links / value hints / marks as read, marks found in code and their problems, code-link markup, paths in step text, each step card's text (as written, moved, stale, renamed and gone files), the shop journey's steps placed in its code after edits, search words and scores, the Journeys list model (sorts, searches, chips, the active file), the map layout's pure parts (media/journey-layout.js).
  • podcast/ (6): the full check of all 44 cases in cases.json (problems, messages, paths, places in the file, the episode), the sample episode the panel is sent, its timing (views, chapters, jumps, calm views, resume), marks.
  • notes/ (36): 13 real note files read and written back (the JSON the extension writes), crafted and refused notes, the three-way merge, the agents' README, v2 and compact v3 anchors found again after edits, the stale diff.
  • check/ (13) and check-model/ (5): the understanding check end to end on the refunds change of test/fixtures/grader-cases (the skill's script output and the check file, every CLI command's output and status --json, the Check view at each stage, each question's thread, grading replies and refused ones, the CI job and its MR comment), broken check files and what validate says, drift / conflicts / the default branch, the prompts, failures in plain words, TODO comments, the view's names and requests.

Not pinned (built inside vscode-dependent classes): the panel's tour/journey message (mapState), the step card, the podcast player's messages, layout() (measures the DOM); their pure payloads are pinned. The quiz is not on main, so it has no goldens.

How

test/golden.ts: expectGolden(area, name, value) writes a string as is (.txt), anything else as JSON.stringify(v, null, 2) in its real key order, with undefined, Maps, Sets and NaN spelled out. Missing or different fails with a diff. The CLI goldens replace temporary paths, ISO times and commit ids with stable names; the journey goldens run in UTC. .gitattributes keeps test/goldens/ out of line-ending conversion.

  • npm run test:goldens: the goldens alone (about 3 s of tests after tsc).
  • npm test includes them (they are out/test/*.test.js and test/cli/*.test.mjs, counted once): 365 → 397 tests.
  • Update an intended change: UPDATE_GOLDENS=1 npm run test:goldens, then review git diff test/goldens. Details in test/README.md.

Deterministic: three runs in a row, and under TZ=Pacific/Auckland LANG=C LC_ALL=C and TZ=America/Los_Angeles LANG=de_DE.UTF-8, all green with no file changed. No production code changed.

Negative controls

Three breaks planted in a scratch copy (not committed), each run with npm run test:goldens:

Break Caught by Existing tests
Journey validation message has no file → has no file name (src/journeyModel.ts) journey/parse.invalid.json not caught
Grading result off by one: passed >= need → passed > need (cli/understanding/state.mjs) check/states.json 8 tests fail
Check view message field renamed mr → mrUrl in checkView only (type unchanged, so tsc passes; the page still reads mr) check/refunds.stage.committed.json not caught

Pin what the pure code returns today, byte for byte, as a regression net
before refactoring: test/golden.ts (expectGolden; UPDATE_GOLDENS=1 writes)
and 98 golden files in test/goldens/ from 32 golden tests:

- journey: parsing (fixtures and crafted rule breaks), anchors, code links,
  value hints, marks, step card text, steps placed after edits, search,
  the Journeys list model, the map layout's pure parts
- podcast: the full check of every case, the sample episode, timing, marks
- notes: note files read and written back, refusals, the merge, v2 and
  compact anchors after edits
- check: the understanding check end to end on the refunds fixture (the
  skill's script, CLI output and JSON, the Check view at each stage,
  threads, grading, CI), broken check files, prompts and failures

npm run test:goldens runs them alone; npm test includes them.
test/README.md says what is pinned, how to update and review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant