test(commands): cover gesture, settle-baseline, appstate, alert-wait, and JSON-object branches

Merged
TH
2mo ago
+325-1

Summary

Burns down the five coverage-based CRAP findings in #3422 by covering their uncovered branches through each owning module's public entry point (no new production exports, no test-only DI). 5 test files, one new (interaction/index.test.ts mirrors interaction/index.ts); no production-code changes. Gross diff ~325 lines.

FunctionBeforeAfter
cli-grammar/common.ts:227 readJsonObject30 (0%)5 (100%)
interaction/index.ts:619 run (gesture dispatch)35 (25%)8 (100%)
interaction/runtime/settle.ts:249 sessionBaseline30 (0%)5 (100%)
system/output.ts:67 formatAppleAppState42 (0%)6 (100%)
system/runtime/system.ts:448 normalizeAlertWaitResult30 (0%)5 (100%)
  • readJsonObject: accept + all refusal shapes, tested in common.test.ts.
  • Gesture run: all seven kinds routed via the family definition's invoke (the real dispatch path), pinning both the client.interactions.* method and the projected options for each kind.
  • sessionBaseline: ref-frame / snapshot / empty pre-frame chain through settleAfterInteraction with a point target; a ?? swap mutation fails the ref-frame test.
  • formatAppleAppState: runner/session/no-identity renders through systemCliOutputFormatters.appstate.
  • normalizeAlertWaitResult: visible / timed-out / no-timing-fields / wrong-kind refusal (typed BackendAlertResult double, asserting COMMAND_FAILED) through device.system.alert.

Closes #3422, part of #3414.

Validation

Tested SHA ffd2f0590: pnpm format and pnpm check:affected --run (under the machine lock) pass. Per-file vitest related + pnpm check:coverage-crap --all over the five owned files: no function at or above CRAP 30 (before: all five listed); CI's Coverage CRAP step confirmed the same at 06d2bb965. Mutation checks: swapping sessionBaseline's ?? order and flipping the alert code both fail their tests. No baseline/gate files touched.