rusackas commented on code in PR #37880:
URL: https://github.com/apache/superset/pull/37880#discussion_r3365950254
##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.test.tsx:
##########
@@ -181,78 +174,8 @@ test('renders options with adhoc metric', async () => {
).toBeInTheDocument();
});
-test('cannot drop a column that is not part of the simple column selection',
() => {
- const adhocMetric = new AdhocMetric({
- expression: 'AVG(birth_names.num)',
- metric_name: 'avg__num',
- });
- const { getByTestId, getAllByTestId } = render(
- <>
- <DatasourcePanelDragOption
- value={{ column_name: 'order_date' }}
- type={DndItemType.Column}
- />
- <DatasourcePanelDragOption
- value={{ column_name: 'address_line1' }}
- type={DndItemType.Column}
- />
- <DatasourcePanelDragOption
- value={{
- metric_name: 'metric_a',
- expression: 'AGG(metric_a)',
- uuid: '1',
- }}
- type={DndItemType.Metric}
- />
- {setup({
- formData: {
- ...baseFormData,
- metrics: [adhocMetric as unknown as QueryFormMetric],
- },
- columns: [{ column_name: 'order_date' }],
- })}
- </>,
- {
- useDnd: true,
- store,
- },
- );
-
- const selections = getAllByTestId('DatasourcePanelDragOption');
- const acceptableColumn = selections[0];
- const unacceptableColumn = selections[1];
- const metricType = selections[2];
- const currentMetric = getByTestId('dnd-labels-container');
-
- fireEvent.dragStart(unacceptableColumn);
- fireEvent.dragOver(currentMetric);
- fireEvent.drop(currentMetric);
-
- expect(screen.queryByTestId('filter-edit-popover')).not.toBeInTheDocument();
-
- fireEvent.dragStart(acceptableColumn);
- fireEvent.dragOver(currentMetric);
- fireEvent.drop(currentMetric);
-
- const filterConfigPopup = screen.getByTestId('filter-edit-popover');
-
expect(within(filterConfigPopup).getByText('order_date')).toBeInTheDocument();
-
- fireEvent.keyDown(filterConfigPopup, {
- key: 'Escape',
- code: 'Escape',
- keyCode: 27,
- charCode: 27,
- });
- expect(screen.queryByTestId('filter-edit-popover')).not.toBeInTheDocument();
-
- fireEvent.dragStart(metricType);
- fireEvent.dragOver(currentMetric);
- fireEvent.drop(currentMetric);
-
- expect(
- within(screen.getByTestId('filter-edit-popover')).getByTestId('react-ace'),
- ).toHaveTextContent('AGG(metric_a)');
-});
+// Note: Drag-and-drop tests removed - @dnd-kit uses pointer events instead of
Review Comment:
Good call — restored these in 0df9742. I re-added the three type-gating
tests (the non-simple-column rejection plus both `disallow_adhoc_metrics`
scenarios) to `DndFilterSelect.test.tsx` using the `captureDroppableData` +
`simulateDrop` pattern from `DndMetricSelect.test.tsx`, driving the drops
through the production `resolveDragEnd` dispatcher so the accept/canDrop gating
is genuinely exercised.
##########
superset-frontend/src/explore/components/ExploreContainer/ExploreContainer.test.tsx:
##########
@@ -57,69 +53,29 @@ test('should render children', () => {
<ExploreContainer>
<MockChildren />
</ExploreContainer>,
- { useRedux: true, useDnd: true },
+ { useRedux: true },
);
expect(getByTestId('mock-children')).toBeInTheDocument();
expect(getByText('not dragging')).toBeInTheDocument();
});
-test('should only propagate dragging state when dragging the panel option', ()
=> {
- const defaultProps = {
- label: <span>Test label</span>,
- tooltipTitle: 'This is a tooltip title',
- onRemove: jest.fn(),
- onMoveLabel: jest.fn(),
- onDropLabel: jest.fn(),
- type: 'test',
- index: 0,
- };
+test('should initially have dragging set to false', () => {
Review Comment:
Restored in 0df9742. I re-added coverage for the drag-start gating in
`ExploreContainer.test.tsx`: one test confirms a DatasourcePanel option (no
`dragIndex`) sets `DraggingContext`, and a second confirms an in-list reorder
(carrying `dragIndex`) does not. Done by capturing the provider's `onDragStart`
and invoking it directly, since jsdom can't drive @dnd-kit's PointerSensor.
--
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]