Skip to content

tests: unit-test cli/plugins-doctor.js (35 cases — checkBinary, doctorPlugin, doctorAllPlugins)#320

Open
javimosch wants to merge 2 commits into
masterfrom
mago/task-420
Open

tests: unit-test cli/plugins-doctor.js (35 cases — checkBinary, doctorPlugin, doctorAllPlugins)#320
javimosch wants to merge 2 commits into
masterfrom
mago/task-420

Conversation

@javimosch

Copy link
Copy Markdown
Owner

What changed

Added __tests__/plugins-doctor.test.js with 35 unit tests covering all three exports from cli/plugins-doctor.js: checkBinary, doctorPlugin, and doctorAllPlugins.

All direct dependencies are mocked (child_process, plugins-store, plugins-registry, plugin-install-guidance, adapter-schema, plugins-manifest), keeping tests fast and isolated.

Coverage highlights

checkBinary (8 tests)

  • ok:true with trimmed stdout; ok:true fallback to "ok" when stdout empty
  • ENOENT → "not installed"; non-ENOENT spawn error → error.message
  • Non-zero exit → trimmed stderr; non-zero + empty stderr → "exit N"
  • Custom args forwarded; default --version args

doctorPlugin (19 tests)

  • Throws code 92 / type resource_not_found for unknown plugin
  • Plugin missing checks/commands properties → ok:true, counts=0
  • Null/undefined entries in checks skipped by if (check && ...) guard
  • Check missing type field skipped; binary check missing name skipped; non-binary type skipped
  • Binary check ok:true / ok:false propagated to result
  • checks.every undefined guard: asserts every check object carries an explicit boolean ok field — no silent undefined gaps
  • Empty checks array → checks.every returns true (ok:true invariant)
  • Unknown adapter → policy check ok:false; shell without unsafe:true → policy error; shell with unsafe:true → no error, unsafe_commands incremented; non_interactive:false → policy error
  • adapter_counts tallied correctly; (missing) label for undefined adapter
  • install_guidance forwarded from getPluginInstallGuidance

doctorAllPlugins (8 tests)

  • Empty installed list → {ok:true, total_plugins:0, failing_plugins:[]}
  • All passing → ok:true; one failing → ok:false + failing_plugins list
  • Missing-field edge case: plugin entry without name field → doctorPlugin(undefined) propagates throw
  • reports.every ok:false propagation; plugins array length matches installed count

Verification

npx jest __tests__/plugins-doctor.test.js --no-coverage
# 35 passed, 0 failed

Closes #420 (mago task #420)

root and others added 2 commits June 26, 2026 10:53
22 tests covering:
- setMcpServer upsert: insert-new, update-existing, string→url, object
  merge, headers/env, null-value bare entry, throws code-85 on empty name,
  return value, write-to-cache
- dedup via normalizeMcpServers: deduplicate same-name (last-wins), sorted
  alpha output, null/invalid entries stripped, numeric name dropped
- removeMcpServer persistence: removes named entry returns true, cache file
  updated, single-of-many removal
- remove-missing no-op: returns false for absent name, for missing field,
  for missing cache, for empty array

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y, doctorPlugin, and doctorAllPlugins

Tests cover: binary check ok/fail/ENOENT/non-ENOENT paths, default args, null/undefined
check entries skipped by guard, missing type/name in check skipped, unknown adapter
policy check, shell unsafe=true policy, non_interactive=false policy, adapter_counts,
(missing) adapter label, checks.every undefined guard (every check carries explicit ok
boolean), empty-checks ok:true invariant, doctorAllPlugins empty/all-pass/one-fail/
missing-name-field edge cases, reports.every propagation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@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.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

More reviews will be available in 51 minutes and 10 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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 383cedfb-322e-4b7d-b960-423859fe5141

📥 Commits

Reviewing files that changed from the base of the PR and between afda2f7 and 26c898e.

📒 Files selected for processing (2)
  • __tests__/config-mcp.test.js
  • __tests__/plugins-doctor.test.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mago/task-420

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.

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