geido commented on code in PR #44144:
URL: https://github.com/apache/superset/pull/44144#discussion_r4045417654


##########
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:
   Good catch. I now snapshot both URL method property descriptors in 
`beforeEach` and restore (or delete) them in `afterEach`, so the jsdom globals 
cannot leak into other tests. The hook suite and staged frontend checks pass.



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