test(smoke): add network-free CLI smoke tier (JG-10) - #42
Conversation
A real-subprocess smoke set over the cli-process harness: top-level + command help, the invalid-command envelope, and a full devices CDB round-trip (add → list → show → remove + an unknown-target error envelope) against a temp-HOME default CDB. No RouterOS/CHR, so it is not gated behind CENTRS_RUN_FAST_INTEGRATION and runs in the fast push/PR gate via the existing `bun test` Test step — no new CI job, which would re-duplicate right after the #41 workflow de-dupe. Adds a `test:smoke` script for standalone runs. The pre-existing test/unit/smoke.test.ts is an exports/project-baseline unit test, not a CLI smoke; the real CLI smoke needs the subprocess harness (test/integration/cli-process.ts), hence test/integration/cli-smoke.test.ts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 51 minutes and 19 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds ChangesCLI Smoke Integration Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Pull request overview
Adds a new network-free, subprocess-based CLI smoke test tier to validate real-process behavior (arg parsing/help output, exit codes, stdio routing, and JSON/error envelope shape) in the fast bun test gate.
Changes:
- Introduces a new Bun test that spawns
src/cli.tsvia the existingcli-process.tsharness and exercises top-level help, command help, invalid command handling, and adevicesCDB add/list/show/remove round-trip under a tempHOME. - Adds a
test:smokenpm script for running just this CLI smoke test directly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/integration/cli-smoke.test.ts | New subprocess-based CLI smoke tests covering help, invalid command, and CDB-backed devices flows without network/CHR. |
| package.json | Adds test:smoke script to run the new CLI smoke test. |
| * Spawns the real `src/cli.ts` as a child process (via the cli-process harness) | ||
| * and exercises the common, **network-free** user flows: help / usage, the | ||
| * invalid-command path, and a full `devices` CDB round-trip. No RouterOS / CHR is | ||
| * involved, so — unlike the CHR integration suites — this is *not* gated behind | ||
| * `CENTRS_RUN_FAST_INTEGRATION`; it always runs, which means it runs in the fast | ||
| * push/PR gate (ci.yaml's `Test` step) on every change. It double-checks arg | ||
| * parsing, the help system, and the error/result envelope from a *real process*, | ||
| * complementing the in-process unit tests that cannot see exit codes or stdio. |
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 `@test/integration/cli-smoke.test.ts`:
- Around line 25-27: The parseEnvelope function uses a type assertion without
runtime validation, which means malformed JSON will produce generic parsing
errors. To improve test debugging, either add a validation step to verify the
envelope structure matches expectations, or wrap the JSON.parse call in a
try-catch block that re-throws with a descriptive error message that explicitly
states the envelope parsing failed. This will make test failures more specific
and easier to debug when the input JSON is malformed.
🪄 Autofix (Beta)
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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 4fdb1e2f-2e87-42dc-af36-bc149526c46b
📒 Files selected for processing (2)
package.jsontest/integration/cli-smoke.test.ts
Address PR #42 review: - Copilot: document that test/integration/ "platform-specific" includes the network-free, always-run subprocess CLI smoke (it spawns the real cli.ts via cli-process.ts), so its placement matches the test layout rules. - CodeRabbit: parseEnvelope now validates it got an object with a boolean `ok` and throws a clear message otherwise, instead of a bare type assertion. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What
A real-subprocess CLI smoke tier (JG-10) over the existing
cli-process.tsharness — a double-check on arg parsing, the help system, and the error/result envelope from a real process, which the in-process unit tests can't see (no exit codes, no stdio).Cases (all network-free, no RouterOS/CHR):
--helpand no-args render the command index;devices --help);input/invalid-commanderror (exit 1, stable details URL);devicesCDB round-trip —add → list → show → removeplus the unknown-target error envelope (cdb/not-found-target,ok:false,detailsUrl) — against a throwaway default CDB created under a tempHOME.Wiring
Not gated behind
CENTRS_RUN_FAST_INTEGRATION, so it runs in the fast push/PR gate via the existingbun test(Test) step — no new CI job, which would re-duplicate right after the #41 workflow de-dupe. Atest:smokescript is added for standalone runs (bun run test:smoke).Note
The pre-existing
test/unit/smoke.test.tsis an exports/project-baseline unit test, not a CLI smoke; the real CLI smoke needs the subprocess harness, hence the newtest/integration/cli-smoke.test.ts.Verification
bun run test:smoke(4 pass), fullbun run test(663 pass / 0 fail),bun run lint,bun run lint:ci,bun run build: all green.Part of June-Gloom Phase 2 (CI). JG-10.
🤖 Generated with Claude Code
Summary by CodeRabbit