From e9aba9997f0b99dbc756eaf9f8c4e0b4853ffb17 Mon Sep 17 00:00:00 2001 From: geido Date: Mon, 15 Aug 2022 17:23:30 +0300 Subject: [PATCH 01/10] Add DrillDetailModal test --- .../spec/fixtures/mockChartQueries.js | 1 + superset-frontend/spec/fixtures/mockState.js | 5 + .../Chart/DrillDetailModal.test.tsx | 105 ++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 superset-frontend/src/components/Chart/DrillDetailModal.test.tsx diff --git a/superset-frontend/spec/fixtures/mockChartQueries.js b/superset-frontend/spec/fixtures/mockChartQueries.js index d25267392a0db..0175df981a306 100644 --- a/superset-frontend/spec/fixtures/mockChartQueries.js +++ b/superset-frontend/spec/fixtures/mockChartQueries.js @@ -36,6 +36,7 @@ export default { datasource: datasourceId, viz_type: 'pie', slice_id: sliceId, + slice_name: 'Genders', granularity_sqla: null, time_grain_sqla: null, since: '100 years ago', diff --git a/superset-frontend/spec/fixtures/mockState.js b/superset-frontend/spec/fixtures/mockState.js index e492217e72b6d..19fb268893615 100644 --- a/superset-frontend/spec/fixtures/mockState.js +++ b/superset-frontend/spec/fixtures/mockState.js @@ -35,6 +35,11 @@ export default { sliceEntities: sliceEntitiesForChart, charts: chartQueries, nativeFilters: nativeFiltersInfo, + common: { + conf: { + SAMPLES_ROW_LIMIT: 100, + }, + }, dataMask: mockDataMaskInfo, dashboardInfo, dashboardFilters: emptyFilters, diff --git a/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx b/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx new file mode 100644 index 0000000000000..42e1fd27e081f --- /dev/null +++ b/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx @@ -0,0 +1,105 @@ +/** + * 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 React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore'; +import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries'; +import DrillDetailModal from './DrillDetailModal'; +import { QueryFormData } from '@superset-ui/core'; +import fetchMock from 'fetch-mock'; +import userEvent from '@testing-library/user-event'; + + +const chart = chartQueries[sliceId]; +const setup = (overrides: Record = {}) => { + const store = getMockStoreWithNativeFilters(); + const props = { + chartId: sliceId, + initialFilters: [], + formData: chart.form_data as unknown as QueryFormData, + ...overrides, +} + return render( + , { + useRedux: true, + useRouter: true, + store + }); +}; +const waitForRender = (overrides: Record = {}) => waitFor(() => setup(overrides)); + +fetchMock.post( + 'end:/datasource/samples?force=false&datasource_type=table&datasource_id=7&per_page=50&page=1', + { + result: { + data: [], + colnames: [], + coltypes: [], + }, + }, +); + +const mockHistoryPush = jest.fn(); +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), + useHistory: () => ({ + push: mockHistoryPush, + }), +})); + +test('should render', async () => { + const { container } = await waitForRender(); + expect(container).toBeInTheDocument(); +}); + +test('should render the title', async () => { + await waitForRender(); + expect(screen.getByText(`Drill to detail: ${chart.form_data.slice_name}`)).toBeInTheDocument(); +}); + +test('should render the modal', async () => { + await waitForRender(); + expect(screen.getByRole("dialog")).toBeInTheDocument(); +}); + +test('should not render the modal', async () => { + await waitForRender({ + initialFilters: undefined, + }); + expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); +}); + +test('should render the button', async () => { + await waitForRender(); + expect(screen.getByRole("button", {name: "Edit chart"})).toBeInTheDocument(); + expect(screen.getAllByRole("button", {name: "Close"})).toHaveLength(2); +}); + +test('should close the modal', async () => { + await waitForRender(); + expect(screen.getByRole("dialog")).toBeInTheDocument(); + userEvent.click(screen.getAllByRole("button", {name: "Close"})[1]); + expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); +}); + +test('should forward to Explore', async () => { + await waitForRender(); + userEvent.click(screen.getByRole("button", {name: "Edit chart"})); + expect(mockHistoryPush).toHaveBeenCalledWith(`/explore/?dashboard_page_id=&slice_id=${sliceId}`); +}); From af71d5a4aa2bf910905c1dc85b47e992bd4c7dfd Mon Sep 17 00:00:00 2001 From: geido Date: Tue, 16 Aug 2022 19:30:52 +0300 Subject: [PATCH 02/10] Add DrillDetailPane tests --- superset-frontend/spec/fixtures/mockState.js | 2 +- .../Chart/DrillDetailModal.test.tsx | 1 - .../DrillDetailPane/DrillDetailPane.test.tsx | 126 ++++++++++++++++++ 3 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 superset-frontend/src/dashboard/components/DrillDetailPane/DrillDetailPane.test.tsx diff --git a/superset-frontend/spec/fixtures/mockState.js b/superset-frontend/spec/fixtures/mockState.js index 19fb268893615..629ed775b4121 100644 --- a/superset-frontend/spec/fixtures/mockState.js +++ b/superset-frontend/spec/fixtures/mockState.js @@ -37,7 +37,7 @@ export default { nativeFilters: nativeFiltersInfo, common: { conf: { - SAMPLES_ROW_LIMIT: 100, + SAMPLES_ROW_LIMIT: 10, }, }, dataMask: mockDataMaskInfo, diff --git a/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx b/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx index 42e1fd27e081f..81ead9643878f 100644 --- a/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx +++ b/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx @@ -25,7 +25,6 @@ import { QueryFormData } from '@superset-ui/core'; import fetchMock from 'fetch-mock'; import userEvent from '@testing-library/user-event'; - const chart = chartQueries[sliceId]; const setup = (overrides: Record = {}) => { const store = getMockStoreWithNativeFilters(); diff --git a/superset-frontend/src/dashboard/components/DrillDetailPane/DrillDetailPane.test.tsx b/superset-frontend/src/dashboard/components/DrillDetailPane/DrillDetailPane.test.tsx new file mode 100644 index 0000000000000..7a89af5850488 --- /dev/null +++ b/superset-frontend/src/dashboard/components/DrillDetailPane/DrillDetailPane.test.tsx @@ -0,0 +1,126 @@ +/** + * 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 React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore'; +import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries'; +import DrillDetailPane from './DrillDetailPane'; +import { QueryFormData, SupersetClient } from '@superset-ui/core'; +import fetchMock from 'fetch-mock'; + +const chart = chartQueries[sliceId]; +const setup = (overrides: Record = {}) => { + const store = getMockStoreWithNativeFilters(); + const props = { + initialFilters: [], + formData: chart.form_data as unknown as QueryFormData, + ...overrides, +} + return render( + , { + useRedux: true, + store + }); +}; +const waitForRender = (overrides: Record = {}) => waitFor(() => setup(overrides)); +const samplesEndpoint = "end:/datasource/samples?force=false&datasource_type=table&datasource_id=7&per_page=50&page=1"; +const fetchWithNoData = () => fetchMock.post( + samplesEndpoint, + { + result: { + total_count: 0, + data: [], + colnames: [], + coltypes: [], + }, + }, +); +const fetchWithData = () => fetchMock.post( + samplesEndpoint, + { + result: { + total_count: 3, + data: [ + { + "year": 1996, + "na_sales": 11.27, + "eu_sales": 8.89, + }, + { + "year": 1989, + "na_sales": 23.2, + "eu_sales": 2.26, + }, + { + "year": 1999, + "na_sales": 9, + "eu_sales": 6.18, + }, + ], + colnames: [ + "year", + "na_sales", + "eu_sales", + ], + coltypes: [ + 0, + 0, + 0, + ], + }, + }); + const SupersetClientPost = jest.spyOn(SupersetClient, 'post'); + +afterEach(fetchMock.restore); + +test('should render', async () => { + fetchWithNoData(); + const { container } = await waitForRender(); + expect(container).toBeInTheDocument(); +}); + +test('should render the loading component', async () => { + fetchWithData(); + setup(); + await waitFor(() => { + expect(screen.getByRole("status", {name: "Loading"})).toBeInTheDocument(); + }); +}); + +test('should render the table with results', async () => { + fetchWithData(); + await waitForRender(); + expect(screen.getByRole("table")).toBeInTheDocument(); + expect(screen.getAllByRole("row")).toHaveLength(4); + expect(screen.getByRole("columnheader", {name: "year"})).toBeInTheDocument(); + expect(screen.getByRole("columnheader", {name: "na_sales"})).toBeInTheDocument(); + expect(screen.getByRole("columnheader", {name: "eu_sales"})).toBeInTheDocument(); +}); + +test('should render the "No results" components', async () => { + fetchWithNoData(); + setup(); + expect(await screen.findByText("No rows were returned for this dataset")).toBeInTheDocument(); +}); + +test('should render the error', async () => { + SupersetClientPost.mockRejectedValue(new Error("Something went wrong")); + await waitForRender(); + expect(screen.getByText("Error: Something went wrong")).toBeInTheDocument(); +}); From ed622527ec61240a65a70e5c8b37895ffed2d559 Mon Sep 17 00:00:00 2001 From: geido Date: Tue, 16 Aug 2022 20:14:14 +0300 Subject: [PATCH 03/10] Add TableControls test --- .../DrillDetailPane/TableControls.test.tsx | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx diff --git a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx new file mode 100644 index 0000000000000..778f5d96add95 --- /dev/null +++ b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx @@ -0,0 +1,109 @@ +/** + * 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 React from 'react'; +import { render, screen } from 'spec/helpers/testing-library'; +import userEvent from '@testing-library/user-event'; +import TableControls from './TableControls'; + +const setFilters = jest.fn(); +const onReload = jest.fn(); +const setup = (overrides: Record = {}) => { + const props = { + filters: [], + setFilters, + onReload, + loading: false, + totalCount: 0, + ...overrides, + }; + return render(); +}; +test('should render', async () => { + const { container } = setup(); + expect(container).toBeInTheDocument(); +}); + +test('should show 0 rows', () => { + setup(); + expect(screen.getByText('0 rows')).toBeInTheDocument(); +}); + +test('should show the correct amount of rows', () => { + setup({ + totalCount: 10, + }); + expect(screen.getByText('10 rows')).toBeInTheDocument(); +}); + +test('should render the reload button', () => { + setup(); + expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument(); +}); + +test('should show the loading indicator', async () => { + setup({ + loading: true, + }); + expect(screen.getByText('Loading...')).toBeInTheDocument(); +}); + +test('should call onreload', async () => { + setup(); + userEvent.click(screen.getByRole('button', { name: 'Reload' })); + expect(onReload).toHaveBeenCalledTimes(1); +}); + +test('should render with filters', async () => { + setup({ + filters: [ + { + col: 'platform', + op: '==', + val: 'GB', + }, + { + col: 'lang', + op: '==', + val: 'IT', + }, + ], + }); + expect(screen.getByText('platform')).toBeInTheDocument(); + expect(screen.getByText('GB')).toBeInTheDocument(); + expect(screen.getByText('lang')).toBeInTheDocument(); + expect(screen.getByText('IT')).toBeInTheDocument(); +}); + +test('should remove the filters on close', async () => { + setup({ + filters: [ + { + col: 'platform', + op: '==', + val: 'GB', + }, + ], + }); + expect(screen.getByText('platform')).toBeInTheDocument(); + expect(screen.getByText('GB')).toBeInTheDocument(); + + userEvent.click(screen.getByRole('img', { name: 'close' })); + + expect(setFilters).toHaveBeenCalledWith([]); +}); From 1e27668f31945fa0b424098ef0615c8ed22e754d Mon Sep 17 00:00:00 2001 From: geido Date: Tue, 16 Aug 2022 20:18:10 +0300 Subject: [PATCH 04/10] Lint --- .../Chart/DrillDetailModal.test.tsx | 48 ++++++---- .../DrillDetailPane/DrillDetailPane.test.tsx | 96 +++++++++---------- 2 files changed, 74 insertions(+), 70 deletions(-) diff --git a/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx b/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx index 81ead9643878f..20f319ce4f979 100644 --- a/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx +++ b/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx @@ -19,29 +19,29 @@ import React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore'; -import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries'; -import DrillDetailModal from './DrillDetailModal'; +import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries'; import { QueryFormData } from '@superset-ui/core'; import fetchMock from 'fetch-mock'; import userEvent from '@testing-library/user-event'; +import DrillDetailModal from './DrillDetailModal'; const chart = chartQueries[sliceId]; const setup = (overrides: Record = {}) => { const store = getMockStoreWithNativeFilters(); const props = { - chartId: sliceId, - initialFilters: [], - formData: chart.form_data as unknown as QueryFormData, - ...overrides, -} - return render( - , { + chartId: sliceId, + initialFilters: [], + formData: chart.form_data as unknown as QueryFormData, + ...overrides, + }; + return render(, { useRedux: true, useRouter: true, - store + store, }); }; -const waitForRender = (overrides: Record = {}) => waitFor(() => setup(overrides)); +const waitForRender = (overrides: Record = {}) => + waitFor(() => setup(overrides)); fetchMock.post( 'end:/datasource/samples?force=false&datasource_type=table&datasource_id=7&per_page=50&page=1', @@ -69,36 +69,42 @@ test('should render', async () => { test('should render the title', async () => { await waitForRender(); - expect(screen.getByText(`Drill to detail: ${chart.form_data.slice_name}`)).toBeInTheDocument(); + expect( + screen.getByText(`Drill to detail: ${chart.form_data.slice_name}`), + ).toBeInTheDocument(); }); test('should render the modal', async () => { await waitForRender(); - expect(screen.getByRole("dialog")).toBeInTheDocument(); + expect(screen.getByRole('dialog')).toBeInTheDocument(); }); test('should not render the modal', async () => { await waitForRender({ initialFilters: undefined, }); - expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); + expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); }); test('should render the button', async () => { await waitForRender(); - expect(screen.getByRole("button", {name: "Edit chart"})).toBeInTheDocument(); - expect(screen.getAllByRole("button", {name: "Close"})).toHaveLength(2); + expect( + screen.getByRole('button', { name: 'Edit chart' }), + ).toBeInTheDocument(); + expect(screen.getAllByRole('button', { name: 'Close' })).toHaveLength(2); }); test('should close the modal', async () => { await waitForRender(); - expect(screen.getByRole("dialog")).toBeInTheDocument(); - userEvent.click(screen.getAllByRole("button", {name: "Close"})[1]); - expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); + expect(screen.getByRole('dialog')).toBeInTheDocument(); + userEvent.click(screen.getAllByRole('button', { name: 'Close' })[1]); + expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); }); test('should forward to Explore', async () => { await waitForRender(); - userEvent.click(screen.getByRole("button", {name: "Edit chart"})); - expect(mockHistoryPush).toHaveBeenCalledWith(`/explore/?dashboard_page_id=&slice_id=${sliceId}`); + userEvent.click(screen.getByRole('button', { name: 'Edit chart' })); + expect(mockHistoryPush).toHaveBeenCalledWith( + `/explore/?dashboard_page_id=&slice_id=${sliceId}`, + ); }); diff --git a/superset-frontend/src/dashboard/components/DrillDetailPane/DrillDetailPane.test.tsx b/superset-frontend/src/dashboard/components/DrillDetailPane/DrillDetailPane.test.tsx index 7a89af5850488..a65d469fb02d6 100644 --- a/superset-frontend/src/dashboard/components/DrillDetailPane/DrillDetailPane.test.tsx +++ b/superset-frontend/src/dashboard/components/DrillDetailPane/DrillDetailPane.test.tsx @@ -19,73 +19,63 @@ import React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore'; -import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries'; -import DrillDetailPane from './DrillDetailPane'; +import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries'; import { QueryFormData, SupersetClient } from '@superset-ui/core'; import fetchMock from 'fetch-mock'; +import DrillDetailPane from './DrillDetailPane'; const chart = chartQueries[sliceId]; const setup = (overrides: Record = {}) => { const store = getMockStoreWithNativeFilters(); const props = { - initialFilters: [], - formData: chart.form_data as unknown as QueryFormData, - ...overrides, -} - return render( - , { + initialFilters: [], + formData: chart.form_data as unknown as QueryFormData, + ...overrides, + }; + return render(, { useRedux: true, - store + store, }); }; -const waitForRender = (overrides: Record = {}) => waitFor(() => setup(overrides)); -const samplesEndpoint = "end:/datasource/samples?force=false&datasource_type=table&datasource_id=7&per_page=50&page=1"; -const fetchWithNoData = () => fetchMock.post( - samplesEndpoint, - { +const waitForRender = (overrides: Record = {}) => + waitFor(() => setup(overrides)); +const samplesEndpoint = + 'end:/datasource/samples?force=false&datasource_type=table&datasource_id=7&per_page=50&page=1'; +const fetchWithNoData = () => + fetchMock.post(samplesEndpoint, { result: { total_count: 0, data: [], colnames: [], coltypes: [], }, - }, -); -const fetchWithData = () => fetchMock.post( - samplesEndpoint, - { + }); +const fetchWithData = () => + fetchMock.post(samplesEndpoint, { result: { total_count: 3, data: [ { - "year": 1996, - "na_sales": 11.27, - "eu_sales": 8.89, + year: 1996, + na_sales: 11.27, + eu_sales: 8.89, }, { - "year": 1989, - "na_sales": 23.2, - "eu_sales": 2.26, + year: 1989, + na_sales: 23.2, + eu_sales: 2.26, }, { - "year": 1999, - "na_sales": 9, - "eu_sales": 6.18, + year: 1999, + na_sales: 9, + eu_sales: 6.18, }, - ], - colnames: [ - "year", - "na_sales", - "eu_sales", - ], - coltypes: [ - 0, - 0, - 0, - ], + ], + colnames: ['year', 'na_sales', 'eu_sales'], + coltypes: [0, 0, 0], }, }); - const SupersetClientPost = jest.spyOn(SupersetClient, 'post'); +const SupersetClientPost = jest.spyOn(SupersetClient, 'post'); afterEach(fetchMock.restore); @@ -99,28 +89,36 @@ test('should render the loading component', async () => { fetchWithData(); setup(); await waitFor(() => { - expect(screen.getByRole("status", {name: "Loading"})).toBeInTheDocument(); + expect(screen.getByRole('status', { name: 'Loading' })).toBeInTheDocument(); }); }); test('should render the table with results', async () => { fetchWithData(); await waitForRender(); - expect(screen.getByRole("table")).toBeInTheDocument(); - expect(screen.getAllByRole("row")).toHaveLength(4); - expect(screen.getByRole("columnheader", {name: "year"})).toBeInTheDocument(); - expect(screen.getByRole("columnheader", {name: "na_sales"})).toBeInTheDocument(); - expect(screen.getByRole("columnheader", {name: "eu_sales"})).toBeInTheDocument(); + expect(screen.getByRole('table')).toBeInTheDocument(); + expect(screen.getAllByRole('row')).toHaveLength(4); + expect( + screen.getByRole('columnheader', { name: 'year' }), + ).toBeInTheDocument(); + expect( + screen.getByRole('columnheader', { name: 'na_sales' }), + ).toBeInTheDocument(); + expect( + screen.getByRole('columnheader', { name: 'eu_sales' }), + ).toBeInTheDocument(); }); test('should render the "No results" components', async () => { fetchWithNoData(); setup(); - expect(await screen.findByText("No rows were returned for this dataset")).toBeInTheDocument(); + expect( + await screen.findByText('No rows were returned for this dataset'), + ).toBeInTheDocument(); }); test('should render the error', async () => { - SupersetClientPost.mockRejectedValue(new Error("Something went wrong")); + SupersetClientPost.mockRejectedValue(new Error('Something went wrong')); await waitForRender(); - expect(screen.getByText("Error: Something went wrong")).toBeInTheDocument(); + expect(screen.getByText('Error: Something went wrong')).toBeInTheDocument(); }); From 6806d3478a96965dd5c0b0df28d761efd5562ea6 Mon Sep 17 00:00:00 2001 From: geido Date: Tue, 16 Aug 2022 20:30:42 +0300 Subject: [PATCH 05/10] Enhance SliceHeaderControls tests --- .../SliceHeaderControls.test.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx index 514ff4fc2cdea..455afb60392a3 100644 --- a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx +++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx @@ -236,3 +236,23 @@ test('Should "Enter fullscreen"', () => { userEvent.click(screen.getByText('Enter fullscreen')); expect(props.handleToggleFullSize).toBeCalledTimes(1); }); + +test('Drill to detail modal is under featureflag', () => { + // @ts-ignore + global.featureFlags = { + [FeatureFlag.DRILL_TO_DETAIL]: false, + }; + const props = createProps(); + renderWrapper(props); + expect(screen.queryByText('Drill to detail')).not.toBeInTheDocument(); +}); + +test('Should show the "Drill to detail"', () => { + // @ts-ignore + global.featureFlags = { + [FeatureFlag.DRILL_TO_DETAIL]: true, + }; + const props = createProps(); + renderWrapper(props); + expect(screen.getByText('Drill to detail')).toBeInTheDocument(); +}); From f071f4c574c2873b0632b709900b2f5fc2370cf9 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Fri, 26 Aug 2022 14:16:38 +0300 Subject: [PATCH 06/10] Update superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> --- .../dashboard/components/DrillDetailPane/TableControls.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx index 778f5d96add95..2882dee2cae57 100644 --- a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx +++ b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx @@ -34,7 +34,7 @@ const setup = (overrides: Record = {}) => { }; return render(); }; -test('should render', async () => { +test('should render', () => { const { container } = setup(); expect(container).toBeInTheDocument(); }); From 99c29e78fa9428b9aa5e0bcca9ac1f486df35a4f Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Fri, 26 Aug 2022 14:17:05 +0300 Subject: [PATCH 07/10] Update superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> --- .../dashboard/components/DrillDetailPane/TableControls.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx index 2882dee2cae57..c0560cfeb434c 100644 --- a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx +++ b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx @@ -56,7 +56,7 @@ test('should render the reload button', () => { expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument(); }); -test('should show the loading indicator', async () => { +test('should show the loading indicator', () => { setup({ loading: true, }); From 70a25a7b6c256a03d164abfc14d35129dfe947b1 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Fri, 26 Aug 2022 14:17:18 +0300 Subject: [PATCH 08/10] Update superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> --- .../dashboard/components/DrillDetailPane/TableControls.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx index c0560cfeb434c..b65b7f3d3e1f0 100644 --- a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx +++ b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx @@ -63,7 +63,7 @@ test('should show the loading indicator', () => { expect(screen.getByText('Loading...')).toBeInTheDocument(); }); -test('should call onreload', async () => { +test('should call onreload', () => { setup(); userEvent.click(screen.getByRole('button', { name: 'Reload' })); expect(onReload).toHaveBeenCalledTimes(1); From 01a64441d1a3bb96d7c993b092e9cbc1dda212a5 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Fri, 26 Aug 2022 14:17:29 +0300 Subject: [PATCH 09/10] Update superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> --- .../dashboard/components/DrillDetailPane/TableControls.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx index b65b7f3d3e1f0..35bc8a6aa67a2 100644 --- a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx +++ b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx @@ -69,7 +69,7 @@ test('should call onreload', () => { expect(onReload).toHaveBeenCalledTimes(1); }); -test('should render with filters', async () => { +test('should render with filters', () => { setup({ filters: [ { From ed836b288031c880927b0c5bf3d7ff9a5aca7e0f Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Fri, 26 Aug 2022 14:17:38 +0300 Subject: [PATCH 10/10] Update superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> --- .../dashboard/components/DrillDetailPane/TableControls.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx index 35bc8a6aa67a2..0768d0ec7344d 100644 --- a/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx +++ b/superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx @@ -90,7 +90,7 @@ test('should render with filters', () => { expect(screen.getByText('IT')).toBeInTheDocument(); }); -test('should remove the filters on close', async () => { +test('should remove the filters on close', () => { setup({ filters: [ {