Skip to content

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

Merged
thymikee merged 2 commits into
mainfrom
crap/3422-commands
Oct 11, 2026
Merged

thymikee merged 2 commits into
mainfrom
crap/3422-commands

Conversation

@thymikee

@thymikee thymikee commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

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.

Function Before After
cli-grammar/common.ts:227 readJsonObject 30 (0%) 5 (100%)
interaction/index.ts:619 run (gesture dispatch) 35 (25%) 8 (100%)
interaction/runtime/settle.ts:249 sessionBaseline 30 (0%) 5 (100%)
system/output.ts:67 formatAppleAppState 42 (0%) 6 (100%)
system/runtime/system.ts:448 normalizeAlertWaitResult 30 (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.

…, and alert-wait branches

Burn down the coverage-based CRAP findings from #3422:
- readJsonObject: accept/refuse table through the cli-grammar reader
- gesture run: all seven kinds routed through the family definition's invoke
- sessionBaseline: ref-frame, snapshot, and pre-frame-empty chains through
  settleAfterInteraction with a point target
- formatAppleAppState: runner/session/unknown renders through the appstate
  CLI output formatter
- normalizeAlertWaitResult: visible and timed-out projections plus the
  wrong-kind refusal through the runtime alert command

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.17 MB 5.17 MB 0 B
Package (unpacked) 5.17 MB 5.17 MB 0 B
Package (download) 1.55 MB 1.55 MB -1 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.4 ms 26.6 ms +0.2 ms
CLI --help 79.1 ms 78.6 ms -0.5 ms

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 06d2bb9. The diff is test-only, all 18 checks pass, and no open reviewer threads remain. There are no conflicts. I did not run the tests, the mutation checks or the coverage-CRAP gate, and the CRAP before and after numbers are your local measurement. I also did not check that the settle fixtures behave exactly as the assertions assume, so I relied on CI being green for that.

Not blocking: in https://github.com/callstack/agent-device/blob/06d2bb9/src/commands/system/runtime/system.test.ts#L123 the backend double and the wrong-kind alert case return as never, which skips BackendAlertResult typing, so typing those outcomes would let you drop the casts and assert code COMMAND_FAILED with the message. In https://github.com/callstack/agent-device/blob/06d2bb9/src/commands/interaction/index.test.ts#L49 the routing table checks only the method name, so a wrong option mapping for fling, swipe, rotate or transform would pass, and you could add toMatchObject on options for those or leave it to the toXOptions tests in gesture.test.ts. Take or leave either one.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 11, 2026
…re option projection

Review follow-up on #3438:
- the alert-wait backend double returns BackendAlertResult values, dropping
  the `as never` casts, and the wrong-kind refusal asserts the typed
  COMMAND_FAILED code alongside the message
- the gesture routing table now asserts the projected client options for
  every kind (fling, swipe, rotate, and transform had no toXOptions mapping
  test in gesture.test.ts)
@thymikee

Copy link
Copy Markdown
Member Author

Both review items addressed in ffd2f0590:

  1. system.test.ts: the alert-wait backend double now returns typed BackendAlertResult values (both the projected-outcome array and the wrong-kind outcome), so the as never casts are gone; the wrong-kind refusal asserts code COMMAND_FAILED alongside the message (mutation check: flipping the thrown code to INVALID_ARGS fails the test).
  2. index.test.ts: the routing table now pins the projected options for every kind via toMatchObject, including fling, swipe, rotate, and transform — gesture.test.ts only covers the CLI reader and daemon writer for pan/drag, not the client-side toXOptions projection, so these mappings were unpinned before.

Still test-only. pnpm format and pnpm check:affected --run pass on ffd2f0590.

@thymikee
thymikee merged commit 52ce29d into main Oct 11, 2026
18 checks passed
@thymikee
thymikee deleted the crap/3422-commands branch October 11, 2026 17:28
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-11 17:29 UTC

@thymikee

Copy link
Copy Markdown
Member Author

The earlier clean review of 06d2bb9 still holds, and I found no problems in the new tests at ffd2f05. This change is test-only (+0/-0 production lines), and the new cases match the head index.ts projections as I read them. All 18 checks pass and there are no conflicts. I read the diff but did not run the tests on this head, and I did not re-run the mutation check that flips the thrown code to INVALID_ARGS. No review threads are open, so nothing else is needed before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRAP: command input, interaction and system output branches

1 participant