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:
Lukas May
2026-03-06 22:10:15 +01:00
parent b6a01e5748
commit 30dcb8340a

View File

@@ -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();
});
});