The withTimeout test was failing because:
1. The mock made ALL ApiProxy.request calls hang, but the implementation
has 4 sequential requests (1 CRD + 3 pod selectors) each wrapped in
their own withTimeout
2. Using advanceTimersByTimeAsync with hanging promises causes act() to
hang because flushPromises() waits for pending promises
Fix:
- Use mockReturnValueOnce for the CRD call (hanging) and
mockResolvedValueOnce for each pod selector call (resolves immediately)
- Use synchronous advanceTimersByTime() instead of async version
- Simplified test flow: check loading=true initially, advance timers,
then verify crdAvailable=false and loading=false
Fixes PRI-1040
The previous mock used mockRejectedValue which immediately rejects,
so Promise.race resolved before withTimeout's setTimeout fired.
Now we use new Promise(() => {}) to simulate a hanging request
and advance timers to properly exercise the 2s timeout logic.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
- Reformat withTimeout call to single line (prettier)
- Add unit test for CRD timeout behavior (crdAvailable=false when API fails)
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Add withTimeout() helper that wraps ApiProxy.request calls with a 2s timeout.
This prevents the plugin from hanging indefinitely when CRD requests fail
or network issues occur in the E2E environment.
Root cause: ApiProxy.request to non-existent CRDs would hang forever,
causing the Loading Intel GPU data... progressbar to never resolve.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
- Reformat withTimeout call to single line (prettier)
- Add unit test for CRD timeout behavior (crdAvailable=false when API fails)
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Add withTimeout() helper that wraps ApiProxy.request calls with a 2s timeout.
This prevents the plugin from hanging indefinitely when CRD requests fail
or network issues occur in the E2E environment.
Root cause: ApiProxy.request to non-existent CRDs would hang forever,
causing the Loading Intel GPU data... progressbar to never resolve.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
The /node/i regex was too broad and matched both the page heading
'Intel GPU — Nodes' and the empty state 'No GPU Nodes Found',
causing a strict mode violation in Playwright.
Use /intel gpu.*nodes/i to match only the actual page heading,
which contains 'Intel GPU' before 'Nodes'.