Skip to content

test: add comprehensive unit tests and raise coverage thresholds - #595

Merged
ericksoa merged 5 commits into
NVIDIA:mainfrom
cv:test/raise-coverage-thresholds
Mar 22, 2026
Merged

ericksoa merged 5 commits into
NVIDIA:mainfrom
cv:test/raise-coverage-thresholds

Conversation

@cv

@cv cv commented Mar 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add unit tests for all plugin modules: onboard/config, commands/slash, blueprint/state, commands/migration-state, and expand register.test.ts with getPluginConfig and custom model coverage
  • Raise coverage thresholds from single digits (6%/2%/5%/6%) to 94%/98%/87%/93% (statements/functions/branches/lines)
  • Total test count goes from 3 to 75

Test plan

  • npx vitest run --coverage passes with all 75 tests green
  • Coverage meets new thresholds: 94% statements, 98% functions, 87% branches, 93% lines
  • CI coverage ratchet check passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests

    • Added extensive test suites covering state management, migration snapshotting/restoration, slash command behavior, onboard config persistence, and plugin registration.
  • Chores

    • Raised minimum code coverage thresholds significantly for lines, functions, branches, and statements.
    • Updated pre-commit hook to run the test suite during commit validation.
    • Relaxed two ESLint rules for test files to reduce noisy warnings.

@coderabbitai

coderabbitai Bot commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR raises CI coverage thresholds and adds multiple Vitest suites for state, migration, slash, onboarding, and registration behaviors; it also updates ESLint test rules and runs Vitest in the pre-commit hook.

Changes

Cohort / File(s) Summary
Coverage Configuration
ci/coverage-threshold.json
Coverage minimums increased from { lines: 6, functions: 2, branches: 5, statements: 6 } to { lines: 93, functions: 98, branches: 87, statements: 94 }.
State Tests
nemoclaw/src/blueprint/state.test.ts
New Vitest suite for loadState/saveState/clearState using an in-memory fs mock; verifies file-absent behavior, timestamp initialization, and persistence semantics.
Migration Command Tests
nemoclaw/src/commands/migration-state.test.ts
Extensive in-memory tests for host detection, snapshot bundle creation/cleanup, archive creation (tar.create mocked), manifest loading, and restore flows; many filesystem ops are mocked.
Slash Command Tests
nemoclaw/src/commands/slash.test.ts
Tests for handleSlashCommand covering help/status/eject/onboard outputs across blank, populated, and snapshot/backup scenarios with mocked state and onboard utilities.
Onboard Config Tests
nemoclaw/src/onboard/config.test.ts
Tests for describeOnboardEndpoint/describeOnboardProvider, plus loadOnboardConfig/saveOnboardConfig/clearOnboardConfig using an in-memory fs mock and HOME-based path resolution.
Register Tests & Helpers
nemoclaw/src/register.test.ts
Adds getPluginConfig tests and adjusts register tests; mocks onboard config helpers and validates model/provider registration behavior and config defaulting.
Git Hook
.husky/pre-commit
Pre-commit hook now runs cd nemoclaw && npx vitest run (added set -e and test execution after lint-staged).
ESLint Config
nemoclaw/eslint.config.mjs
Test-targeted ESLint rules @typescript-eslint/no-unsafe-return and @typescript-eslint/unbound-method set to off for src/**/*.test.ts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through mocks and tiny files bright,
Saving states by soft lamplight,
Snapshots bundled, commands rehearsed,
Pre-commit runs — no tests reversed,
My whiskers twitch — the suite takes flight!

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding comprehensive unit tests across multiple modules and raising coverage thresholds from ~6% to ~94%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 5

🧹 Nitpick comments (1)
nemoclaw/src/register.test.ts (1)

48-81: Consider mocking node:fs instead of touching the real filesystem.

This test writes to the real filesystem at $HOME/.nemoclaw/config.json, which is fragile and could cause issues in CI or conflict with a developer's actual config. Other test files in this PR (e.g., config.test.ts, state.test.ts) use vi.mock("node:fs") with an in-memory store.

Additionally, using require("node:fs") (lines 51-52) is not idiomatic in ESM modules.

♻️ Suggested approach

Consider either:

  1. Move vi.mock("node:fs") to the top of this file and use the same in-memory store pattern as other test files
  2. Or create a shared fs mock utility that can be imported across test files

This would make the test deterministic and avoid polluting the real filesystem.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/register.test.ts` around lines 48 - 81, The test manipulates the
real filesystem via require("node:fs") and writing to
$HOME/.nemoclaw/config.json; instead mock node:fs like other tests to use an
in-memory store. Update this test to call vi.mock("node:fs") at the top (or
import and use the shared fs mock utility used by config.test.ts/state.test.ts),
replace the require("node:fs")/require("node:path") usage with imports
consistent with ESM, and seed the in-memory fs store with the config JSON before
calling register(api) so createMockApi and register(...) observe the mocked
config without touching the real filesystem. Ensure you reference and use the
same mock API (vi.mock("node:fs") in this file) and restore/clear the mock store
between tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@nemoclaw/src/blueprint/state.test.ts`:
- Around line 102-104: The test currently uses an arrow shorthand that returns a
void expression (expect(() => clearState()).not.toThrow()); change the anonymous
arrow to a block body so it becomes a statement: wrap the call to clearState()
in braces—i.e. use expect(() => { clearState(); }).not.toThrow();—so ESLint no
longer flags the void-expression-in-arrow-function error; update the test
referencing clearState and the expect call accordingly.
- Around line 9-11: Replace the forbidden inline import() type annotation used
in the vi.mock callback by declaring a top-level type import and using that type
with importOriginal; specifically, add a type import like `import type * as
NodeFs from "node:fs"` and then change the call `await importOriginal<typeof
import("node:fs")>()` to `await importOriginal<typeof NodeFs>()` inside the
vi.mock callback so the inline import() type is removed while keeping the same
runtime behavior.

In `@nemoclaw/src/commands/migration-state.test.ts`:
- Line 5: Remove the unused import statement `import path from "node:path"` from
the file (migration-state.test.ts); locate the top-level import of `path` and
delete that line so there are no unused imports remaining.
- Around line 39-43: The mock readFileSync uses a non-null assertion on
entry.content; instead narrow the type so the compiler knows content is present:
after retrieving entry from store in the readFileSync implementation, explicitly
check that entry exists and entry.type === "file" and entry.content !==
undefined (or use a user-defined type guard like isFileEntry(entry): entry is
FileEntry) and throw ENOENT if not; then return entry.content without using the
non-null assertion. Alternatively, update the FsEntry/FileEntry types so that
entries with type === "file" always have a non-optional content property.
- Around line 31-32: The test's vi.mock call uses a forbidden import() type
annotation on importOriginal (await importOriginal<typeof import("node:fs")>());
change this to use a type assertion instead: call await importOriginal() and
then assert its type to typeof import("node:fs") (e.g., assign to a const
original and cast it) so that the variables original and importOriginal keep the
correct node:fs typing without using import() in a type position.

---

Nitpick comments:
In `@nemoclaw/src/register.test.ts`:
- Around line 48-81: The test manipulates the real filesystem via
require("node:fs") and writing to $HOME/.nemoclaw/config.json; instead mock
node:fs like other tests to use an in-memory store. Update this test to call
vi.mock("node:fs") at the top (or import and use the shared fs mock utility used
by config.test.ts/state.test.ts), replace the
require("node:fs")/require("node:path") usage with imports consistent with ESM,
and seed the in-memory fs store with the config JSON before calling
register(api) so createMockApi and register(...) observe the mocked config
without touching the real filesystem. Ensure you reference and use the same mock
API (vi.mock("node:fs") in this file) and restore/clear the mock store between
tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 139bb8fd-79da-43a6-b3a9-1ba2ab3a8ea6

📥 Commits

Reviewing files that changed from the base of the PR and between e52c2f0 and 0eb056b.

📒 Files selected for processing (6)
  • ci/coverage-threshold.json
  • nemoclaw/src/blueprint/state.test.ts
  • nemoclaw/src/commands/migration-state.test.ts
  • nemoclaw/src/commands/slash.test.ts
  • nemoclaw/src/onboard/config.test.ts
  • nemoclaw/src/register.test.ts

Comment thread nemoclaw/src/blueprint/state.test.ts Resolved
Comment thread nemoclaw/src/blueprint/state.test.ts Resolved
cv and others added 2 commits March 21, 2026 11:27
Add tests for all plugin modules: onboard/config, commands/slash,
blueprint/state, commands/migration-state, and expand register tests
with getPluginConfig and custom model coverage. Raises coverage
thresholds from single digits to 87-98% across all metrics.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add vitest run to the pre-commit hook alongside lint-staged. Tests
complete in ~250ms so there's no meaningful delay to the workflow.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

♻️ Duplicate comments (5)
nemoclaw/src/commands/migration-state.test.ts (3)

5-5: ⚠️ Potential issue | 🟡 Minor

Remove unused node:path import.

Line 5 is unused and causes lint failure.

🔧 Proposed fix
-import path from "node:path";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/commands/migration-state.test.ts` at line 5, Remove the unused
import of node:path from the top of the test file: eliminate the line importing
"node:path" (the unused symbol path) in migration-state.test.ts to resolve the
lint failure; ensure no other references to path remain in the file after
removal.

39-43: ⚠️ Potential issue | 🟠 Major

Remove forbidden non-null assertion in readFileSync mock.

Line 42 uses !, which is disallowed by the lint rules in this repo.

🔧 Proposed fix
     readFileSync: (p: string) => {
       const entry = store.get(p);
-      if (!entry || entry.type !== "file") throw new Error(`ENOENT: ${p}`);
-      return entry.content!;
+      if (!entry || entry.type !== "file" || entry.content === undefined) {
+        throw new Error(`ENOENT: ${p}`);
+      }
+      return entry.content;
     },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/commands/migration-state.test.ts` around lines 39 - 43, The
readFileSync mock uses a forbidden non-null assertion on entry.content; update
the readFileSync implementation (the mock that calls store.get) to explicitly
handle the missing content instead of using `!`: after retrieving entry via
store.get(p) check that entry.content is defined and return it, otherwise throw
the same ENOENT error (or a clear error), so remove the `entry.content!`
non-null assertion and replace it with an explicit runtime check around
entry.content in the readFileSync mock.

31-33: ⚠️ Potential issue | 🟠 Major

Avoid inline import() type annotation in vi.mock callback typing.

Line 32 violates the lint configuration and blocks lint.

🔧 Proposed fix
 import { describe, it, expect, beforeEach, vi } from "vitest";
 import type { PluginLogger } from "../index.js";
+import type * as NodeFs from "node:fs";
@@
 vi.mock("node:fs", async (importOriginal) => {
-  const original = await importOriginal<typeof import("node:fs")>();
+  const original = await importOriginal<typeof NodeFs>();
   return {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/commands/migration-state.test.ts` around lines 31 - 33, The
inline type annotation using typeof import("node:fs") inside the vi.mock
callback causes the lint failure; define a top-level type alias (e.g., type
NodeFs = typeof import("node:fs")) and then replace the inline annotation by
referencing that alias when calling importOriginal (e.g., await
importOriginal<NodeFs>()), or alternatively remove the generic and cast the
result to that alias—update usage in the vi.mock callback where importOriginal
is called and in any variable like original to use the new NodeFs alias.
nemoclaw/src/blueprint/state.test.ts (2)

102-104: ⚠️ Potential issue | 🟡 Minor

Use a block body to avoid returning a void expression from shorthand arrow.

Line 103 violates the configured lint rule.

🔧 Proposed fix
-    it("does nothing when no file exists", () => {
-      expect(() => clearState()).not.toThrow();
-    });
+    it("does nothing when no file exists", () => {
+      expect(() => {
+        clearState();
+      }).not.toThrow();
+    });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/blueprint/state.test.ts` around lines 102 - 104, The test uses a
shorthand arrow that returns a void expression, violating the lint rule; change
the test callback for the "does nothing when no file exists" case to a
block-bodied function (e.g., it("does nothing when no file exists", () => {
expect(() => clearState()).not.toThrow(); })), ensuring the callback has a block
body and does not implicitly return a void expression; reference the clearState
function and that test name when updating the test.

9-11: ⚠️ Potential issue | 🟠 Major

Replace forbidden inline import() type annotation in mock factory.

Line 10 triggers the lint rule and is currently blocking npm run lint.

🔧 Proposed fix
 import { describe, it, expect, beforeEach, vi } from "vitest";
 import { loadState, saveState, clearState, type NemoClawState } from "./state.js";
+import type * as NodeFs from "node:fs";
@@
 vi.mock("node:fs", async (importOriginal) => {
-  const original = await importOriginal<typeof import("node:fs")>();
+  const original = await importOriginal<typeof NodeFs>();
   return {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/blueprint/state.test.ts` around lines 9 - 11, The inline type
annotation import("node:fs") in the vi.mock factory is forbidden by the linter;
remove it and use a proper top-level type import or rely on inferred types
instead. For example, add a top-level type statement like "import type * as fs
from 'node:fs'" and then change the mock factory to "const original = await
importOriginal<typeof fs>();" or simply "const original = await
importOriginal();" so the vi.mock(importOriginal => { ... }) factory no longer
uses an inline import() type; update occurrences of importOriginal and original
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.husky/pre-commit:
- Around line 2-3: Add a fail-fast shell option to the pre-commit hook so a
failing lint-staged cannot be bypassed: enable "set -e" at the top of the script
(or chain the commands with &&) so that "npx --no -- lint-staged" aborts the
hook on failure before running "cd nemoclaw && npx vitest run".

---

Duplicate comments:
In `@nemoclaw/src/blueprint/state.test.ts`:
- Around line 102-104: The test uses a shorthand arrow that returns a void
expression, violating the lint rule; change the test callback for the "does
nothing when no file exists" case to a block-bodied function (e.g., it("does
nothing when no file exists", () => { expect(() => clearState()).not.toThrow();
})), ensuring the callback has a block body and does not implicitly return a
void expression; reference the clearState function and that test name when
updating the test.
- Around line 9-11: The inline type annotation import("node:fs") in the vi.mock
factory is forbidden by the linter; remove it and use a proper top-level type
import or rely on inferred types instead. For example, add a top-level type
statement like "import type * as fs from 'node:fs'" and then change the mock
factory to "const original = await importOriginal<typeof fs>();" or simply
"const original = await importOriginal();" so the vi.mock(importOriginal => {
... }) factory no longer uses an inline import() type; update occurrences of
importOriginal and original accordingly.

In `@nemoclaw/src/commands/migration-state.test.ts`:
- Line 5: Remove the unused import of node:path from the top of the test file:
eliminate the line importing "node:path" (the unused symbol path) in
migration-state.test.ts to resolve the lint failure; ensure no other references
to path remain in the file after removal.
- Around line 39-43: The readFileSync mock uses a forbidden non-null assertion
on entry.content; update the readFileSync implementation (the mock that calls
store.get) to explicitly handle the missing content instead of using `!`: after
retrieving entry via store.get(p) check that entry.content is defined and return
it, otherwise throw the same ENOENT error (or a clear error), so remove the
`entry.content!` non-null assertion and replace it with an explicit runtime
check around entry.content in the readFileSync mock.
- Around line 31-33: The inline type annotation using typeof import("node:fs")
inside the vi.mock callback causes the lint failure; define a top-level type
alias (e.g., type NodeFs = typeof import("node:fs")) and then replace the inline
annotation by referencing that alias when calling importOriginal (e.g., await
importOriginal<NodeFs>()), or alternatively remove the generic and cast the
result to that alias—update usage in the vi.mock callback where importOriginal
is called and in any variable like original to use the new NodeFs alias.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7ccb6b67-ebf7-435d-9946-2b5606c54c3a

📥 Commits

Reviewing files that changed from the base of the PR and between 0eb056b and c15a89c.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (11)
  • .husky/commit-msg
  • .husky/pre-commit
  • .husky/pre-push
  • ci/coverage-threshold.json
  • nemoclaw/src/blueprint/state.test.ts
  • nemoclaw/src/commands/migration-state.test.ts
  • nemoclaw/src/commands/slash.test.ts
  • nemoclaw/src/onboard/config.test.ts
  • nemoclaw/src/register.test.ts
  • package.json
  • scripts/debug.sh
✅ Files skipped from review due to trivial changes (5)
  • scripts/debug.sh
  • .husky/commit-msg
  • .husky/pre-push
  • ci/coverage-threshold.json
  • nemoclaw/src/onboard/config.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • nemoclaw/src/register.test.ts

Comment thread .husky/pre-commit Resolved

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

♻️ Duplicate comments (5)
nemoclaw/src/commands/migration-state.test.ts (3)

5-5: ⚠️ Potential issue | 🟡 Minor

Remove unused node:path import.

Line 5 is unused and currently trips lint.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/commands/migration-state.test.ts` at line 5, Remove the unused
import statement `import path from "node:path";` from the
migration-state.test.ts test file (the import is not referenced anywhere in the
tests), leaving other imports and test code intact so lint no longer flags the
unused symbol.

39-43: ⚠️ Potential issue | 🟡 Minor

Avoid non-null assertion in readFileSync mock.

Line 42 uses entry.content!; this is currently flagged by lint. Tighten the check before returning content.

Minimal fix
     readFileSync: (p: string) => {
       const entry = store.get(p);
-      if (!entry || entry.type !== "file") throw new Error(`ENOENT: ${p}`);
-      return entry.content!;
+      if (!entry || entry.type !== "file" || entry.content === undefined) {
+        throw new Error(`ENOENT: ${p}`);
+      }
+      return entry.content;
     },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/commands/migration-state.test.ts` around lines 39 - 43, The mock
implementation of readFileSync uses a non-null assertion on entry.content
(entry.content!) which violates lint; update readFileSync to explicitly verify
entry.content is defined before returning it (e.g., check if entry.content ===
undefined/null and throw the same ENOENT or a clear error), referencing the mock
readFileSync implementation and the store.get(p) result (entry) so you replace
the non-null assertion with a proper runtime check and return entry.content only
after confirming it exists.

31-33: ⚠️ Potential issue | 🟡 Minor

Lint blocker still present: inline import() type annotation.

Line 32 still uses the forbidden pattern in importOriginal.

Minimal fix
 vi.mock("node:fs", async (importOriginal) => {
-  const original = await importOriginal<typeof import("node:fs")>();
+  const original = (await importOriginal()) as typeof import("node:fs");
   return {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/commands/migration-state.test.ts` around lines 31 - 33, The test
uses an inline import() type annotation in the vi.mock callback (await
importOriginal<typeof import("node:fs")>()), which the linter forbids; fix it by
avoiding inline import() types—either add a top-level type alias via "import
type * as nodeFs from 'node:fs'" and then call await importOriginal<typeof
nodeFs>() or simply call const original = (await importOriginal()) as typeof
import("node:fs");—update the vi.mock callback to use one of these patterns so
the inline import() type is removed while preserving the same runtime behavior.
nemoclaw/src/blueprint/state.test.ts (2)

102-104: ⚠️ Potential issue | 🟡 Minor

Lint blocker still present: void expression in arrow shorthand.

Line 103 should use a block body to satisfy the rule.

Minimal fix
-      expect(() => clearState()).not.toThrow();
+      expect(() => { clearState(); }).not.toThrow();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/blueprint/state.test.ts` around lines 102 - 104, The test uses
an arrow shorthand with a void expression causing a lint error; change the test
from a concise arrow body to a block body so the void expression is not used in
shorthand. Locate the test case using it("does nothing when no file exists",
...) and replace the concise arrow () => clearState() (or the current shorthand)
with a block body that calls clearState() inside (e.g., () => { expect(() =>
clearState()).not.toThrow(); }), ensuring the assertion remains the same and the
lint rule is satisfied.

9-11: ⚠️ Potential issue | 🟡 Minor

Lint blocker still present: inline import() type annotation.

At Line 10, importOriginal<typeof import("node:fs")>() still violates the lint rule and will fail CI.

Minimal fix
 vi.mock("node:fs", async (importOriginal) => {
-  const original = await importOriginal<typeof import("node:fs")>();
+  const original = (await importOriginal()) as typeof import("node:fs");
   return {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/blueprint/state.test.ts` around lines 9 - 11, The inline type
annotation importOriginal<typeof import("node:fs")>() in the vi.mock call
violates the lint rule; fix by declaring a named type alias (e.g., NodeFS =
typeof import("node:fs")) above the mock and then call importOriginal<NodeFS>()
inside vi.mock, so change the type parameter on importOriginal to the alias
referenced by the vi.mock callback; update the importOriginal usage in the
vi.mock block accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@nemoclaw/src/register.test.ts`:
- Around line 48-80: The test mutates the real HOME by writing a config.json
under process.env.HOME; change it to create an isolated temp home (use mkdtemp
or a temp dir) and stub process.env.HOME for the duration of the test so
register(api) reads from the temp location; ensure you seed the
temp/.nemoclaw/config.json with the same payload, call register(api) and assert
on the mocked api.registerProvider, then restore the original process.env.HOME
and clean up the temp directory and any files in the finally block to avoid side
effects. Use the existing createMockApi and register function names to locate
the test setup and teardown points.

---

Duplicate comments:
In `@nemoclaw/src/blueprint/state.test.ts`:
- Around line 102-104: The test uses an arrow shorthand with a void expression
causing a lint error; change the test from a concise arrow body to a block body
so the void expression is not used in shorthand. Locate the test case using
it("does nothing when no file exists", ...) and replace the concise arrow () =>
clearState() (or the current shorthand) with a block body that calls
clearState() inside (e.g., () => { expect(() => clearState()).not.toThrow(); }),
ensuring the assertion remains the same and the lint rule is satisfied.
- Around line 9-11: The inline type annotation importOriginal<typeof
import("node:fs")>() in the vi.mock call violates the lint rule; fix by
declaring a named type alias (e.g., NodeFS = typeof import("node:fs")) above the
mock and then call importOriginal<NodeFS>() inside vi.mock, so change the type
parameter on importOriginal to the alias referenced by the vi.mock callback;
update the importOriginal usage in the vi.mock block accordingly.

In `@nemoclaw/src/commands/migration-state.test.ts`:
- Line 5: Remove the unused import statement `import path from "node:path";`
from the migration-state.test.ts test file (the import is not referenced
anywhere in the tests), leaving other imports and test code intact so lint no
longer flags the unused symbol.
- Around line 39-43: The mock implementation of readFileSync uses a non-null
assertion on entry.content (entry.content!) which violates lint; update
readFileSync to explicitly verify entry.content is defined before returning it
(e.g., check if entry.content === undefined/null and throw the same ENOENT or a
clear error), referencing the mock readFileSync implementation and the
store.get(p) result (entry) so you replace the non-null assertion with a proper
runtime check and return entry.content only after confirming it exists.
- Around line 31-33: The test uses an inline import() type annotation in the
vi.mock callback (await importOriginal<typeof import("node:fs")>()), which the
linter forbids; fix it by avoiding inline import() types—either add a top-level
type alias via "import type * as nodeFs from 'node:fs'" and then call await
importOriginal<typeof nodeFs>() or simply call const original = (await
importOriginal()) as typeof import("node:fs");—update the vi.mock callback to
use one of these patterns so the inline import() type is removed while
preserving the same runtime behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b52f575a-b67a-48c6-be9c-63826b20a6df

📥 Commits

Reviewing files that changed from the base of the PR and between c15a89c and ceeaf92.

📒 Files selected for processing (7)
  • .husky/pre-commit
  • ci/coverage-threshold.json
  • nemoclaw/src/blueprint/state.test.ts
  • nemoclaw/src/commands/migration-state.test.ts
  • nemoclaw/src/commands/slash.test.ts
  • nemoclaw/src/onboard/config.test.ts
  • nemoclaw/src/register.test.ts
✅ Files skipped from review due to trivial changes (2)
  • nemoclaw/src/commands/slash.test.ts
  • nemoclaw/src/onboard/config.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .husky/pre-commit

Comment thread nemoclaw/src/register.test.ts Resolved
cv and others added 3 commits March 21, 2026 11:32
Relax no-unsafe-return and unbound-method rules for test files in the
eslint config — these are unavoidable with vi.mock factories and mock
assertion patterns. Also fix non-null assertions, void arrow returns,
unused imports, and forbidden import() type annotations.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Rewrite the custom model test to mock loadOnboardConfig instead of
writing to the real filesystem with require("node:fs"). Fixes
no-require-imports and no-unsafe-call lint errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Without set -e, a lint-staged failure would be masked if vitest
passes afterward, allowing the commit to succeed despite lint errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
nemoclaw/src/onboard/config.test.ts (2)

112-117: Fragile path duplication—prefer using saveOnboardConfig to seed the store.

Line 114 duplicates the internal path logic from config.ts. If the path computation changes in the source, this test may silently pass or fail unexpectedly. Consider seeding via saveOnboardConfig instead, which guarantees path alignment:

♻️ Suggested refactor
     it("returns parsed config when file exists", () => {
       const config = makeConfig();
-      const configPath = `${process.env.HOME ?? "/tmp"}/.nemoclaw/config.json`;
-      store.set(configPath, JSON.stringify(config));
+      saveOnboardConfig(config);
       expect(loadOnboardConfig()).toEqual(config);
     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/onboard/config.test.ts` around lines 112 - 117, Test currently
duplicates the internal config path logic by computing configPath and writing to
store directly; instead call the module's saveOnboardConfig to seed the storage
so the test stays aligned with loadOnboardConfig's path logic. Update the
"returns parsed config when file exists" test to use makeConfig() to create the
config and then call saveOnboardConfig(config) (or the synchronous equivalent
exported from config.ts) to write it, then call loadOnboardConfig() and assert
equality; remove manual construction of configPath and direct store.set to avoid
fragile duplication.

86-100: Consider adding a test for the default branch returning "Unknown".

The parameterized tests cover all defined EndpointType values, but the source function has a default branch returning "Unknown". While TypeScript exhaustiveness should prevent reaching it with valid types, adding a test (e.g., casting an invalid value) would ensure full branch coverage.

💡 Optional test for default branch
it('returns "Unknown" for unrecognized endpoint type', () => {
  const config = makeConfig({ endpointType: "unknown-type" as EndpointType, providerLabel: undefined });
  expect(describeOnboardProvider(config)).toBe("Unknown");
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw/src/onboard/config.test.ts` around lines 86 - 100, Add a unit test
to cover the function's default branch by calling describeOnboardProvider with a
config built by makeConfig where endpointType is an invalid string cast as
EndpointType (e.g., "unknown-type" as EndpointType) and asserting the result is
"Unknown"; place it alongside the existing parameterized tests in the same suite
so describeOnboardProvider, makeConfig and EndpointType are exercised and the
fallback branch is covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@nemoclaw/src/onboard/config.test.ts`:
- Around line 112-117: Test currently duplicates the internal config path logic
by computing configPath and writing to store directly; instead call the module's
saveOnboardConfig to seed the storage so the test stays aligned with
loadOnboardConfig's path logic. Update the "returns parsed config when file
exists" test to use makeConfig() to create the config and then call
saveOnboardConfig(config) (or the synchronous equivalent exported from
config.ts) to write it, then call loadOnboardConfig() and assert equality;
remove manual construction of configPath and direct store.set to avoid fragile
duplication.
- Around line 86-100: Add a unit test to cover the function's default branch by
calling describeOnboardProvider with a config built by makeConfig where
endpointType is an invalid string cast as EndpointType (e.g., "unknown-type" as
EndpointType) and asserting the result is "Unknown"; place it alongside the
existing parameterized tests in the same suite so describeOnboardProvider,
makeConfig and EndpointType are exercised and the fallback branch is covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 32242e2d-0391-4270-8a88-ae136adcaa3a

📥 Commits

Reviewing files that changed from the base of the PR and between ceeaf92 and bae680d.

📒 Files selected for processing (6)
  • .husky/pre-commit
  • nemoclaw/eslint.config.mjs
  • nemoclaw/src/blueprint/state.test.ts
  • nemoclaw/src/commands/migration-state.test.ts
  • nemoclaw/src/onboard/config.test.ts
  • nemoclaw/src/register.test.ts
✅ Files skipped from review due to trivial changes (2)
  • nemoclaw/eslint.config.mjs
  • nemoclaw/src/blueprint/state.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .husky/pre-commit
  • nemoclaw/src/commands/migration-state.test.ts

@ericksoa
ericksoa merged commit 820f044 into NVIDIA:main Mar 22, 2026
7 checks passed
@cv
cv deleted the test/raise-coverage-thresholds branch March 22, 2026 04:14
Ryuketsukami pushed a commit to Ryuketsukami/NemoClaw that referenced this pull request Mar 24, 2026
…DIA#595)

* test: add comprehensive unit tests and raise coverage thresholds

Add tests for all plugin modules: onboard/config, commands/slash,
blueprint/state, commands/migration-state, and expand register tests
with getPluginConfig and custom model coverage. Raises coverage
thresholds from single digits to 87-98% across all metrics.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* ci: run unit tests in pre-commit hook

Add vitest run to the pre-commit hook alongside lint-staged. Tests
complete in ~250ms so there's no meaningful delay to the workflow.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: address eslint errors in test files

Relax no-unsafe-return and unbound-method rules for test files in the
eslint config — these are unavoidable with vi.mock factories and mock
assertion patterns. Also fix non-null assertions, void arrow returns,
unused imports, and forbidden import() type annotations.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: replace require() with vi.mock in register.test.ts

Rewrite the custom model test to mock loadOnboardConfig instead of
writing to the real filesystem with require("node:fs"). Fixes
no-require-imports and no-unsafe-call lint errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: add set -e to pre-commit hook for fail-fast behavior

Without set -e, a lint-staged failure would be masked if vitest
passes afterward, allowing the commit to succeed despite lint errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
jessesanford pushed a commit to jessesanford/NemoClaw that referenced this pull request Mar 24, 2026
…DIA#595)

* test: add comprehensive unit tests and raise coverage thresholds

Add tests for all plugin modules: onboard/config, commands/slash,
blueprint/state, commands/migration-state, and expand register tests
with getPluginConfig and custom model coverage. Raises coverage
thresholds from single digits to 87-98% across all metrics.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* ci: run unit tests in pre-commit hook

Add vitest run to the pre-commit hook alongside lint-staged. Tests
complete in ~250ms so there's no meaningful delay to the workflow.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: address eslint errors in test files

Relax no-unsafe-return and unbound-method rules for test files in the
eslint config — these are unavoidable with vi.mock factories and mock
assertion patterns. Also fix non-null assertions, void arrow returns,
unused imports, and forbidden import() type annotations.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: replace require() with vi.mock in register.test.ts

Rewrite the custom model test to mock loadOnboardConfig instead of
writing to the real filesystem with require("node:fs"). Fixes
no-require-imports and no-unsafe-call lint errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: add set -e to pre-commit hook for fail-fast behavior

Without set -e, a lint-staged failure would be masked if vitest
passes afterward, allowing the commit to succeed despite lint errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
@wscurran wscurran added the chore Build, CI, dependency, or tooling maintenance label Jun 8, 2026
cv added a commit that referenced this pull request Nov 6, 2026
NemoClaw v1 no longer offers the Deep Agents Code harness
(`nvidia.fabric.langchain.deepagents-code`), and pins a Fabric revision
without its adapter. The LangChain Deep Agents harness
(`nvidia.fabric.langchain.deepagents`) stays as it is.

## Problem

The Deep Agents Code integration is on hold: its Fabric adapter pull
requests, NVIDIA/NeMo-Fabric#571 and #575, are closed. `v1` still pins
Fabric `e5b5ebf2`, which merges both, and builds, catalogs, documents,
and live-tests a `deepagents-code` image.

## Change

What users lose:

- the `deepagents-code` agent image and Bake target, and the harness's
entry in the bundled catalog;
- `examples/fabric-deepagents-code.yaml`;
- the `terminal` interface: apply no longer prints an `Open` command,
and JSON `interfaces` entries no longer carry `launcher` or `signIn:
sandbox_exec`.

The Fabric pin moves to `934ab7eca1ec9ac86a22fd24913f2e9d68637c4a`,
branch `integration/nemoclaw-pin-no-dcode` on `cv/NeMo-Fabric`. It
starts from NVIDIA/NeMo-Fabric `main` at `035bc2fe`, which has #568 and
#569, and merges the head branches of #570, #573, #574, #572, and #576,
in that order.

- #574's branch contains #573's and then removes OpenClaw's Control UI
to keep the two pull requests' diffs apart (`9855259c`). Merging both
dropped the Control UI, so the branch reverts that commit; OpenClaw's
files then match #573's head.
- The one textual conflict, in Fabric's
`docs/integrations/harness/hermes.mdx`, keeps #574's layout and adds
#576's `runtime.keep_state` paragraph.
- The regenerated `image/fabric/catalog.json` differs from `e5b5ebf2`'s
only by the removed adapter and the revision; the other 11 descriptors
are unchanged. OpenClaw's supported version is still 2026.9.34.
- The fixture image the HCL cases name, and the registration names in
`openshift-external-two-providers`, follow the new catalog.

`SignIn::SandboxExec`, the interface `launcher` field, and their CLI
output and tests are removed. Only Deep Agents Code's terminal used
them. Pi's descriptor at the new pin declares no interfaces, and no open
NeMo-Fabric pull request adds one: the two that touch Pi, #604 and #595,
change a health test and the README.

The four model-tuning tests from #14111 keep their check, and now select
Codex instead of Deep Agents Code. Codex accepts only `models.base_url`
among model fields and declares no model extension. Pi isn't used: its
`config.accepts` lists only `models.base_url`, but its model extension
declares `max_tokens`, which planning accepts as a legacy extension
field, so the `maxTokens` cases fail with Pi.

The Docker live suite and `cargo ci live-images` no longer build or pull
a `deepagents-code` image. The verify-yaml-deployment skill drops its
Deep Agents Code agent and terminal feature; verify-fabric-boundary now
carries, in its native-interfaces page, the pseudo-terminal driver its
`tui` check took from that feature. Fern's redirects for the old Deep
Agents Code quickstart pages stay.

## Beyond CI

- Fabric `934ab7ec`: its Rust workspace tests, except `fabric-python`,
which needs `libpython3.12` to link; its Python suite (3,282 passed);
and its TypeScript tests passed. The OpenCode tests failed because the
host has Bun 1.3.14 and the adapter needs 1.4.2 or later. `just
check-adapter-catalog` passed.
- GitHub's `codeload` archives of `934ab7ec` under `NVIDIA/NeMo-Fabric`
and `cv/NeMo-Fabric` have the pinned SHA-256.
- On `linux_arm64`, `cargo images build` built all 11 production agent
images and the reference image, `cargo images qualify` passed for all
12, and `catalog.py` run with the built Claude Code image's interpreter
reproduced the committed catalog. `cargo ci live-docker` passed.
- With the tuning check disabled, the three rejection tests failed;
counting a null extension as set failed the fourth.

Not run: `cargo ci live-kind`, and the images on `linux/amd64`; the
Kubernetes images change only by the Fabric pin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants