test: add error resilience case to orchestrator quality review hook tests
Adds the fourth test case from the spec: when shouldRunQualityReview throws, the orchestrator must not crash, must log a warning (verified implicitly by the catch block), and must still call scheduleDispatch() so dispatch continuity is maintained. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -481,4 +481,21 @@ describe('handleAgentStopped — quality review integration', () => {
|
||||
expect(shouldRunQualityReview).not.toHaveBeenCalled();
|
||||
expect(mocks.dispatchManager.completeTask).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not crash and still calls scheduleDispatch when shouldRunQualityReview throws', async () => {
|
||||
vi.mocked(shouldRunQualityReview).mockRejectedValue(new Error('quality review check failed'));
|
||||
|
||||
createOrchestrator(mocks);
|
||||
|
||||
mocks.eventBus.emit({
|
||||
type: 'agent:stopped',
|
||||
timestamp: new Date(),
|
||||
payload: { taskId: 't1', reason: 'task_complete', agentId: 'a1' },
|
||||
});
|
||||
|
||||
// scheduleDispatch() must still run — verifiable via dispatchNext being called in the dispatch cycle
|
||||
await vi.waitFor(() => expect(mocks.dispatchManager.dispatchNext).toHaveBeenCalled());
|
||||
// completeTask is not called from the catch block — error is swallowed after logging a warning
|
||||
expect(mocks.dispatchManager.completeTask).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user