Skip to content

Zero tests on cli/handlers/{state,run,graph}.ts — refactoring is unsafe #29

Closed

Description

@lex00

Per the implementation audit:

  • packages/core/src/cli/handlers/state.ts — 231 LOC, 0 tests
  • packages/core/src/cli/handlers/run.ts — 450+ LOC, 0 tests
  • packages/core/src/cli/handlers/graph.ts — 0 tests
  • packages/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 in packages/test-utils returning a LexiconPlugin with configurable behavior
  • Add a mockTemporalClient({ workflows?, status?, ... }) factory in packages/test-utils returning enough surface for run handler tests (no real Temporal connection)
  • Both factories include vitest expect-friendly call recorders so tests can assert "was describeResources called 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 --force required), 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 — BuildDigest computation 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 run reports 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-utils and consumed by at least three test files

Activity

  1. added a commit that references this issue on May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions