Skip to content

test(doctor): add doctor module coverage - #686

Merged
rafaelscosta merged 1 commit into
mainfrom
devops/pr-596-doctor-coverage-current-20260507
May 8, 2026
Merged

test(doctor): add doctor module coverage#686
rafaelscosta merged 1 commit into
mainfrom
devops/pr-596-doctor-coverage-current-20260507

Conversation

@rafaelscosta

@rafaelscosta rafaelscosta commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Supersedes #596 by porting the doctor module coverage onto current main and updating the ide-sync assertions for the current skills-first contract.

Adds coverage for:

  • modular doctor checks
  • doctor fix handler
  • doctor orchestrator/index behavior

Validation

  • npm test -- tests/core/doctor --runInBand --forceExit
  • npm run typecheck
  • npm run lint (passes with existing warnings)
  • git diff --check origin/main...HEAD

Part of #52.

Summary by CodeRabbit

  • Tests
    • Added focused test coverage for diagnostic health checks (including node-version, config, rules, agent memory, entity registry, git/hooks, command/skill counts, IDE sync) and summary/formatting behaviors.
    • Added tests for the orchestrator that validate output formats, versioning, summaries, and status aggregation.
    • Added tests for automated fix handling, covering dry-run vs real fixes and sequencing of fix actions.

@github-actions github-actions Bot added area: agents Agent system related area: workflows Workflow system related squad mcp type: test Test coverage and quality area: core Core framework (.aios-core/core/) area: installer Installer and setup (packages/installer/) area: synapse SYNAPSE context engine area: cli CLI tools (bin/, packages/aios-pro-cli/) area: pro Pro features (pro/) area: health-check Health check system area: docs Documentation (docs/) area: devops CI/CD, GitHub Actions (.github/) labels May 8, 2026
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7d6a6a3f-3040-414f-bd9a-a3c65f8821a1

📥 Commits

Reviewing files that changed from the base of the PR and between 54eab23 and db2fb44.

📒 Files selected for processing (3)
  • tests/core/doctor/doctor-checks.test.js
  • tests/core/doctor/doctor-index.test.js
  • tests/core/doctor/fix-handler.test.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/core/doctor/doctor-index.test.js
  • tests/core/doctor/fix-handler.test.js

Walkthrough

This pull request adds comprehensive Jest test suites for the Doctor diagnostic system. Three test files validate individual health checks (covering Node version, config files, rules, agents, git hooks, skills, commands, and IDE sync), the orchestration layer (versioning, output formatting, fix modes), and the auto-fix handler (status filtering, check-specific remediation, dry-run behavior). All tests use isolated temporary directories for filesystem operations and make no changes to public APIs.

Changes

Doctor System Tests

Layer / File(s) Summary
Test Infrastructure
tests/core/doctor/doctor-checks.test.js, tests/core/doctor/doctor-index.test.js, tests/core/doctor/fix-handler.test.js
Shared temp directory utilities, makeContext(projectRoot) factory, and Jest lifecycle hooks (beforeEach/afterEach) for isolated test execution.
Individual Diagnostic Checks
tests/core/doctor/doctor-checks.test.js
11 check suites validate PASS/WARN/FAIL outcomes: node-version, core-config, rules-files, agent-memory, entity-registry, git-hooks, skills-count, commands-count, hooks-claude-count, settings-json, ide-sync. Filesystem fixtures and mtime/threshold assertions drive expected statuses and messages.
Orchestrator and Output Formatting
tests/core/doctor/doctor-index.test.js
Tests runDoctorChecks export and behavior: DOCTOR_VERSION 2.0.0, returned data shape (version, timestamp, summary, checks, fixResults), text/JSON formatting, fix/dryRun/quiet modes, default projectRoot behavior, expected check presence, resilience on empty directories, and summary counter consistency.
Fix Handler and Auto-Remediation
tests/core/doctor/fix-handler.test.js
Tests applyFixes filtering PASS results, unknown check handling (applied: false with "No auto-fix available"), dry-run semantics ([DRY RUN] messages), and specific fixers: rules-files copies missing rules, agent-memory creates MEMORY.md stubs, claude-md redirects to install, and settings-json fixer outcomes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

type: test, area: core, area: health-check, area: devops

Suggested reviewers

  • oalanicolas
  • Pedrovaleriolopez
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "test(doctor): add doctor module coverage" directly and clearly summarizes the main change: comprehensive test coverage additions for the doctor module with 71 tests across checks, fix handler, and orchestrator.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch devops/pr-596-doctor-coverage-current-20260507

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.

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

📊 Coverage Report

Coverage report not available

📈 Full coverage report available in Codecov


Generated by PR Automation (Story 6.1)

@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: 4

🧹 Nitpick comments (1)
tests/core/doctor/fix-handler.test.js (1)

160-175: ⚡ Quick win

Strengthen settings-json fixer assertions.

This test only checks fixResults[0].check, so it can pass even if the fixer no longer applies/returns expected behavior. Add assertions on applied and/or expected message pattern (similar to other fixer tests).

🤖 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/core/doctor/fix-handler.test.js` around lines 160 - 175, The test
currently only asserts fixResults[0].check and can pass even if the fixer didn't
actually apply; update the test that calls applyFixes(results, context) to also
assert expected behavior for the 'settings-json' fixer by checking either
fixResults[0].applied === true (when generator ran) or that
fixResults[0].message matches the expected install/force pattern used by other
fixer tests (e.g., contains "install --force" or similar); ensure you reference
the same result object (fixResults[0]) and keep the existing check assertion for
'settings-json'.
🤖 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 `@tests/core/doctor/doctor-checks.test.js`:
- Around line 45-56: The test "deve retornar PASS quando Node >= 18" currently
only asserts when major >= 18, allowing a silent pass on older Node versions;
update the test around the run() call and major variable to include an else
branch that asserts the expected behavior when major < 18 (e.g. check
result.status is the failing value, result.check equals 'node-version',
result.message mentions Node.js, and that result.fixCommand is set/not null), or
replace the conditional with explicit assertions for both branches so the test
always validates the result variable.
- Line 39: The test uses relative requires for Doctor check modules (e.g.,
destructuring { run, name } from node-version) which violates the
absolute-import rule; replace each relative require with the project's absolute
import for the corresponding Doctor check module and update all other
occurrences in this file (the imports that provide run and name for each check).
Locate the require calls that import check modules (they destructure run and
name) and change them to use the project's absolute import style consistently
for every check import mentioned in the review.

In `@tests/core/doctor/doctor-index.test.js`:
- Line 16: The test imports runDoctorChecks and DOCTOR_VERSION via a relative
path into .aiox-core; change that require to the repo's absolute import for the
core doctor module (e.g., import the module from the absolute package name such
as aiox-core/core/doctor) so runDoctorChecks and DOCTOR_VERSION are loaded via
the project's absolute import convention instead of
"../../../.aiox-core/core/doctor".

In `@tests/core/doctor/fix-handler.test.js`:
- Around line 16-17: The test uses relative paths to import applyFixes and
EXPECTED_RULES; replace those relative requires with the project's absolute
module paths (importing the same symbols applyFixes and EXPECTED_RULES) so the
test follows the repository's absolute import convention—update the require
calls that reference '../../../.aiox-core/core/doctor/fix-handler' and
'../../../.aiox-core/core/doctor/checks/rules-files' to their equivalent
absolute import module specifiers while keeping the imported identifiers
applyFixes and EXPECTED_RULES unchanged.

---

Nitpick comments:
In `@tests/core/doctor/fix-handler.test.js`:
- Around line 160-175: The test currently only asserts fixResults[0].check and
can pass even if the fixer didn't actually apply; update the test that calls
applyFixes(results, context) to also assert expected behavior for the
'settings-json' fixer by checking either fixResults[0].applied === true (when
generator ran) or that fixResults[0].message matches the expected install/force
pattern used by other fixer tests (e.g., contains "install --force" or similar);
ensure you reference the same result object (fixResults[0]) and keep the
existing check assertion for 'settings-json'.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6c23d5e2-833d-467a-a4e5-85fe0f996c2e

📥 Commits

Reviewing files that changed from the base of the PR and between 1c3ba4e and 54eab23.

📒 Files selected for processing (3)
  • tests/core/doctor/doctor-checks.test.js
  • tests/core/doctor/doctor-index.test.js
  • tests/core/doctor/fix-handler.test.js

Comment thread tests/core/doctor/doctor-checks.test.js Outdated
Comment thread tests/core/doctor/doctor-checks.test.js
Comment thread tests/core/doctor/doctor-index.test.js Outdated
Comment thread tests/core/doctor/fix-handler.test.js Outdated
@vercel

vercel Bot commented May 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aiox-core Ready Ready Preview, Comment May 8, 2026 1:06am

Request Review

…rchestrator (#52)

Cobertura completa dos 10 checks modulares (node-version, core-config,
rules-files, agent-memory, entity-registry, git-hooks, skills-count,
commands-count, hooks-claude-count, settings-json, ide-sync), do
fix-handler (dry-run, apply, erros) e do orchestrator (json, quiet, fix).
@rafaelscosta
rafaelscosta force-pushed the devops/pr-596-doctor-coverage-current-20260507 branch from 54eab23 to db2fb44 Compare May 8, 2026 01:06
@rafaelscosta
rafaelscosta merged commit 6b4b241 into main May 8, 2026
40 checks passed
@rafaelscosta
rafaelscosta deleted the devops/pr-596-doctor-coverage-current-20260507 branch May 8, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: agents Agent system related area: cli CLI tools (bin/, packages/aios-pro-cli/) area: core Core framework (.aios-core/core/) area: devops CI/CD, GitHub Actions (.github/) area: docs Documentation (docs/) area: health-check Health check system area: installer Installer and setup (packages/installer/) area: pro Pro features (pro/) area: synapse SYNAPSE context engine area: workflows Workflow system related mcp squad type: test Test coverage and quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants