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


##########
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:
   <!-- Bito Reply -->
   The implementation of snapshotting and restoring the URL method property 
descriptors in the test suite correctly addresses the issue of jsdom global 
leakage. This approach ensures that the test environment remains isolated and 
that the mock implementations do not persist across different test cases.



-- 
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