rusackas commented on code in PR #37141:
URL: https://github.com/apache/superset/pull/37141#discussion_r2824945131


##########
superset-frontend/src/features/home/Menu.test.tsx:
##########
@@ -24,6 +24,15 @@ import { getExtensionsRegistry } from '@superset-ui/core';
 import { Menu } from './Menu';
 import * as getBootstrapData from 'src/utils/getBootstrapData';
 
+// Mock useBreakpoint to return desktop breakpoints (prevents mobile menu 
rendering)
+jest.mock('antd', () => ({
+  ...jest.requireActual('antd'),
+  Grid: {
+    ...jest.requireActual('antd').Grid,
+    useBreakpoint: () => ({ xs: true, sm: true, md: true, lg: true, xl: true 
}),
+  },
+}));

Review Comment:
   Update: I tried mocking `@superset-ui/core/components` to follow best 
practices, but it fails with circular dependency issues:
   
   ```
   TypeError: Cannot read properties of undefined (reading 'ActionButton')
   ```
   
   The `jest.requireActual('@superset-ui/core/components')` triggers module 
evaluation which tries to resolve ActionButton before the mock is fully set up, 
causing a cascade of import failures.
   
   Mocking `antd` directly works because:
   1. `antd` is a leaf dependency without circular imports to the codebase
   2. When `@superset-ui/core/components` loads, it imports Grid from the 
mocked `antd`
   
   Added a comment in commit 9d16b51 explaining this decision for future 
maintainers.



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