Skip to content

Commit

Permalink
fix: setupPlugin in chart list page (apache#16413)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Grace Guo and ktmud authored Aug 25, 2021
1 parent 78d8089 commit 08b8aa2
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions superset-frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/spec/helpers/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ 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/',
);
});

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/');
});
2 changes: 2 additions & 0 deletions superset-frontend/src/views/CRUD/chart/ChartList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 (
Expand Down

0 comments on commit 08b8aa2

Please sign in to comment.