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


##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.test.tsx:
##########
@@ -41,16 +44,34 @@ import {
 } from 
'src/explore/components/controls/DndColumnSelectControl/DndFilterSelect';
 import { PLACEHOLDER_DATASOURCE } from 'src/dashboard/constants';
 import { ExpressionTypes } from '../FilterControl/types';
-import { Datasource } from '../../../types';
 import { DndItemType } from '../../DndItemType';
-import DatasourcePanelDragOption from 
'../../DatasourcePanel/DatasourcePanelDragOption';
+import { Datasource } from '../../../types';
+import {
+  CapturedDroppable,
+  captureDroppableData,
+  simulateDrop,
+} from './dndTestUtils';
 
 jest.mock('src/core/editors', () => ({
   EditorHost: ({ value }: { value: string }) => (
     <div data-test="react-ace">{value}</div>
   ),
 }));
 
+jest.mock('@dnd-kit/core', () => ({
+  ...jest.requireActual('@dnd-kit/core'),
+  useDroppable: jest.fn(),
+}));
+
+const captured: CapturedDroppable = { current: undefined };
+
+beforeEach(() => {
+  captured.current = undefined;
+  (useDroppable as jest.Mock).mockImplementation(
+    captureDroppableData(captured),
+  );
+});

Review Comment:
   <!-- Bito Reply -->
   The proposed change correctly addresses the issue by merging the two 
`beforeEach` hooks into a single block. This ensures that 
`jest.clearAllMocks()` is executed before the `useDroppable` mock 
implementation is set, preventing the mock from being inadvertently cleared and 
ensuring `captured.current` is correctly populated for the drop simulations.
   
   
**superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.test.tsx**
   ```
   beforeEach(() => {
       captured.current = undefined;
       jest.clearAllMocks();
       (useDroppable as jest.Mock).mockImplementation(
         captureDroppableData(captured),
       );
     });
   ```



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