diff --git a/superset-frontend/spec/helpers/shim.tsx b/superset-frontend/spec/helpers/shim.tsx index ba4310e94dd2d..152fcc370cfc2 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 317a8d02ba51f..adf0780e32043 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 87ae7307a84ed..7501ce6382a4c 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 9298287322692..1046c69f846e6 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 0ab1e44a802e6..75ddc1c6fa9dd 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 c070fa926d861..25ab1b63aea6b 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 2254ffb00a9d1..f0280c4851e73 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 a042fcc63d8a5..65158f3ac811e 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 2d6d202799648..ea1d823d2498c 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 ad289cefe9a82..2755d832d79f5 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 1e1307a5880e0..00c1443c56e21 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 d7fe90d3889be..11f66d8dba529 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 37a64d911270e..9111eee077175 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 dc8e96dfc838f..fc651e52b706c 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 9e32c3005170f..2c094e72afba0 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 8074525f4e5b5..80337344a2a1d 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 ec7de8d36ed87..8513f452e58d8 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 aeb6311290d9f..a7186e2aa19b5 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 5710d6dd0df0f..f6fc0481f6521 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 c957258e91ff1..32cc16b04f45b 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 ae7c78d6a89e5..be28d7e2dfa85 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({});