From 10478ff1303ee0e7755f0c90404bd35bd58b1086 Mon Sep 17 00:00:00 2001 From: Grace Date: Mon, 23 Aug 2021 15:11:57 -0700 Subject: [PATCH 1/5] fix: setupPlugin in chart list page --- superset-frontend/src/views/CRUD/chart/ChartList.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/superset-frontend/src/views/CRUD/chart/ChartList.tsx b/superset-frontend/src/views/CRUD/chart/ChartList.tsx index e4aff8192cca..be5d3568b699 100644 --- a/superset-frontend/src/views/CRUD/chart/ChartList.tsx +++ b/superset-frontend/src/views/CRUD/chart/ChartList.tsx @@ -57,6 +57,7 @@ import Chart from 'src/types/Chart'; import { Tooltip } from 'src/components/Tooltip'; import Icons from 'src/components/Icons'; import { nativeFilterGate } from 'src/dashboard/components/nativeFilters/utils'; +import setupPlugins from 'src/setup/setupPlugins'; import ChartCard from './ChartCard'; const PAGE_SIZE = 25; @@ -125,6 +126,8 @@ const Actions = styled.div` color: ${({ theme }) => theme.colors.grayscale.base}; `; +setupPlugins(); + function ChartList(props: ChartListProps) { const { addDangerToast, addSuccessToast } = props; From b3211120fe82db3049ecc8d0f259099f7e09b390 Mon Sep 17 00:00:00 2001 From: Grace Date: Tue, 24 Aug 2021 12:56:08 -0700 Subject: [PATCH 2/5] fix the order of setupPlugins call --- superset-frontend/src/views/CRUD/chart/ChartList.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/superset-frontend/src/views/CRUD/chart/ChartList.tsx b/superset-frontend/src/views/CRUD/chart/ChartList.tsx index be5d3568b699..76e3809d6981 100644 --- a/superset-frontend/src/views/CRUD/chart/ChartList.tsx +++ b/superset-frontend/src/views/CRUD/chart/ChartList.tsx @@ -74,6 +74,7 @@ const CONFIRM_OVERWRITE_MESSAGE = t( 'sure you want to overwrite?', ); +setupPlugins(); const registry = getChartMetadataRegistry(); const createFetchDatasets = (handleError: (err: Response) => void) => async ( @@ -126,8 +127,6 @@ const Actions = styled.div` color: ${({ theme }) => theme.colors.grayscale.base}; `; -setupPlugins(); - function ChartList(props: ChartListProps) { const { addDangerToast, addSuccessToast } = props; From 767fe31c1eca683ed8af88c57579d2df6673280f Mon Sep 17 00:00:00 2001 From: Jesse Yang Date: Tue, 24 Aug 2021 14:19:38 -0700 Subject: [PATCH 3/5] Fix jest test on loading geojson --- superset-frontend/jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/jest.config.js b/superset-frontend/jest.config.js index 191f7a5e1df1..91db278b2c82 100644 --- a/superset-frontend/jest.config.js +++ b/superset-frontend/jest.config.js @@ -19,7 +19,7 @@ module.exports = { testRegex: '(\\/spec|\\/src)\\/.*(_spec|\\.test)\\.(j|t)sx?$', moduleNameMapper: { - '\\.(css|less)$': '/spec/__mocks__/styleMock.js', + '\\.(css|less|geojson)$': '/spec/__mocks__/styleMock.js', '\\.(gif|ttf|eot|png|jpg)$': '/spec/__mocks__/fileMock.js', '\\.svg$': '/spec/__mocks__/svgrMock.tsx', '^src/(.*)$': '/src/$1', From bff75830571b0032297e6797800861c642e5af38 Mon Sep 17 00:00:00 2001 From: Jesse Yang Date: Tue, 24 Aug 2021 14:24:10 -0700 Subject: [PATCH 4/5] add jest changes --- superset-frontend/jest.config.js | 4 ++-- .../spec/__mocks__/{styleMock.js => mockExportObject.js} | 0 .../spec/__mocks__/{fileMock.js => mockExportString.js} | 0 superset-frontend/spec/helpers/setup.ts | 2 ++ 4 files changed, 4 insertions(+), 2 deletions(-) rename superset-frontend/spec/__mocks__/{styleMock.js => mockExportObject.js} (100%) rename superset-frontend/spec/__mocks__/{fileMock.js => mockExportString.js} (100%) diff --git a/superset-frontend/jest.config.js b/superset-frontend/jest.config.js index 91db278b2c82..2d9529f69dd1 100644 --- a/superset-frontend/jest.config.js +++ b/superset-frontend/jest.config.js @@ -19,8 +19,8 @@ module.exports = { testRegex: '(\\/spec|\\/src)\\/.*(_spec|\\.test)\\.(j|t)sx?$', moduleNameMapper: { - '\\.(css|less|geojson)$': '/spec/__mocks__/styleMock.js', - '\\.(gif|ttf|eot|png|jpg)$': '/spec/__mocks__/fileMock.js', + '\\.(css|less|geojson)$': '/spec/__mocks__/mockExportObject.js', + '\\.(gif|ttf|eot|png|jpg)$': '/spec/__mocks__/mockExportString.js', '\\.svg$': '/spec/__mocks__/svgrMock.tsx', '^src/(.*)$': '/src/$1', '^spec/(.*)$': '/spec/$1', diff --git a/superset-frontend/spec/__mocks__/styleMock.js b/superset-frontend/spec/__mocks__/mockExportObject.js similarity index 100% rename from superset-frontend/spec/__mocks__/styleMock.js rename to superset-frontend/spec/__mocks__/mockExportObject.js diff --git a/superset-frontend/spec/__mocks__/fileMock.js b/superset-frontend/spec/__mocks__/mockExportString.js similarity index 100% rename from superset-frontend/spec/__mocks__/fileMock.js rename to superset-frontend/spec/__mocks__/mockExportString.js diff --git a/superset-frontend/spec/helpers/setup.ts b/superset-frontend/spec/helpers/setup.ts index 28abd96bc5c2..c2c991f95621 100644 --- a/superset-frontend/spec/helpers/setup.ts +++ b/superset-frontend/spec/helpers/setup.ts @@ -23,3 +23,5 @@ import { configure as configureTestingLibrary } from '@testing-library/react'; configureTestingLibrary({ testIdAttribute: 'data-test', }); + +document.body.innerHTML = '
'; From 8a0ef8541093799f14f0747951b1657dadb95957 Mon Sep 17 00:00:00 2001 From: Grace Date: Tue, 24 Aug 2021 22:48:50 -0700 Subject: [PATCH 5/5] fix unit tests --- .../src/components/OmniContainer/OmniContainer.test.tsx | 1 + .../src/explore/exploreUtils/getChartDataUri.test.ts | 2 +- .../src/explore/exploreUtils/getExploreUrl.test.ts | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/components/OmniContainer/OmniContainer.test.tsx b/superset-frontend/src/components/OmniContainer/OmniContainer.test.tsx index d797727ed2ad..dd926b632df5 100644 --- a/superset-frontend/src/components/OmniContainer/OmniContainer.test.tsx +++ b/superset-frontend/src/components/OmniContainer/OmniContainer.test.tsx @@ -25,6 +25,7 @@ import OmniContainer from './index'; jest.mock('src/featureFlags', () => ({ isFeatureEnabled: jest.fn(), FeatureFlag: { OMNIBAR: 'OMNIBAR' }, + initFeatureFlags: jest.fn(), })); test('Do not open Omnibar with the featureflag disabled', () => { diff --git a/superset-frontend/src/explore/exploreUtils/getChartDataUri.test.ts b/superset-frontend/src/explore/exploreUtils/getChartDataUri.test.ts index c61612d9c7e3..797b5def3d39 100644 --- a/superset-frontend/src/explore/exploreUtils/getChartDataUri.test.ts +++ b/superset-frontend/src/explore/exploreUtils/getChartDataUri.test.ts @@ -31,7 +31,7 @@ test('Get ChartUri when allowDomainSharding:false', () => { duplicateQueryParameters: false, escapeQuerySpace: true, fragment: null, - hostname: undefined, + hostname: 'localhost', password: null, path: '/path', port: '', diff --git a/superset-frontend/src/explore/exploreUtils/getExploreUrl.test.ts b/superset-frontend/src/explore/exploreUtils/getExploreUrl.test.ts index efa4b6ed8e1c..7457b462b031 100644 --- a/superset-frontend/src/explore/exploreUtils/getExploreUrl.test.ts +++ b/superset-frontend/src/explore/exploreUtils/getExploreUrl.test.ts @@ -33,13 +33,13 @@ const createParams = () => ({ test('Get ExploreUrl with default params', () => { const params = createParams(); - expect(getExploreUrl(params)).toBe('http:///superset/explore/'); + expect(getExploreUrl(params)).toBe('http://localhost/superset/explore/'); }); test('Get ExploreUrl with endpointType:full', () => { const params = createParams(); expect(getExploreUrl({ ...params, endpointType: 'full' })).toBe( - 'http:///superset/explore_json/', + 'http://localhost/superset/explore_json/', ); }); @@ -47,5 +47,5 @@ test('Get ExploreUrl with endpointType:full and method:GET', () => { const params = createParams(); expect( getExploreUrl({ ...params, endpointType: 'full', method: 'GET' }), - ).toBe('http:///superset/explore_json/'); + ).toBe('http://localhost/superset/explore_json/'); });