fix: add request timeout wrapper to prevent E2E test hang #40

Closed
privilegedescalation-engineer[bot] wants to merge 10 commits from fix/e2e-timeout-hang into main
Showing only changes of commit 3aa9c15e80 - Show all commits
+11 -13
View File
@@ -155,25 +155,23 @@ describe('IntelGpuDataProvider', () => {
it('treats a hanging CRD request as unavailable after 2s timeout', async () => {
vi.useFakeTimers();
const nodeWrapper = { jsonData: {} };
vi.mocked(K8s.ResourceClasses.Node.useList).mockReturnValue([
[nodeWrapper],
null,
] as any);
vi.mocked(K8s.ResourceClasses.Pod.useList).mockReturnValue([
[nodeWrapper],
null,
] as any);
vi.mocked(ApiProxy.request).mockRejectedValue(
new Error('Request timed out after 2000ms')
);
vi.mocked(K8s.ResourceClasses.Node.useList).mockReturnValue([[nodeWrapper], null] as any);
vi.mocked(K8s.ResourceClasses.Pod.useList).mockReturnValue([[nodeWrapper], null] as any);
vi.mocked(ApiProxy.request).mockReturnValue(new Promise(() => {}));
const { result } = renderHook(() => useIntelGpuContext(), { wrapper: Wrapper });
await act(async () => {
await vi.advanceTimersByTimeAsync(100);
await vi.advanceTimersByTimeAsync(1999);
});
expect(result.current.loading).toBe(false);
expect(result.current.loading).toBe(true);
await act(async () => {
await vi.advanceTimersByTimeAsync(200);
});
await waitFor(() => expect(result.current.loading).toBe(false));
expect(result.current.crdAvailable).toBe(false);
vi.useRealTimers();
});
});