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


##########
superset-frontend/src/explore/components/controls/DateFilterControl/tests/DateFilterLabel.test.tsx:
##########
@@ -93,3 +93,45 @@ test('Open and close popover', () => {
   expect(defaultProps.onClosePopover).toHaveBeenCalled();
   expect(screen.queryByText('Edit time range')).not.toBeInTheDocument();
 });
+
+test('DateFilter popover should attach to document.body when not overflowing', 
() => {
+  render(setup({ ...defaultProps, isOverflowingFilterBar: false }));
+
+  userEvent.click(screen.getByText(NO_TIME_RANGE));
+
+  const popover = document.querySelector('.time-range-popover');
+  expect(popover?.parentElement).toBe(document.body);
+});
+
+test('DateFilter popover should attach to parent node when overflowing in 
filter bar', () => {
+  render(setup({ ...defaultProps, isOverflowingFilterBar: true }));
+
+  userEvent.click(screen.getByText(NO_TIME_RANGE));
+
+  // When overflowing, the popover should be attached to the trigger's parent 
node
+  // instead of document.body to prevent clipping issues
+  const popover = document.querySelector('.time-range-popover');
+  const trigger = screen.getByTestId(DateFilterTestKey.PopoverOverlay);
+
+  // Verify that the popover's container is the trigger's parent (not 
document.body)
+  expect(popover?.parentElement).toBe(trigger.parentElement);
+});
+
+test('DateFilter should properly handle isOverflowingFilterBar prop changes', 
() => {
+  const { rerender } = render(
+    setup({ ...defaultProps, isOverflowingFilterBar: false }),
+  );
+
+  userEvent.click(screen.getByText(NO_TIME_RANGE));
+  const popover = document.querySelector('.time-range-popover');
+  expect(popover?.parentElement).toBe(document.body);
+
+  // Close and reopen with different prop
+  userEvent.click(screen.getByText('CANCEL'));
+
+  rerender(setup({ ...defaultProps, isOverflowingFilterBar: true }));
+  userEvent.click(screen.getByText(NO_TIME_RANGE));
+
+  // The getPopupContainer behavior should update based on the new prop
+  expect(defaultProps.onOpenPopover).toHaveBeenCalled();

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Incomplete test verification</b></div>
   <div id="fix">
   
   The test for handling isOverflowingFilterBar prop changes claims to verify 
getPopupContainer behavior updates, but only checks onOpenPopover is called. It 
should also assert the popover attachment changes to the parent node after 
rerender.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
     
     const popover = document.querySelector('.time-range-popover');
     const trigger = screen.getByTestId(DateFilterTestKey.PopoverOverlay);
     expect(popover?.parentElement).toBe(trigger.parentElement);
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #ab7b15</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.test.tsx:
##########
@@ -0,0 +1,259 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { render } from 'spec/helpers/testing-library';
+import { Provider } from 'react-redux';
+import { Store } from 'redux';
+import configureStore from 'redux-mock-store';
+import thunk from 'redux-thunk';
+import { FilterBarOrientation } from 'src/dashboard/types';
+import FilterControls from './FilterControls';
+
+const mockStore = configureStore([thunk]);
+
+const createMockFilter = (id: string, name: string) => ({
+  id,
+  name,
+  filterType: 'filter_select',
+  targets: [{ datasetId: 1, column: { name: 'country' } }],
+  defaultDataMask: {},
+  controlValues: {},
+  cascadeParentIds: [],
+  scope: {
+    rootPath: ['ROOT_ID'],
+    excluded: [] as string[],
+  },
+  isInstant: true,
+  allowsMultipleValues: true,
+  isRequired: false,
+});
+
+const getDefaultState = (orientation: FilterBarOrientation) => ({
+  dashboardInfo: {
+    id: 1,
+    filterBarOrientation: orientation,
+  },
+  dashboardLayout: {
+    present: {
+      ROOT_ID: {
+        type: 'ROOT',
+        id: 'ROOT_ID',
+        children: ['TABS-1'],
+      },
+      'TABS-1': {
+        type: 'TABS',
+        id: 'TABS-1',
+        children: ['TAB-1', 'TAB-2'],
+      },
+      'TAB-1': {
+        type: 'TAB',
+        id: 'TAB-1',
+        children: ['CHART-1'],
+      },
+      'TAB-2': {
+        type: 'TAB',
+        id: 'TAB-2',
+        children: ['CHART-2'],
+      },
+      'CHART-1': {
+        type: 'CHART',
+        id: 'CHART-1',
+        meta: { chartId: 1 },
+      },
+      'CHART-2': {
+        type: 'CHART',
+        id: 'CHART-2',
+        meta: { chartId: 2 },
+      },
+    },
+  },
+  charts: {
+    1: { id: 1, formData: {} },
+    2: { id: 2, formData: {} },
+  },
+  dataMask: {},
+  nativeFilters: {
+    filters: {
+      'filter-1': createMockFilter('filter-1', 'Country Filter'),
+      'filter-2': createMockFilter('filter-2', 'Region Filter'),
+      'filter-3': createMockFilter('filter-3', 'City Filter'),
+    },
+    filterSets: {},
+  },
+  dashboardState: {
+    directPathToChild: [],
+    activeTabs: ['TAB-1'],
+    chartCustomizationItems: [],
+  },
+  sliceEntities: {
+    slices: {
+      1: {
+        slice_id: 1,
+        slice_name: 'Chart 1',
+        form_data: {},
+      },
+      2: {
+        slice_id: 2,
+        slice_name: 'Chart 2',
+        form_data: {},
+      },
+    },
+  },
+  datasources: {},
+});
+
+function setup(overrideState: any = {}, props: any = {}) {
+  const state = {
+    ...getDefaultState(FilterBarOrientation.Vertical),
+    ...overrideState,
+  };
+  const store = mockStore(state) as Store;
+
+  return render(
+    <Provider store={store}>
+      <FilterControls
+        dataMaskSelected={{}}
+        onFilterSelectionChange={jest.fn()}
+        {...props}
+      />
+    </Provider>,
+  );
+}
+
+test('FilterControls should mark out-of-scope filters as not overflowed in 
vertical mode', () => {
+  const stateWithVertical = getDefaultState(FilterBarOrientation.Vertical);
+
+  // Set up filters where filter-3 is out of scope (not on active tab)
+  stateWithVertical.nativeFilters.filters['filter-3'].scope = {
+    rootPath: ['ROOT_ID'],
+    excluded: ['TAB-1'], // Exclude from active tab
+  };
+
+  const { container } = setup(stateWithVertical);
+
+  // In vertical mode, out-of-scope filters should be in the collapse panel
+  // not in the overflow dropdown
+  expect(container).toBeInTheDocument();
+
+  // The component should render without errors and properly calculate
+  // that out-of-scope filters are not "overflowed" in vertical mode
+});

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Test: Weak assertions</b></div>
   <div id="fix">
   
   Test assertions are too weak - they only check that the component renders 
but don't verify the overflow behavior claimed in test names. Consider checking 
rendered components or props.
   </div>
   
   
   </div>
   
   <details>
   <summary><b>Citations</b></summary>
   <ul>
   
   <li>
   Rule Violated: <a 
href="https://github.com/apache/superset/blob/31a2775/AGENTS.md#L21";>AGENTS.md:21</a>
   </li>
   
   </ul>
   </details>
   
   
   
   
   <small><i>Code Review Run #ab7b15</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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