Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(test): pre-handle rejected promises in test mocks

Steven Enamakelef105e5de68a
diff --git a/app/src/features/conversations/aui/PlanReviewPart.test.tsx b/app/src/features/conversations/aui/PlanReviewPart.test.tsx
index ec08b9b04e..4ec769baa7 100644
--- a/app/src/features/conversations/aui/PlanReviewPart.test.tsx
+++ b/app/src/features/conversations/aui/PlanReviewPart.test.tsx
@@ -92,7 +92,9 @@ describe('PlanReviewCardCore', () => {
});
it('shows an error and does not clear the review when the RPC fails', async () => {
- vi.mocked(callCoreRpc).mockImplementation(() => Promise.reject(new Error('boom')));
+ const rejection = Promise.reject(new Error('boom'));
+ rejection.catch(() => {}); // pre-handle so vitest doesn't flag it unhandled
+ vi.mocked(callCoreRpc).mockReturnValue(rejection);
const store = renderCard();
await userEvent.click(screen.getByText('Approve & run'));
diff --git a/app/src/features/conversations/aui/useThreadGoal.test.tsx b/app/src/features/conversations/aui/useThreadGoal.test.tsx
index b8682b27f9..dfd912b934 100644
--- a/app/src/features/conversations/aui/useThreadGoal.test.tsx
+++ b/app/src/features/conversations/aui/useThreadGoal.test.tsx
@@ -58,7 +58,9 @@ describe('useLoadThreadGoal', () => {
});
it('leaves the slice untouched when the RPC fails', async () => {
- vi.mocked(threadApi.getGoal).mockImplementation(() => Promise.reject(new Error('no such method')));
+ const rejection = Promise.reject(new Error('no such method'));
+ rejection.catch(() => {}); // pre-handle so vitest doesn't flag it unhandled
+ vi.mocked(threadApi.getGoal).mockReturnValue(rejection);
const { store, wrapper } = setup();
renderHook(() => useLoadThreadGoal('t1'), { wrapper });
diff --git a/app/src/features/conversations/aui/useThreadTodos.test.tsx b/app/src/features/conversations/aui/useThreadTodos.test.tsx
index 55670f61c3..e73facdbb6 100644
--- a/app/src/features/conversations/aui/useThreadTodos.test.tsx
+++ b/app/src/features/conversations/aui/useThreadTodos.test.tsx
@@ -51,7 +51,9 @@ describe('useLoadThreadTodos', () => {
});
it('leaves the slice untouched when the RPC fails (older core)', async () => {
- vi.mocked(threadApi.getTodos).mockImplementation(() => Promise.reject(new Error('no such method')));
+ const rejection = Promise.reject(new Error('no such method'));
+ rejection.catch(() => {}); // pre-handle so vitest doesn't flag it unhandled
+ vi.mocked(threadApi.getTodos).mockReturnValue(rejection);
const { store, wrapper } = setup();
renderHook(() => useLoadThreadTodos('t1'), { wrapper });