test(cli): add focused dispatch behavior tests - #1457
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR adds ChangesCLI dispatch resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
f1a2233 to
0256994
Compare
0256994 to
295a52a
Compare
295a52a to
2315e6c
Compare
Phase 6 (final) of the CLI deepening: add tests/cli-dispatch.test.ts covering the pure dispatch contract — DISPATCH_COMMANDS/DISPATCH_ALIASES invariants, alias resolution (setup/init, eject/restore, remove/uninstall, model/models), and dispatchCommand exit-code returns for help forms (0) and unknown commands (1). Full-stack verification: 213 pass / 4 known pre-existing environmental failures; typecheck green.
2315e6c to
7409e83
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/cli-dispatch.test.ts`:
- Around line 31-36: Extend the alias coverage in the test named “canonical
alias pairs resolve to their command” to exercise dispatchCommand rather than
only inspecting DISPATCH_ALIASES. Stub the relevant runners and verify each of
setup, eject, remove, and model invokes its mapped target runner; alternatively
extract a pure resolver used by dispatchCommand and test all four mappings
through it.
- Around line 39-44: Add a `dispatchCommand` assertion in the “returns 0 for
help forms” test for the `-h` command, using the same help request shape and
expected exit code as the existing `help` and `--help` cases.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d61a459a-0474-42cc-9bfc-3416b4a5a5b4
📒 Files selected for processing (1)
tests/cli-dispatch.test.ts
Addresses two CodeRabbit findings on #1457: - extract resolveDispatchCommand (the pure resolver dispatchCommand uses for runner selection) and test all four aliases (setup/eject/remove/model) plus canonical/unknown/undefined cases at the resolution level, so a regression in the alias lookup is caught - cover the -h help form in the dispatchCommand help-forms test
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cli/dispatch.ts`:
- Around line 513-516: The resolveDispatchCommand lookup currently accepts
inherited Object properties as valid commands. Replace the `command in
commandRunners` check with `Object.prototype.hasOwnProperty.call(commandRunners,
command)`, preserving alias resolution for valid names, and add regression tests
ensuring `dispatchCommand` returns exit code 1 for `__proto__`, `constructor`,
and `toString`.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: cbde8509-8b56-4686-8c93-35818f620029
📒 Files selected for processing (2)
src/cli/dispatch.tstests/cli-dispatch.test.ts
Addresses CodeRabbit finding on #1457 (stability): commandRunners is a normal object, so 'in' accepted inherited names (__proto__, constructor, toString), reaching a non-callable or inherited function. Use Object.prototype.hasOwnProperty for the lookup and add regression tests asserting dispatchCommand returns exit code 1 for those names.
Summary
Add focused behavior tests for the CLI dispatch module (final phase of the CLI deepening).
tests/cli-dispatch.test.tscovering the pure dispatch contract:DISPATCH_COMMANDS/DISPATCH_ALIASESinvariants, alias resolution (setup→init,eject→restore,remove→uninstall,model→models), anddispatchCommandexit-code returns for help forms (0) and unknown commands (1).Verification
tests/cli-dispatch.test.ts— 5 pass.bun run typecheck— exit 0.cli-restore-back(2) andPOST /api/syncownership (2) environmental cases.No GUI changes; no screenshot required.
Checklist
Review notes (stacked PR): stacks on #1456 (
codex/cli-help). Does not targetdev. Diff is only the new dispatch behavior test (e897d990..f1a22339): 1 file, +50. Merge only after the earlier phases (#1444, #1446, #1451, #1455, #1456) land.Summary by CodeRabbit
Bug Fixes
Tests