fix: setupPlugin in chart list page (#16413)

* fix: setupPlugin in chart list page

* fix the order of setupPlugins call

* Fix jest test on loading geojson

* add jest changes

* fix unit tests

Co-authored-by: Jesse Yang <jesse.yang@airbnb.com>
This commit is contained in:
Grace Guo 2021-08-24 23:10:46 -07:00 committed by GitHub
parent 78d8089b18
commit 08b8aa277f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 6 deletions

View File

@ -19,8 +19,8 @@
module.exports = {
testRegex: '(\\/spec|\\/src)\\/.*(_spec|\\.test)\\.(j|t)sx?$',
moduleNameMapper: {
'\\.(css|less)$': '<rootDir>/spec/__mocks__/styleMock.js',
'\\.(gif|ttf|eot|png|jpg)$': '<rootDir>/spec/__mocks__/fileMock.js',
'\\.(css|less|geojson)$': '<rootDir>/spec/__mocks__/mockExportObject.js',
'\\.(gif|ttf|eot|png|jpg)$': '<rootDir>/spec/__mocks__/mockExportString.js',
'\\.svg$': '<rootDir>/spec/__mocks__/svgrMock.tsx',
'^src/(.*)$': '<rootDir>/src/$1',
'^spec/(.*)$': '<rootDir>/spec/$1',

View File

@ -23,3 +23,5 @@ import { configure as configureTestingLibrary } from '@testing-library/react';
configureTestingLibrary({
testIdAttribute: 'data-test',
});
document.body.innerHTML = '<div id="app" data-bootstrap="{}"></div>';

View File

@ -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', () => {

View File

@ -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: '',

View File

@ -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/');
});

View File

@ -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;
@ -73,6 +74,7 @@ const CONFIRM_OVERWRITE_MESSAGE = t(
'sure you want to overwrite?',
);
setupPlugins();
const registry = getChartMetadataRegistry();
const createFetchDatasets = (handleError: (err: Response) => void) => async (