test(cli): cover runtime utility helpers#2944
Conversation
This reverts commit 4ebeae4.
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
📝 WalkthroughWalkthroughThis PR adds test coverage for global CLI actions, introduces an optional runtime hook for sandbox upgrades, and removes obsolete v8 ignore comments from utility modules. ChangesGlobal CLI Actions - Runtime Hooks
Test Coverage & Code Cleanup
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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 docstrings
🧪 Generate unit tests (beta)
Comment |
Signed-off-by: Carlos Villela <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/global-cli-actions.test.ts (1)
95-101: ⚡ Quick winAdd an explicit fallback test for
runUpgradeSandboxesActionwith no hook injected.This PR changes upgrade hook routing; covering the no-hook branch here would close the main regression gap in this suite.
Suggested test extension
const mocks = vi.hoisted(() => ({ backupAll: vi.fn(), garbageCollectImages: vi.fn().mockResolvedValue(undefined), help: vi.fn(), recoverNamedGatewayRuntime: vi.fn().mockResolvedValue({ recovered: true }), runDeployAction: vi.fn().mockResolvedValue(undefined), runOnboardAction: vi.fn().mockResolvedValue(undefined), runOpenshell: vi.fn(() => ({ status: 0 })), runSetupAction: vi.fn().mockResolvedValue(undefined), runSetupSparkAction: vi.fn().mockResolvedValue(undefined), + upgradeSandboxes: vi.fn().mockResolvedValue(undefined), version: vi.fn(), })); @@ vi.mock("./root-help-action", () => ({ help: mocks.help, version: mocks.version })); +vi.mock("./upgrade-sandboxes-action", () => ({ + upgradeSandboxes: mocks.upgradeSandboxes, +})); @@ it("falls back to default runtime hooks", async () => { await expect(recoverNamedGatewayRuntime()).resolves.toEqual({ recovered: true }); runOpenshellProviderCommand(["provider", "list"]); + await runUpgradeSandboxesAction({ check: true }); expect(mocks.recoverNamedGatewayRuntime).toHaveBeenCalledWith(); expect(mocks.runOpenshell).toHaveBeenCalledWith(["provider", "list"], undefined); + expect(mocks.upgradeSandboxes).toHaveBeenCalledWith({ check: true }); });🤖 Prompt for 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. In `@src/lib/global-cli-actions.test.ts` around lines 95 - 101, Add a test that covers the no-hook fallback for runUpgradeSandboxesAction: mirror the existing "falls back to default runtime hooks" test pattern by invoking runUpgradeSandboxesAction() (ensuring any necessary setup like recoverNamedGatewayRuntime() is awaited if used elsewhere), assert the call resolves to the expected default result, and verify the upgrade hook passthrough by asserting mocks.runUpgradeSandboxes was called with no injected hook (or undefined) and any expected default args; use the same mocking/verification style as the existing tests to locate the code paths in runUpgradeSandboxesAction and mocks.runUpgradeSandboxes.
🤖 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.
Nitpick comments:
In `@src/lib/global-cli-actions.test.ts`:
- Around line 95-101: Add a test that covers the no-hook fallback for
runUpgradeSandboxesAction: mirror the existing "falls back to default runtime
hooks" test pattern by invoking runUpgradeSandboxesAction() (ensuring any
necessary setup like recoverNamedGatewayRuntime() is awaited if used elsewhere),
assert the call resolves to the expected default result, and verify the upgrade
hook passthrough by asserting mocks.runUpgradeSandboxes was called with no
injected hook (or undefined) and any expected default args; use the same
mocking/verification style as the existing tests to locate the code paths in
runUpgradeSandboxesAction and mocks.runUpgradeSandboxes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: a35ecbaa-8417-45a1-a33b-2caeac64a861
📒 Files selected for processing (5)
src/lib/global-cli-actions.test.tssrc/lib/global-cli-actions.tssrc/lib/oclif-runner.tssrc/lib/terminal-style.test.tssrc/lib/terminal-style.ts
💤 Files with no reviewable changes (2)
- src/lib/oclif-runner.ts
- src/lib/terminal-style.ts
prekshivyas
left a comment
There was a problem hiding this comment.
LGTM. Test-coverage PR with one description-completeness nit.
What landed:
global-cli-actions.test.ts(+102): new tests for the facade — action forwarding, hook injection, default fallback paths.terminal-style.test.ts(+14): existence check on color constants.oclif-runner.tsandterminal-style.ts: remove/* v8 ignore start */so coverage counts these.global-cli-actions.ts(+5/-2): addsupgradeSandboxestoGlobalCliActionRuntimeHookswith a fall-through inrunUpgradeSandboxesAction— a new test-injection seam mirroring the existingrecoverNamedGatewayRuntime/runOpenshellhooks. Production impact zero.
Nit (non-blocking): the PR description only mentions removing v8-ignores from oclif-runner + terminal-style; it doesn't mention the global-cli-actions.test.ts (102 of 121 added lines) or the new upgradeSandboxes hook. CodeRabbit's auto-summary did surface it. Worth pulling that into the body before squash-merge so the commit message reflects what landed.
CI: pr.yaml mostly green (lint/dco/check-hash/legacy-path-guard/changes PASS); CodeRabbit SUCCESS; macos-e2e/checks + pr-self-hosted builds still in flight at review time. No failures.
## Summary Stabilize CLI coverage runs by cleaning compiled CLI output before coverage builds and validating that generated JavaScript sourcemaps point at existing sources. This makes coverage use a clean `dist/` baseline instead of stale generated files. ## Stack Navigation - Position: 46 of 60 - Previous PR: [#2944 — test(cli): cover runtime utility helpers](#2944) - Next PR: [#2962 — refactor(cli): extract maintenance image helpers](#2962) ## Changes - Added `npm run clean:cli` for removing stale `dist/` artifacts without changing the normal `build:cli` ordering. - Added `scripts/check-dist-sourcemaps.ts` and `npm run dist:sourcemaps:check` to fail fast on stale generated sourcemaps. - Updated the CLI coverage pre-push hook to clean `dist/`, rebuild, and validate sourcemaps before running coverage. - Rebaselined CLI function coverage to the clean-dist value exposed by the stabilized run. - Added unit coverage for the sourcemap checker. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Verification - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `make docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- Signed-off-by: Carlos Villela <[email protected]> --------- Signed-off-by: Carlos Villela <[email protected]> Co-authored-by: Prekshi Vyas <[email protected]>
Summary
Remove broad coverage ignores from small runtime utility modules that already have or can have direct tests.
Stack Navigation
Changes
Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela [email protected]
Summary by CodeRabbit
New Features
Chores