test(agent): add MockAgentManager mode tests
- Test default execute mode on spawn - Test discuss mode with context_complete scenario - Test breakdown mode with breakdown_complete scenario - Verify stopped event reasons for each mode
This commit is contained in:
@@ -595,6 +595,98 @@ describe('MockAgentManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ===========================================================================
|
||||
// Agent modes (execute, discuss, breakdown)
|
||||
// ===========================================================================
|
||||
|
||||
describe('agent modes', () => {
|
||||
it('should spawn agent with default execute mode', async () => {
|
||||
const agent = await manager.spawn({
|
||||
name: 'exec-agent',
|
||||
taskId: 't1',
|
||||
prompt: 'test',
|
||||
});
|
||||
expect(agent.mode).toBe('execute');
|
||||
});
|
||||
|
||||
it('should spawn agent in discuss mode', async () => {
|
||||
manager.setScenario('discuss-agent', {
|
||||
status: 'context_complete',
|
||||
delay: 0,
|
||||
decisions: [{ topic: 'Auth', decision: 'JWT', reason: 'Standard' }],
|
||||
summary: 'Auth discussion complete',
|
||||
});
|
||||
|
||||
const agent = await manager.spawn({
|
||||
name: 'discuss-agent',
|
||||
taskId: 't1',
|
||||
prompt: 'discuss auth',
|
||||
mode: 'discuss',
|
||||
});
|
||||
|
||||
expect(agent.mode).toBe('discuss');
|
||||
});
|
||||
|
||||
it('should spawn agent in breakdown mode', async () => {
|
||||
manager.setScenario('breakdown-agent', {
|
||||
status: 'breakdown_complete',
|
||||
delay: 0,
|
||||
phases: [
|
||||
{ number: 1, name: 'Foundation', description: 'Core setup' },
|
||||
{ number: 2, name: 'Features', description: 'Main features' },
|
||||
],
|
||||
});
|
||||
|
||||
const agent = await manager.spawn({
|
||||
name: 'breakdown-agent',
|
||||
taskId: 't1',
|
||||
prompt: 'breakdown work',
|
||||
mode: 'breakdown',
|
||||
});
|
||||
|
||||
expect(agent.mode).toBe('breakdown');
|
||||
});
|
||||
|
||||
it('should emit stopped event with context_complete reason', async () => {
|
||||
manager.setScenario('discuss-done', {
|
||||
status: 'context_complete',
|
||||
delay: 0,
|
||||
decisions: [],
|
||||
summary: 'Done',
|
||||
});
|
||||
|
||||
await manager.spawn({
|
||||
name: 'discuss-done',
|
||||
taskId: 't1',
|
||||
prompt: 'test',
|
||||
mode: 'discuss',
|
||||
});
|
||||
await vi.runAllTimersAsync();
|
||||
|
||||
const stopped = eventBus.emittedEvents.find((e) => e.type === 'agent:stopped');
|
||||
expect(stopped?.payload.reason).toBe('context_complete');
|
||||
});
|
||||
|
||||
it('should emit stopped event with breakdown_complete reason', async () => {
|
||||
manager.setScenario('breakdown-done', {
|
||||
status: 'breakdown_complete',
|
||||
delay: 0,
|
||||
phases: [],
|
||||
});
|
||||
|
||||
await manager.spawn({
|
||||
name: 'breakdown-done',
|
||||
taskId: 't1',
|
||||
prompt: 'test',
|
||||
mode: 'breakdown',
|
||||
});
|
||||
await vi.runAllTimersAsync();
|
||||
|
||||
const stopped = eventBus.emittedEvents.find((e) => e.type === 'agent:stopped');
|
||||
expect(stopped?.payload.reason).toBe('breakdown_complete');
|
||||
});
|
||||
});
|
||||
|
||||
// ===========================================================================
|
||||
// Structured question data (new schema tests)
|
||||
// ===========================================================================
|
||||
|
||||
Reference in New Issue
Block a user