Copilot commented on code in PR #40782: URL: https://github.com/apache/superset/pull/40782#discussion_r3359673400
########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.overflow.test.tsx: ########## @@ -0,0 +1,320 @@ +/** + * 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 { act } from 'react'; +import { NativeFilterType, Preset } from '@superset-ui/core'; +import type { DataMaskStateWithId } from '@superset-ui/core'; +import type { + DropdownContainerProps, + DropdownItem, +} from '@superset-ui/core/components/DropdownContainer'; +import { SelectFilterPlugin } from 'src/filters/components'; +import { FilterBarOrientation } from 'src/dashboard/types'; +import { render, waitFor, within } from 'spec/helpers/testing-library'; +import FilterControls from './FilterControls'; Review Comment: Importing `act` from `react` bypasses the project’s RTL wrapper (`spec/helpers/testing-library`), which can lead to inconsistent batching/flush behavior vs other Superset frontend tests (e.g. FilterBar.test.tsx). Prefer using the same `act` export as the other RTL tests in this area. ########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -92,3 +106,148 @@ test('should render the loading icon', async () => { }); expect(screen.getByRole('status', { name: 'Loading' })).toBeInTheDocument(); }); + +// --- Tests migrated from disabled Cypress spec +// `_skip.horizontalFilterBar.test.ts` (sc-107387). --- + +const createSelectFilter = (id: string, name: string, column: string) => ({ + id, + name, + type: NativeFilterType.NativeFilter, + filterType: 'filter_select', + targets: [{ datasetId: 2, column: { name: column } }], + defaultDataMask: { filterState: { value: null }, extraFormData: {} }, + controlValues: {}, + cascadeParentIds: [], + scope: { rootPath: ['ROOT_ID'], excluded: [] }, + description: '', + chartsInScope: [], + tabsInScope: [], +}); + +const buildStateWithFilters = ( + filters: ReturnType<typeof createSelectFilter>[], +) => ({ + dashboardState: { + sliceIds: [], + activeTabs: ['ROOT_ID'], + }, + dashboardInfo: { + id: 1, + dash_edit_perm: true, + filterBarOrientation: FilterBarOrientation.Horizontal, + metadata: { + native_filter_configuration: filters, + }, + }, + dashboardLayout: { + present: { + ROOT_ID: { type: 'ROOT', id: 'ROOT_ID', children: [] }, + }, + past: [], + future: [], + }, + charts: {}, + nativeFilters: { + filters: filters.reduce( + (acc, f) => ({ ...acc, [f.id]: f }), + {} as Record<string, ReturnType<typeof createSelectFilter>>, + ), + filtersState: {}, + }, + dataMask: filters.reduce( + (acc, f) => ({ + ...acc, + [f.id]: { id: f.id, filterState: { value: null }, extraFormData: {} }, + }), + {} as Record<string, unknown>, + ), + sliceEntities: { slices: {} }, + datasources: {}, +}); + +const renderWithFilters = ( + filters: ReturnType<typeof createSelectFilter>[], + overrideProps?: Record<string, any>, +) => Review Comment: Avoid `Record<string, any>` for `overrideProps` in TS tests: it defeats type-checking and makes it easy to pass invalid props to the component under test. Use a typed partial of the actual Horizontal bar props instead (type-only import via `import('./types')` keeps the change local). -- 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]
