Skip to content

test: add usage-validation coverage for cli/run.js#350

Draft
javimosch wants to merge 3 commits into
masterfrom
am/am-f17c27-ti4dig
Draft

test: add usage-validation coverage for cli/run.js#350
javimosch wants to merge 3 commits into
masterfrom
am/am-f17c27-ti4dig

Conversation

@javimosch

@javimosch javimosch commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Automated maintenance run by automaintainer.

Focus:


WORK ALREADY IN FLIGHT — do not overlap:
These automaintainer pull requests are already open and awaiting review. Do NOT re-implement, refactor, or restructure the files they touch — pick non-overlapping work, and never recreate a change an open PR already makes. If your objective unavoidably overlaps one of these, choose a different, complementary improvement instead.

Branch: am/am-f17c27-ti4dig

Diff:

__tests__/run-command.test.js | 81 +++++++++++++++++++++++++++++++++++++++++++
 __tests__/skills-mcp.test.js  | 58 +++++++++++++++++++++++++++++++
 2 files changed, 139 insertions(+)

Summary by CodeRabbit

  • Tests
    • Added coverage for invalid one-shot command usage, including missing plugin, resource, or action arguments.
    • Added coverage for generated MCP skill instructions, including YAML formatting, optional workflow details, and custom skill identifiers.

SuperCLI Dev added 3 commits July 13, 2026 15:29
`supercli run <plugin> <resource> <action>` (issue #335) had no dedicated
test file. Cover the three early-return usage-error paths (missing plugin,
missing resource+action, missing action only) so future edits to the
argument-validation logic get regression coverage.
A local `npm install` run to verify the previous commit's tests rewrote
package-lock.json because package.json currently declares no dependencies
(a pre-existing regression from c10ee2b, out of scope here). Restore the
lockfile to its prior committed state.
cli/skills-mcp.js (buildMcpServersUsageSkillMarkdown) had no test file even
though it's a pure, easily-tested function. Cover the default frontmatter
shape, the showDag toggle, and the custom skillId option.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@javimosch javimosch marked this pull request as draft July 13, 2026 15:31
@javimosch

Copy link
Copy Markdown
Owner Author

🏛️ Automaintainer architecture review: VIOLATION

The new files live at top-level __tests__/ and reference ../cli/run and ../cli/skills-mcp, none of which are scoped under a plugin/ directory, so this appears to add code outside the permitted

The change passed verification, but it violates this repo's architecture rules. The PR was set to draft and auto-merge is held — review before marking it ready.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Jest tests for supercli run usage validation and buildMcpServersUsageSkillMarkdown, covering error handling, output suppression, YAML frontmatter, instruction content, DAG rendering, and skill ID propagation.

Changes

Test coverage

Layer / File(s) Summary
Run-command validation tests
__tests__/run-command.test.js
Mocks the executor and verifies invalid positional arguments return code 85 usage errors without invoking normal output.
MCP skill markdown tests
__tests__/skills-mcp.test.js
Verifies frontmatter rendering, instruction content, optional DAG output, and skillId command propagation.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change by adding usage-validation test coverage for cli/run.js.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch am/am-f17c27-ti4dig

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.

@javimosch

Copy link
Copy Markdown
Owner Author

Automaintainer Review Verdict: APPROVED — Both test files are well-structured, focused on early-return validation paths, and follow the same __tests__/ placement convention used by all other open automaintainer PRs in this batch (#345#349). The architecture-violation concern raised in a prior comment is overruled: placing Jest tests in the top-level __tests__/ directory is the project's own established pattern. The executor mock in run-command.test.js is appropriate to avoid loading the native vm2 sandbox. CI is pending, not failing. No production code is changed.

@javimosch

Copy link
Copy Markdown
Owner Author

Approved by automaintainer review team — ready for human merge

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

🧹 Nitpick comments (1)
__tests__/run-command.test.js (1)

13-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Verify the mocked execute is not called in each test.

The execute mock is set up but never asserted. Adding expect(execute).not.toHaveBeenCalled() to each test would confirm the usage-validation paths return before any execution attempt, closing a gap where a missing early-return could go undetected.

♻️ Proposed addition
 jest.mock("../cli/executor", () => ({ execute: jest.fn() }));

-const { handleRunCommand } = require("../cli/run");
+const { handleRunCommand } = require("../cli/run");
+const { execute } = require("../cli/executor");
+
+afterEach(() => {
+  jest.clearAllMocks();
+});

Then add to each test, after the existing expect(output).not.toHaveBeenCalled() line:

     expect(output).not.toHaveBeenCalled();
+    expect(execute).not.toHaveBeenCalled();
     expect(outputError).toHaveBeenCalledWith(
🤖 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 `@__tests__/run-command.test.js` around lines 13 - 15, Update every test in
__tests__/run-command.test.js covering usage validation to assert the mocked
execute function was not called, adding the assertion after the existing
output-not-called expectation. Import or reference the execute mock from the
../cli/executor mock and preserve the current test behavior.
🤖 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 `@__tests__/run-command.test.js`:
- Around line 13-15: Update every test in __tests__/run-command.test.js covering
usage validation to assert the mocked execute function was not called, adding
the assertion after the existing output-not-called expectation. Import or
reference the execute mock from the ../cli/executor mock and preserve the
current test behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5d945660-9788-4aee-8341-0728aa9921f4

📥 Commits

Reviewing files that changed from the base of the PR and between 667e0d7 and 264b035.

📒 Files selected for processing (2)
  • __tests__/run-command.test.js
  • __tests__/skills-mcp.test.js

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.

1 participant