From 49aa9b4ca82a6ac8c90aa1f81ef89cc9cb55b293 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Mon, 13 Feb 2023 12:31:09 -0500 Subject: [PATCH] chore: Removes icon warnings from tests (#23054) --- superset-frontend/spec/helpers/shim.tsx | 30 +++++++++++++++++++ .../QueryLimitSelect.test.tsx | 3 -- .../AlteredSliceTag/AlteredSliceTag.test.jsx | 2 -- .../Datasource/DatasourceEditor.test.jsx | 12 -------- .../ErrorBoundary/ErrorBoundary.test.tsx | 2 -- .../src/components/ListView/ListView.test.jsx | 6 ---- .../components/MessageToasts/Toast.test.jsx | 2 -- .../PageHeaderWithActions.test.tsx | 2 -- .../HeaderReportDropdown/index.test.tsx | 6 ---- .../ReportModal/ReportModal.test.tsx | 6 ---- .../src/components/Select/AsyncSelect.tsx | 4 +-- .../src/components/Select/Select.tsx | 4 +-- .../components/TableView/TableView.test.tsx | 2 -- .../DashboardBuilder.test.tsx | 3 -- .../DatasourceControl.test.tsx | 19 ------------ .../DndMetricSelect.test.tsx | 8 ----- .../AdhocFilterOption.test.tsx | 8 ----- .../VizTypeControl/FastVizSwitcher.tsx | 11 +++++-- .../CRUD/data/database/DatabaseList.test.jsx | 8 ----- .../database/DatabaseModal/index.test.tsx | 19 ------------ .../views/CRUD/data/query/QueryList.test.tsx | 8 ----- 21 files changed, 43 insertions(+), 122 deletions(-) diff --git a/superset-frontend/spec/helpers/shim.tsx b/superset-frontend/spec/helpers/shim.tsx index ba4310e94..152fcc370 100644 --- a/superset-frontend/spec/helpers/shim.tsx +++ b/superset-frontend/spec/helpers/shim.tsx @@ -89,4 +89,34 @@ jest.mock('react-markdown', () => (props: any) => <>{props.children}); jest.mock('rehype-sanitize', () => () => jest.fn()); jest.mock('rehype-raw', () => () => jest.fn()); +// Mocks the Icon component due to its async nature +// Tests should override this when needed +jest.mock('src/components/Icons/Icon', () => ({ + __esModule: true, + default: ({ + fileName, + role, + 'aria-label': ariaLabel, + ...rest + }: { + fileName: string; + role: string; + 'aria-label': React.AriaAttributes['aria-label']; + }) => ( + + ), + StyledIcon: ({ + role, + 'aria-label': ariaLabel, + ...rest + }: { + role: string; + 'aria-label': React.AriaAttributes['aria-label']; + }) => , +})); + process.env.WEBPACK_MODE = 'test'; diff --git a/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx b/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx index 317a8d02b..adf0780e3 100644 --- a/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx +++ b/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx @@ -42,9 +42,6 @@ jest.mock('src/components/Select/Select', () => () => ( jest.mock('src/components/Select/AsyncSelect', () => () => (
)); -jest.mock('src/components/Icons/Icon', () => () => ( -
-)); const defaultQueryLimit = 100; diff --git a/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.test.jsx b/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.test.jsx index 87ae7307a..7501ce638 100644 --- a/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.test.jsx +++ b/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.test.jsx @@ -33,8 +33,6 @@ import { fakePluginControls, } from './AlteredSliceTagMocks'; -jest.mock('src/components/Icons/Icon', () => () => ); - const getTableWrapperFromModalBody = modalBody => modalBody.find(TableView).find(TableCollection); diff --git a/superset-frontend/src/components/Datasource/DatasourceEditor.test.jsx b/superset-frontend/src/components/Datasource/DatasourceEditor.test.jsx index 929828732..1046c69f8 100644 --- a/superset-frontend/src/components/Datasource/DatasourceEditor.test.jsx +++ b/superset-frontend/src/components/Datasource/DatasourceEditor.test.jsx @@ -24,18 +24,6 @@ import DatasourceEditor from 'src/components/Datasource/DatasourceEditor'; import mockDatasource from 'spec/fixtures/mockDatasource'; import * as featureFlags from 'src/featureFlags'; -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: ({ fileName, role, ...rest }) => ( - - ), - StyledIcon: () => , -})); - const props = { datasource: mockDatasource['7__table'], addSuccessToast: () => {}, diff --git a/superset-frontend/src/components/ErrorBoundary/ErrorBoundary.test.tsx b/superset-frontend/src/components/ErrorBoundary/ErrorBoundary.test.tsx index 0ab1e44a8..75ddc1c6f 100644 --- a/superset-frontend/src/components/ErrorBoundary/ErrorBoundary.test.tsx +++ b/superset-frontend/src/components/ErrorBoundary/ErrorBoundary.test.tsx @@ -20,8 +20,6 @@ import React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import ErrorBoundary from '.'; -jest.mock('src/components/Icons/Icon', () => () => ); - const mockedProps = { children: Error children, onError: () => null, diff --git a/superset-frontend/src/components/ListView/ListView.test.jsx b/superset-frontend/src/components/ListView/ListView.test.jsx index c070fa926..25ab1b63a 100644 --- a/superset-frontend/src/components/ListView/ListView.test.jsx +++ b/superset-frontend/src/components/ListView/ListView.test.jsx @@ -35,12 +35,6 @@ import Pagination from 'src/components/Pagination/Wrapper'; import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint'; -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: () => , - StyledIcon: () => , -})); - function makeMockLocation(query) { const queryStr = encodeURIComponent(query); return { diff --git a/superset-frontend/src/components/MessageToasts/Toast.test.jsx b/superset-frontend/src/components/MessageToasts/Toast.test.jsx index 2254ffb00..f0280c485 100644 --- a/superset-frontend/src/components/MessageToasts/Toast.test.jsx +++ b/superset-frontend/src/components/MessageToasts/Toast.test.jsx @@ -23,8 +23,6 @@ import Toast from 'src/components/MessageToasts/Toast'; import { act } from 'react-dom/test-utils'; import mockMessageToasts from './mockMessageToasts'; -jest.mock('src/components/Icons/Icon', () => () => ); - const props = { toast: mockMessageToasts[0], onCloseToast() {}, diff --git a/superset-frontend/src/components/PageHeaderWithActions/PageHeaderWithActions.test.tsx b/superset-frontend/src/components/PageHeaderWithActions/PageHeaderWithActions.test.tsx index a042fcc63..65158f3ac 100644 --- a/superset-frontend/src/components/PageHeaderWithActions/PageHeaderWithActions.test.tsx +++ b/superset-frontend/src/components/PageHeaderWithActions/PageHeaderWithActions.test.tsx @@ -23,8 +23,6 @@ import userEvent from '@testing-library/user-event'; import { PageHeaderWithActions, PageHeaderWithActionsProps } from './index'; import { Menu } from '../Menu'; -jest.mock('src/components/Icons/Icon', () => () => ); - const defaultProps: PageHeaderWithActionsProps = { editableTitleProps: { title: 'Test title', diff --git a/superset-frontend/src/components/ReportModal/HeaderReportDropdown/index.test.tsx b/superset-frontend/src/components/ReportModal/HeaderReportDropdown/index.test.tsx index 2d6d20279..ea1d823d2 100644 --- a/superset-frontend/src/components/ReportModal/HeaderReportDropdown/index.test.tsx +++ b/superset-frontend/src/components/ReportModal/HeaderReportDropdown/index.test.tsx @@ -24,12 +24,6 @@ import HeaderReportDropdown, { HeaderReportProps } from '.'; let isFeatureEnabledMock: jest.MockInstance; -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: () => , - StyledIcon: () => , -})); - const createProps = () => ({ dashboardId: 1, useTextMenu: false, diff --git a/superset-frontend/src/components/ReportModal/ReportModal.test.tsx b/superset-frontend/src/components/ReportModal/ReportModal.test.tsx index ad289cefe..2755d832d 100644 --- a/superset-frontend/src/components/ReportModal/ReportModal.test.tsx +++ b/superset-frontend/src/components/ReportModal/ReportModal.test.tsx @@ -33,12 +33,6 @@ fetchMock.get(REPORT_ENDPOINT, {}); const NOOP = () => {}; -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: () => , - StyledIcon: () => , -})); - const defaultProps = { addDangerToast: NOOP, addSuccessToast: NOOP, diff --git a/superset-frontend/src/components/Select/AsyncSelect.tsx b/superset-frontend/src/components/Select/AsyncSelect.tsx index 1e1307a58..00c1443c5 100644 --- a/superset-frontend/src/components/Select/AsyncSelect.tsx +++ b/superset-frontend/src/components/Select/AsyncSelect.tsx @@ -511,9 +511,9 @@ const AsyncSelect = forwardRef( suffixIcon={getSuffixIcon(isLoading, showSearch, isDropdownVisible)} menuItemSelectedIcon={ invertSelection ? ( - + ) : ( - + ) } oneLine={oneLine} diff --git a/superset-frontend/src/components/Select/Select.tsx b/superset-frontend/src/components/Select/Select.tsx index d7fe90d38..11f66d8db 100644 --- a/superset-frontend/src/components/Select/Select.tsx +++ b/superset-frontend/src/components/Select/Select.tsx @@ -486,9 +486,9 @@ const Select = forwardRef( )} menuItemSelectedIcon={ invertSelection ? ( - + ) : ( - + ) } oneLine={oneLine} diff --git a/superset-frontend/src/components/TableView/TableView.test.tsx b/superset-frontend/src/components/TableView/TableView.test.tsx index 37a64d911..9111eee07 100644 --- a/superset-frontend/src/components/TableView/TableView.test.tsx +++ b/superset-frontend/src/components/TableView/TableView.test.tsx @@ -44,8 +44,6 @@ const mockedProps: TableViewProps = { pageSize: 1, }; -jest.mock('src/components/Icons/Icon', () => () => ); - test('should render', () => { const { container } = render(); expect(container).toBeInTheDocument(); diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx index dc8e96dfc..fc651e52b 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx @@ -49,9 +49,6 @@ jest.mock('src/featureFlags'); jest.mock('src/components/ResizableSidebar/useStoredSidebarWidth'); // mock following dependant components to fix the prop warnings -jest.mock('src/components/Icons/Icon', () => () => ( -
-)); jest.mock('src/components/DeprecatedSelect/WindowedSelect', () => () => (
)); diff --git a/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx b/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx index 9e32c3005..2c094e72a 100644 --- a/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx +++ b/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx @@ -27,25 +27,6 @@ import DatasourceControl from '.'; const SupersetClientGet = jest.spyOn(SupersetClient, 'get'); -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: ({ - fileName, - role, - ...rest - }: { - fileName: string; - role: string; - }) => ( - - ), - StyledIcon: () => , -})); - const createProps = (overrides: JsonObject = {}) => ({ hovered: false, type: 'DatasourceControl', diff --git a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.test.tsx b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.test.tsx index 8074525f4..80337344a 100644 --- a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.test.tsx +++ b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.test.tsx @@ -30,14 +30,6 @@ import { DndMetricSelect } from 'src/explore/components/controls/DndColumnSelect import { AGGREGATES } from 'src/explore/constants'; import { EXPRESSION_TYPES } from '../MetricControl/AdhocMetric'; -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: ({ fileName }: { fileName: string }) => ( - - ), - StyledIcon: () => , -})); - const defaultProps = { savedMetrics: [ { diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx index ec7de8d36..8513f452e 100644 --- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx +++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx @@ -25,14 +25,6 @@ import AdhocFilter, { } from 'src/explore/components/controls/FilterControl/AdhocFilter'; import AdhocFilterOption, { AdhocFilterOptionProps } from '.'; -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: ({ fileName, role }: { fileName: string; role: string }) => ( - - ), - StyledIcon: () => , -})); - const simpleAdhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'value', diff --git a/superset-frontend/src/explore/components/controls/VizTypeControl/FastVizSwitcher.tsx b/superset-frontend/src/explore/components/controls/VizTypeControl/FastVizSwitcher.tsx index aeb631129..a7186e2aa 100644 --- a/superset-frontend/src/explore/components/controls/VizTypeControl/FastVizSwitcher.tsx +++ b/superset-frontend/src/explore/components/controls/VizTypeControl/FastVizSwitcher.tsx @@ -213,7 +213,9 @@ export const FastVizSwitcher = React.memo( ) { vizTiles.unshift({ name: currentSelection, - icon: , + icon: ( + + ), }); } if ( @@ -224,7 +226,12 @@ export const FastVizSwitcher = React.memo( ) { vizTiles.unshift({ name: currentViz, - icon: , + icon: ( + + ), }); } return vizTiles; diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseList.test.jsx b/superset-frontend/src/views/CRUD/data/database/DatabaseList.test.jsx index 5710d6dd0..f6fc0481f 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseList.test.jsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseList.test.jsx @@ -64,14 +64,6 @@ jest.mock('react-redux', () => ({ useSelector: jest.fn(), })); -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: ({ fileName, role }) => ( - - ), - StyledIcon: () => , -})); - fetchMock.get(databasesInfoEndpoint, { permissions: ['can_write'], }); diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx index c957258e9..32cc16b04 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx @@ -45,25 +45,6 @@ jest.mock('@superset-ui/core', () => ({ isFeatureEnabled: () => true, })); -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: ({ - fileName, - role, - ...rest - }: { - fileName: string; - role: string; - }) => ( - - ), - StyledIcon: () => , -})); - const mockHistoryPush = jest.fn(); jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), diff --git a/superset-frontend/src/views/CRUD/data/query/QueryList.test.tsx b/superset-frontend/src/views/CRUD/data/query/QueryList.test.tsx index ae7c78d6a..be28d7e2d 100644 --- a/superset-frontend/src/views/CRUD/data/query/QueryList.test.tsx +++ b/superset-frontend/src/views/CRUD/data/query/QueryList.test.tsx @@ -35,14 +35,6 @@ import SyntaxHighlighter from 'react-syntax-highlighter/dist/cjs/light'; import SubMenu from 'src/views/components/SubMenu'; import { QueryState } from '@superset-ui/core'; -jest.mock('src/components/Icons/Icon', () => ({ - __esModule: true, - default: ({ fileName, role }: { fileName: string; role: string }) => ( - - ), - StyledIcon: () => , -})); - // store needed for withToasts const mockStore = configureStore([thunk]); const store = mockStore({});