-
-
Notifications
You must be signed in to change notification settings - Fork 938
test: add unit tests for cli-commands module #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,389 @@ | ||||||||
| /** | ||||||||
| * Unit tests for cli-commands module | ||||||||
| * | ||||||||
| * Tests the CLI command handlers for orchestrator control: | ||||||||
| * orchestrate, orchestrate-status, orchestrate-stop, orchestrate-resume. | ||||||||
| */ | ||||||||
|
|
||||||||
| jest.mock('fs-extra'); | ||||||||
| jest.mock('../../../.aios-core/core/orchestration/master-orchestrator'); | ||||||||
|
|
||||||||
| const fs = require('fs-extra'); | ||||||||
| const MasterOrchestrator = require('../../../.aios-core/core/orchestration/master-orchestrator'); | ||||||||
|
|
||||||||
| const { | ||||||||
| orchestrate, | ||||||||
| orchestrateStatus, | ||||||||
| orchestrateStop, | ||||||||
| orchestrateResume, | ||||||||
| commands, | ||||||||
| } = require('../../../.aios-core/core/orchestration/cli-commands'); | ||||||||
|
|
||||||||
| describe('cli-commands', () => { | ||||||||
| let consoleSpy; | ||||||||
|
|
||||||||
| beforeEach(() => { | ||||||||
| jest.resetAllMocks(); | ||||||||
| consoleSpy = jest.spyOn(console, 'log').mockImplementation(); | ||||||||
| fs.ensureDir.mockResolvedValue(undefined); | ||||||||
| fs.writeJson.mockResolvedValue(undefined); | ||||||||
| }); | ||||||||
|
|
||||||||
| afterEach(() => { | ||||||||
| consoleSpy.mockRestore(); | ||||||||
| }); | ||||||||
|
|
||||||||
| // ============================================================ | ||||||||
| // exports | ||||||||
| // ============================================================ | ||||||||
| describe('exports', () => { | ||||||||
| 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', () => { | ||||||||
| expect(commands.orchestrate).toBe(orchestrate); | ||||||||
| expect(commands['orchestrate-status']).toBe(orchestrateStatus); | ||||||||
| expect(commands['orchestrate-stop']).toBe(orchestrateStop); | ||||||||
| expect(commands['orchestrate-resume']).toBe(orchestrateResume); | ||||||||
| }); | ||||||||
| }); | ||||||||
|
|
||||||||
| // ============================================================ | ||||||||
| // orchestrate | ||||||||
| // ============================================================ | ||||||||
| describe('orchestrate', () => { | ||||||||
| test('returns error when no storyId', async () => { | ||||||||
| const result = await orchestrate(null); | ||||||||
| expect(result.success).toBe(false); | ||||||||
| expect(result.exitCode).toBe(3); | ||||||||
| expect(result.error).toContain('Story ID'); | ||||||||
| }); | ||||||||
|
|
||||||||
| test('returns error for empty storyId', async () => { | ||||||||
| const result = await orchestrate(''); | ||||||||
| expect(result.success).toBe(false); | ||||||||
| expect(result.exitCode).toBe(3); | ||||||||
|
||||||||
| expect(result.exitCode).toBe(3); | |
| expect(result.exitCode).toBe(3); | |
| expect(result.error).toContain('Story ID'); |
Copilot
AI
Feb 18, 2026
There was a problem hiding this comment.
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.
| expect(result.success).toBe(false); |
There was a problem hiding this comment.
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 oftest()for test case definitions. All other test files in tests/core and tests/core/orchestration use theit()pattern (e.g., tests/core/master-orchestrator.test.js, tests/core/orchestration/lock-manager.test.js). Please update alltest()calls toit()to maintain consistency with the established convention.