bito-code-review[bot] commented on code in PR #44144:
URL: https://github.com/apache/superset/pull/44144#discussion_r4039520093


##########
superset-frontend/src/dashboard/hooks/useDownloadScreenshot.test.ts:
##########
@@ -206,6 +220,70 @@ test('logs cacheKey, dashboardId, and format when retries 
are exhausted', async
   jest.useRealTimers();
 });
 
+test('stops polling immediately when screenshot generation reaches Error', 
async () => {
+  jest.useFakeTimers();
+  mockPostSuccess(720);
+  (SupersetClient.get as jest.Mock).mockRejectedValue(terminalError());
+
+  await triggerDownload();
+
+  expect(SupersetClient.get).toHaveBeenCalledTimes(1);
+  expect(logging.error).toHaveBeenCalledWith('Screenshot generation failed', {
+    cacheKey: CACHE_KEY,
+    dashboardId: DASHBOARD_ID,
+    format: DownloadScreenshotFormat.PNG,
+  });
+
+  await act(async () => {
+    jest.advanceTimersByTime(RETRY_INTERVAL * 5);
+    await flushPromises();
+  });
+
+  expect(SupersetClient.get).toHaveBeenCalledTimes(1);
+
+  jest.clearAllTimers();
+  jest.useRealTimers();
+});
+
+test('uses the server task budget beyond the previous 90-second limit', async 
() => {
+  jest.useFakeTimers();
+  mockPostSuccess(120);
+  let getCalls = 0;
+  (SupersetClient.get as jest.Mock).mockImplementation(() => {
+    getCalls += 1;
+    return getCalls > 31
+      ? Promise.resolve(createResponse())
+      : Promise.reject(notReadyError());
+  });
+  Object.assign(window.URL, {
+    createObjectURL: jest.fn(() => 'blob:mock'),
+    revokeObjectURL: jest.fn(),
+  });

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Global URL stub never restored</b></div>
   <div id="fix">
   
   `Object.assign(window.URL, ...)` permanently overwrites 
`createObjectURL`/`revokeObjectURL` jsdom globals; nothing restores them (`grep 
-c afterEach` in this file = 0), so the jest.fn stubs leak into every later 
test in the file, masking calls to the real implementations. The sibling test 
at line 173 has the same leak, but this diff adds another instance. Per BITO.md 
rule 14435, save originals in `beforeEach` and restore in `afterEach`.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #20778e</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to