Skip to content

test(smoke): add network-free CLI smoke tier (JG-10) - #42

Merged
mobileskyfi merged 2 commits into
mainfrom
ci/cli-smoke-tier
Jun 16, 2026
Merged

test(smoke): add network-free CLI smoke tier (JG-10)#42
mobileskyfi merged 2 commits into
mainfrom
ci/cli-smoke-tier

Conversation

@mobileskyfi

@mobileskyfi mobileskyfi commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What

A real-subprocess CLI smoke tier (JG-10) over the existing cli-process.ts harness — 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):

  • top-level --help and no-args render the command index;
  • command-level help is reachable (devices --help);
  • an unknown command is the input/invalid-command error (exit 1, stable details URL);
  • a full devices CDB round-trip — add → list → show → remove plus the unknown-target error envelope (cdb/not-found-target, ok:false, detailsUrl) — against a throwaway default CDB created under a temp HOME.

Wiring

Not gated behind CENTRS_RUN_FAST_INTEGRATION, so it 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. A test:smoke script is added for standalone runs (bun run test:smoke).

Note

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, hence the new test/integration/cli-smoke.test.ts.

Verification

bun run test:smoke (4 pass), full bun 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

  • Tests
    • Added CLI smoke testing suite to validate core command-line functionality and error handling without external dependencies.

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>
Copilot AI review requested due to automatic review settings June 16, 2026 10:38
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@mobileskyfi, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2b13017c-409a-4036-84a9-a731aecda907

📥 Commits

Reviewing files that changed from the base of the PR and between 9f8a766 and 2ffdcc8.

📒 Files selected for processing (2)
  • test/AGENTS.md
  • test/integration/cli-smoke.test.ts
📝 Walkthrough

Walkthrough

Adds test/integration/cli-smoke.test.ts, a new integration test suite that spawns src/cli.ts as a real subprocess to verify network-free CLI behavior: help output, unknown-command error responses, and a full devices CDB round-trip (add → list → show → remove) using an isolated temporary HOME directory. A test:smoke script is added to package.json.

Changes

CLI Smoke Integration Tests

Layer / File(s) Summary
CLI smoke test suite and script entry point
test/integration/cli-smoke.test.ts, package.json
Adds the complete smoke test file defining the Envelope interface, parseEnvelope helper, and five test cases covering no-args/help rendering, devices --help, unknown-command exit code 1 with stderr validation, and a devices CDB add/list/show/remove round-trip asserting JSON envelope ok: true/ok: false fields and stable error codes. Wires the suite via a new test:smoke script in package.json.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A rabbit hops through the CLI gate,
Spawning processes to validate,
Help text renders, errors ring true,
Devices add, list, show — then remove too!
JSON envelopes checked with care,
Smoke tests passing beyond compare. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a network-free CLI smoke test tier. It is specific, relates directly to the changeset, and includes the ticket reference.
Description check ✅ Passed The description covers all key aspects: what was added, the network-free test cases, integration details, and verification results. However, the change type checkboxes in the template are not marked.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/cli-smoke-tier

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.ts via the existing cli-process.ts harness and exercises top-level help, command help, invalid command handling, and a devices CDB add/list/show/remove round-trip under a temp HOME.
  • Adds a test:smoke npm 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.

Comment on lines +4 to +11
* 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4557db1 and 9f8a766.

📒 Files selected for processing (2)
  • package.json
  • test/integration/cli-smoke.test.ts

Comment thread test/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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants