Repository navigation
Closed
Description
Per the implementation audit:
packages/core/src/cli/handlers/state.ts— 231 LOC, 0 testspackages/core/src/cli/handlers/run.ts— 450+ LOC, 0 testspackages/core/src/cli/handlers/graph.ts— 0 testspackages/core/src/state/snapshot.ts,state/git.ts,state/digest.ts— 0 tests
state/digest.ts is the engine behind state diff and is exactly the area #26 will rewrite. That issue in particular needs coverage to land safely. The other handlers are user-facing CLI commands and shouldn't ship without tests.
Prerequisite for #26. Independent of #27/#28/#30/#31, but pairs naturally with all of them.
Tasks
Test infrastructure
- Add a
mockPlugin({ describeResources?, ... })factory inpackages/test-utilsreturning aLexiconPluginwith configurable behavior - Add a
mockTemporalClient({ workflows?, status?, ... })factory inpackages/test-utilsreturning enough surface for run handler tests (no real Temporal connection) - Both factories include vitest
expect-friendly call recorders so tests can assert "wasdescribeResourcescalled with env X"
Handler tests
-
cli/handlers/state.test.ts— cover snapshot (success, no plugins, plugin throws), show (existing snapshot, missing snapshot), diff (digest mode happy path, no prior snapshot), log (empty, with history) -
cli/handlers/run.test.ts— cover run submit (success, missing op), list (with/without Temporal connection), status, signal, cancel (with--forcerequired), log -
cli/handlers/graph.test.ts— cover empty repo, single op, op with deps, missing-dep error
State internals tests
-
state/snapshot.test.ts—takeSnapshot()with mocked plugins: success path, plugin throws → handled, no plugins → empty snapshot -
state/git.test.ts— orphan branch operations against a temp git repo: write, read, list, history -
state/digest.test.ts—BuildDigestcomputation determinism + diff edge cases (added/removed/identical/permuted)
Verification
- All new test files follow the structure of
packages/core/src/cli/commands/build.test.ts - Run
npx vitest run --coverage packages/core/src/{state,cli/handlers}and capture baseline coverage in the PR description
Done when
- Six new test files exist (three handlers + three state internals)
-
npx vitest runreports them all passing - Line coverage for each of the six target source files is ≥ 70% (per
npx vitest run --coverage) - Mock factories are exported from
@intentius/test-utilsand consumed by at least three test files
Metadata
Metadata
Assignees
Labels
No labels
Activity
Merge pull request #35 from INTENTIUS/feat/handler-test-coverage-issu…