Skip to content

Commit 689fc83

Browse files
committed
test(face-clusters): cover status-request rejection in useGlobalRecluster
Addresses a CodeRabbit review comment: the suite only covered the {success: false, status: 'error'} payload path, not a rejected status request (e.g. 404 for a missing/aged-out task ID).
1 parent a422cc2 commit 689fc83

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

frontend/src/hooks/__tests__/useGlobalRecluster.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,29 @@ describe('useGlobalRecluster', () => {
126126
expect(mockStatus).not.toHaveBeenCalled();
127127
});
128128

129+
test('sets an error when the status request itself rejects (e.g. 404 for an aged-out task)', async () => {
130+
mockStart.mockResolvedValue(startOk);
131+
const notFound = {
132+
isAxiosError: true,
133+
message: 'Request failed with status code 404',
134+
code: 'ERR_BAD_REQUEST',
135+
response: { status: 404, data: {} },
136+
};
137+
mockStatus.mockRejectedValue(notFound);
138+
139+
const { result, invalidateSpy } = setup();
140+
act(() => {
141+
result.current.trigger();
142+
});
143+
await flush();
144+
145+
expect(result.current.isError).toBe(true);
146+
expect(result.current.errorMessage).toBe(
147+
'ERR_BAD_REQUEST: Request failed with status code 404',
148+
);
149+
expect(invalidateSpy).not.toHaveBeenCalled();
150+
});
151+
129152
test('stops polling after unmount', async () => {
130153
mockStart.mockResolvedValue(startOk);
131154
mockStatus.mockResolvedValue(running);

0 commit comments

Comments
 (0)