feat(08.1-02): add TestHarness convenience methods for scenarios
- Add setAgentDone() for done status scenarios - Add setAgentQuestion() for question status scenarios - Add setAgentError() for unrecoverable_error scenarios - Add getPendingQuestion() to harness interface - Import PendingQuestion type from agent/types
This commit is contained in:
@@ -12,6 +12,7 @@ import type { EventBus, DomainEvent } from '../events/types.js';
|
||||
import { EventEmitterBus } from '../events/bus.js';
|
||||
import type { AgentManager } from '../agent/types.js';
|
||||
import { MockAgentManager, type MockAgentScenario } from '../agent/mock-manager.js';
|
||||
import type { PendingQuestion } from '../agent/types.js';
|
||||
import type { WorktreeManager, Worktree, WorktreeDiff, MergeResult } from '../git/types.js';
|
||||
import type { DispatchManager } from '../dispatch/types.js';
|
||||
import { DefaultDispatchManager } from '../dispatch/manager.js';
|
||||
@@ -190,6 +191,30 @@ export interface TestHarness {
|
||||
*/
|
||||
setAgentScenario(agentName: string, scenario: MockAgentScenario): void;
|
||||
|
||||
/**
|
||||
* Convenience: Set agent to complete with done status.
|
||||
*/
|
||||
setAgentDone(agentName: string, result?: string): void;
|
||||
|
||||
/**
|
||||
* Convenience: Set agent to ask a question.
|
||||
*/
|
||||
setAgentQuestion(
|
||||
agentName: string,
|
||||
question: string,
|
||||
options?: Array<{ label: string; description?: string }>
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Convenience: Set agent to fail with unrecoverable error.
|
||||
*/
|
||||
setAgentError(agentName: string, error: string): void;
|
||||
|
||||
/**
|
||||
* Get pending question for an agent.
|
||||
*/
|
||||
getPendingQuestion(agentId: string): Promise<PendingQuestion | null>;
|
||||
|
||||
/**
|
||||
* Get events by type.
|
||||
*/
|
||||
@@ -276,6 +301,24 @@ export function createTestHarness(): TestHarness {
|
||||
agentManager.setScenario(agentName, scenario);
|
||||
},
|
||||
|
||||
setAgentDone: (agentName: string, result?: string) => {
|
||||
agentManager.setScenario(agentName, { status: 'done', result });
|
||||
},
|
||||
|
||||
setAgentQuestion: (
|
||||
agentName: string,
|
||||
question: string,
|
||||
options?: Array<{ label: string; description?: string }>
|
||||
) => {
|
||||
agentManager.setScenario(agentName, { status: 'question', question, options });
|
||||
},
|
||||
|
||||
setAgentError: (agentName: string, error: string) => {
|
||||
agentManager.setScenario(agentName, { status: 'unrecoverable_error', error });
|
||||
},
|
||||
|
||||
getPendingQuestion: (agentId: string) => agentManager.getPendingQuestion(agentId),
|
||||
|
||||
getEventsByType: (type: string) => eventBus.getEventsByType(type),
|
||||
|
||||
clearEvents: () => eventBus.clearEvents(),
|
||||
|
||||
Reference in New Issue
Block a user