test: rebuild the view-skeleton suite on ADR 0009 tiers (task 0003)
Guard the CLI entry's program.parse() behind import.meta.main so the command module can be imported without running the CLI, then rebuild the deleted suite across the three tiers ADR 0009 defines: - unit: parse (core) and render (bin), asserted on return values - integration: the view command function, asserted on its Result - e2e: the kitchen binary as a subprocess (exit codes, streams, ANSI suppression, errors, --help) Drop the stale test-support.ts coverage ignore and refresh the task's implementation notes to describe the tiered suite.
This commit is contained in:
@@ -60,20 +60,18 @@ Headings render distinct-by-level via chalk, tapering from bold at level 1 towar
|
||||
Per the cli-view spec, the specific colour and weight choices are visual decisions verified by inspection, not asserted in tests — the renderer tests assert ANSI-stripped text, spacing, and the presence/absence of styling, not particular colours.
|
||||
The frontmatter separator is a dimmed 40-character box-drawing rule.
|
||||
|
||||
### Tests that are green on arrival
|
||||
### Test suite structured on ADR 0009's tiers
|
||||
|
||||
A few required-coverage tests document behaviour that the minimal implementation already satisfies and so pass without a preceding red (frontmatter empty/absent, flat document order, and the level-distinctness/suppression renderer test).
|
||||
They assert real observable behaviour against independent literals rather than restating the implementation.
|
||||
The suite is organised by the three tiers ADR 0009 defines, each seam tested at exactly one tier.
|
||||
Because task 0003's code was already built, these are characterization tests — green on arrival — asserting observable behaviour against independent literals rather than restating the implementation.
|
||||
The CLI entry shell (`packages/bin/src/index.ts`) guards its `program.parse()` behind `import.meta.main`, so importing it never runs the CLI, and the boundary work it does is reachable only through the e2e tier.
|
||||
|
||||
### Review follow-up applied
|
||||
Unit tests cover the two pure seams.
|
||||
`packages/core/src/parse_test.ts` asserts `parse` through the package barrel: frontmatter passthrough for arbitrary, empty, and absent blocks, headings at every level 1–6, paragraphs with `TextNode` content, flat document order, and empty diagnostics.
|
||||
`packages/bin/src/render_test.ts` asserts `render` on ANSI-stripped output: headings at every level, paragraph blank-line spacing, the frontmatter YAML with its separator, and their absence when frontmatter is empty.
|
||||
|
||||
The `runCli` and `stripAnsi` test helpers were extracted into `packages/bin/src/test-support.ts` to remove duplication the review flagged across the bin test files.
|
||||
The scaffold's remaining `test.todo` placeholders (future block/inline types, annotations) are left intact for their owning tasks.
|
||||
Integration tests (`packages/bin/src/view_test.ts`) assert the `view` command function's returned `Result` in-process: `ok` with rendered output for a readable file, frontmatter passthrough, a `read-failed` error for a missing path, and `formatViewError`'s message.
|
||||
|
||||
### End-to-end coverage pulled forward
|
||||
|
||||
A reduced end-to-end smoke was pulled forward so the vertical slice is validated the way a user runs it.
|
||||
End-to-end tests (`packages/bin/src/index_test.ts`) drive the `kitchen` binary as a subprocess, asserting exit codes, stream routing, document order, ANSI suppression on a pipe, the missing-file and missing-argument errors, and `--help`.
|
||||
`fixtures/prose.md` is a committed recipe using only the constructs this slice models — frontmatter, headings at levels 1–3, and plain-text paragraphs — so it renders losslessly today.
|
||||
`integration_test.ts` runs `kitchen view fixtures/prose.md` as a subprocess and asserts the ANSI-stripped output: exit 0, frontmatter YAML before the body, the separator, every heading and paragraph, and flat document order.
|
||||
`smoke_test.ts` covers `kitchen --help` exiting 0 with the `view` command listed.
|
||||
This is a subset of task 0007's smoke, which still owns the full `fixtures/basic.md` end-to-end once 0004's richer nodes make that fixture render losslessly.
|
||||
The full `fixtures/basic.md` end-to-end remains task 0007's, once 0004's richer nodes make that fixture render losslessly.
|
||||
|
||||
Reference in New Issue
Block a user