Branch: ai/golden-file-rollout
Depends on: step-04 (candy-testing exists), step-15/16/17/18 (candy-forms / sugar-prompt / sugar-charts / sugar-table use candy-testing for some tests already)
Blocks: —
Roll out candy-testing's assertGoldenAnsi helpers across all rendering libs that the analysis flagged: candy-forms, sugar-prompt, sugar-bits, sugar-charts, sugar-table, sugar-glow, candy-vt, candy-vcr, candy-shine. Replaces ad-hoc string comparisons and brings every lib into the "snapshot tests for ANSI output" pattern. This is the #1 ecosystem-wide weakness called out in the analysis.
Reference: §19, §149 (zero ANSI byte assertions cited as the most common weakness across 8+ libs).
- Each of the 9 lib's composer.json — add
sugarcraft/candy-testing(dev) viapath-repo-closure. - Each lib's
tests/— convert existing tests that build string-equal assertions intoAssertions::assertGoldenAnsi(...); add NEW golden-file tests for view() output on representative scenarios. tests/fixtures/in each lib — golden files added.
- Each of the 9 libs has at least one
assertGoldenAnsitest for a representative renderer (text input, table render, chart, markdown, etc.). - Existing tests preserved; new golden tests are additive.
-
UPDATE_GOLDENS=1 vendor/bin/phpunitregenerates fixture files (tested in at least one lib end-to-end). - Coverage on rendering paths increases measurably (track per-lib coverage delta).
-
git statusclean on master.
- path-repo closure: candy-testing (dev-only require) in each of the 9 libs.
- For each lib: identify the most exercised render() method; build a representative input fixture; capture the output via
UPDATE_GOLDENS=1once; commit the .golden file; the test asserts against it on subsequent runs. - Convert ad-hoc string-equality tests: where a test currently does
$this->assertSame($expected, $rendered)with a literal string, swap toAssertions::assertGoldenAnsi('fixtures/foo.golden', $rendered). Drop the inline expected string into the fixture file. - DO NOT delete any existing tests — only convert or add.
- Run phpunit in each lib + spot-check
UPDATE_GOLDENS=1regenerates one of them, then re-run unset to verify the regenerated golden matches.
- Per lib: add 1+ assertGoldenAnsi test for the canonical view() output of the lib's main component(s).
- Convert any tests where the expected string is embedded literally → use a golden file.
- Verify
UPDATE_GOLDENS=1flow on candy-vt (or pick one lib that's representative).
- Each lib's README: a
## Snapshot testsparagraph pointing at the golden-file pattern and the UPDATE_GOLDENS env-var workflow. - Each lib's CALIBER_LEARNINGS: "Use assertGoldenAnsi for any new render() test. Re-record goldens with UPDATE_GOLDENS=1 phpunit after intentional output changes."
- PR title:
9 rendering libs: golden-file snapshot tests via candy-testing - PR body:
## Summary - candy-forms, sugar-prompt, sugar-bits, sugar-charts, sugar-table, sugar-glow, candy-vt, candy-vcr, candy-shine all gain assertGoldenAnsi-backed golden-file tests. - Closes the ecosystem's most-cited weakness: "no snapshot tests for ANSI rendering" (§19/§149). - UPDATE_GOLDENS=1 phpunit workflow documented. - Tests are additive; existing tests preserved. ## Test plan - [x] vendor/bin/phpunit in 9 libs (existing suites + new golden tests all green) - [x] UPDATE_GOLDENS=1 spot-check round-trip verified - [x] php tools/check-path-repos.php Refs: docs/repo_map_step_28.md, docs/repo_map_update.md §19, §149, §322 - Commit subject:
9 rendering libs: golden-file snapshot test rollout via candy-testing.