Skip to content

test: add unit tests for cli-commands module#246

Closed
nikolasdehor wants to merge 1 commit intoSynkraAI:mainfrom
nikolasdehor:test/cli-commands-coverage
Closed

test: add unit tests for cli-commands module#246
nikolasdehor wants to merge 1 commit intoSynkraAI:mainfrom
nikolasdehor:test/cli-commands-coverage

Conversation

@nikolasdehor
Copy link
Contributor

Summary

Closes #245

Add 24 unit tests for the CLI command handlers in .aios-core/core/orchestration/cli-commands.js (580 lines, previously 0% coverage).

Test Coverage

Command Tests Key Scenarios
exports 2 Functions, commands map
orchestrate 8 No storyId, full pipeline, epic flag, blocked, failed, dry run, exception
orchestrate-status 4 No storyId, missing state, display, read error
orchestrate-stop 4 No storyId, missing state, stop update, write error
orchestrate-resume 6 No storyId, missing state, completed, current epic, next epic, exception

Testing Approach

  • Mocks fs-extra and master-orchestrator for full isolation
  • Suppresses console output via jest.spyOn(console, 'log')
  • Tests all exit codes: 0 (success), 1 (error), 2 (blocked/completed), 3 (validation)
  • Validates state transitions: in_progress → stopped → resumed

All 24 tests passing.

Add 24 tests covering orchestrator CLI commands:
- orchestrate: full pipeline, epic flag, dry run, blocked/failed results
- orchestrate-status: state display, missing state, read errors
- orchestrate-stop: state update to stopped, missing state, write errors
- orchestrate-resume: resume from current/next epic, completed check
- All commands validate storyId requirement
Copilot AI review requested due to automatic review settings February 18, 2026 19:26
@vercel
Copy link

vercel bot commented Feb 18, 2026

@nikolasdehor is attempting to deploy a commit to the Pedro Valério Lopez's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

Warning

Rate limit exceeded

@nikolasdehor has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 53 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive unit test coverage for the CLI commands module that handles orchestrator control operations. The module was previously untested (0% coverage for 580 lines).

Changes:

  • Adds 24 unit tests covering all four CLI command handlers (orchestrate, orchestrate-status, orchestrate-stop, orchestrate-resume)
  • Tests validation, success/error scenarios, state transitions, and exit codes
  • Implements proper mocking of fs-extra and master-orchestrator dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +40 to +47
test('exports all command functions', () => {
expect(typeof orchestrate).toBe('function');
expect(typeof orchestrateStatus).toBe('function');
expect(typeof orchestrateStop).toBe('function');
expect(typeof orchestrateResume).toBe('function');
});

test('exports commands map', () => {
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codebase consistently uses it() instead of test() for test case definitions. All other test files in tests/core and tests/core/orchestration use the it() pattern (e.g., tests/core/master-orchestrator.test.js, tests/core/orchestration/lock-manager.test.js). Please update all test() calls to it() to maintain consistency with the established convention.

Suggested change
test('exports all command functions', () => {
expect(typeof orchestrate).toBe('function');
expect(typeof orchestrateStatus).toBe('function');
expect(typeof orchestrateStop).toBe('function');
expect(typeof orchestrateResume).toBe('function');
});
test('exports commands map', () => {
it('exports all command functions', () => {
expect(typeof orchestrate).toBe('function');
expect(typeof orchestrateStatus).toBe('function');
expect(typeof orchestrateStop).toBe('function');
expect(typeof orchestrateResume).toBe('function');
});
it('exports commands map', () => {

Copilot uses AI. Check for mistakes.
MasterOrchestrator.mockImplementation(() => mockOrchestrator);

const result = await orchestrate('story-1', { projectRoot: '/p' });

Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with other test assertions, consider also checking that result.success is false when testing the failed result scenario. Other similar tests check both exitCode and success.

Suggested change
expect(result.success).toBe(false);

Copilot uses AI. Check for mistakes.
test('returns error for empty storyId', async () => {
const result = await orchestrate('');
expect(result.success).toBe(false);
expect(result.exitCode).toBe(3);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the test on line 59-64, consider also checking result.error to ensure it contains an appropriate message about Story ID being required.

Suggested change
expect(result.exitCode).toBe(3);
expect(result.exitCode).toBe(3);
expect(result.error).toContain('Story ID');

Copilot uses AI. Check for mistakes.
@nikolasdehor
Copy link
Contributor Author

Consolidated into #426

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.

Add unit tests for cli-commands module

2 participants