sadpandajoe commented on code in PR #35456:
URL: https://github.com/apache/superset/pull/35456#discussion_r2399696149
##########
superset-frontend/src/components/Datasource/components/DatasourceEditor/components/DatasetUsageTab/DatasetUsageTab.test.tsx:
##########
@@ -101,21 +158,47 @@ const setupTest = (props = {}) => {
...props,
};
- return render(<DatasetUsageTab {...defaultProps} />, {
+ const result = render(<DatasetUsageTab {...defaultProps} />, {
wrapper: createWrapper({
useRedux: true,
useRouter: true,
}),
});
+
+ return { ...result, mockOnFetchCharts };
};
beforeEach(() => {
fetchMock.reset();
jest.clearAllMocks();
+
+ // Save original scrollTo and mock it for JSDOM compatibility
+ originalScrollTo = Element.prototype.scrollTo;
+ Object.defineProperty(Element.prototype, 'scrollTo', {
+ value: jest.fn(),
+ configurable: true,
+ writable: true,
+ });
+
+ tableMock.__resetPaginationHandler();
});
afterEach(() => {
fetchMock.restore();
+
+ // Restore real timers in case a test with fakeTimers failed mid-test
+ jest.useRealTimers();
+
+ // Restore original scrollTo to avoid test pollution
+ if (originalScrollTo) {
+ Object.defineProperty(Element.prototype, 'scrollTo', {
+ value: originalScrollTo,
Review Comment:
We already have comprehensive manual cleanup for scrollTo and
useRealTimers(). Adding jest.restoreAllMocks() would be redundant since we're
explicitly managing the mocks we care about.
--
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]