mirror of
https://github.com/apache/superset.git
synced 2026-04-23 01:55:09 +00:00
committed by
GitHub
parent
0fc9da6be7
commit
0c08bb87c3
@@ -28,4 +28,5 @@ export default {
|
|||||||
isPublished: true,
|
isPublished: true,
|
||||||
css: '',
|
css: '',
|
||||||
focusedFilterField: null,
|
focusedFilterField: null,
|
||||||
|
refreshFrequency: 0,
|
||||||
};
|
};
|
||||||
|
|||||||
4
superset-frontend/spec/fixtures/mockState.js
vendored
4
superset-frontend/spec/fixtures/mockState.js
vendored
@@ -24,11 +24,11 @@ import { dashboardLayout } from './mockDashboardLayout';
|
|||||||
import dashboardInfo from './mockDashboardInfo';
|
import dashboardInfo from './mockDashboardInfo';
|
||||||
import { emptyFilters } from './mockDashboardFilters';
|
import { emptyFilters } from './mockDashboardFilters';
|
||||||
import dashboardState from './mockDashboardState';
|
import dashboardState from './mockDashboardState';
|
||||||
import sliceEntities from './mockSliceEntities';
|
import { sliceEntitiesForChart } from './mockSliceEntities';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
datasources,
|
datasources,
|
||||||
sliceEntities,
|
sliceEntities: sliceEntitiesForChart,
|
||||||
charts: chartQueries,
|
charts: chartQueries,
|
||||||
nativeFilters: nativeFiltersInfo,
|
nativeFilters: nativeFiltersInfo,
|
||||||
dashboardInfo,
|
dashboardInfo,
|
||||||
|
|||||||
@@ -160,9 +160,13 @@ describe('AlteredSliceTag', () => {
|
|||||||
);
|
);
|
||||||
const rows = getTableWrapperFromModalBody(modalBody).find('tr');
|
const rows = getTableWrapperFromModalBody(modalBody).find('tr');
|
||||||
expect(rows).toHaveLength(8);
|
expect(rows).toHaveLength(8);
|
||||||
const fakeRow = mount(<div>{rows.get(1)}</div>);
|
const slice = mount(
|
||||||
expect(fakeRow.find('tr')).toHaveLength(1);
|
<table>
|
||||||
expect(fakeRow.find('td')).toHaveLength(3);
|
<tbody>{rows.get(1)}</tbody>
|
||||||
|
</table>,
|
||||||
|
);
|
||||||
|
expect(slice.find('tr')).toHaveLength(1);
|
||||||
|
expect(slice.find('td')).toHaveLength(3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Button from 'src/components/Button';
|
import Button from 'src/components/Button';
|
||||||
|
import { act } from 'react-dom/test-utils';
|
||||||
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
||||||
import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
|
import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
|
||||||
import Modal from 'src/common/components/Modal';
|
import Modal from 'src/common/components/Modal';
|
||||||
@@ -44,7 +45,9 @@ describe('ConfirmStatusChange', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
it('opens a confirm modal', () => {
|
it('opens a confirm modal', () => {
|
||||||
wrapper.find('#btn1').first().props().onClick('foo');
|
act(() => {
|
||||||
|
wrapper.find('#btn1').first().props().onClick('foo');
|
||||||
|
});
|
||||||
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
|
|
||||||
@@ -52,7 +55,9 @@ describe('ConfirmStatusChange', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('calls the function on confirm', () => {
|
it('calls the function on confirm', () => {
|
||||||
wrapper.find(Button).last().props().onClick();
|
act(() => {
|
||||||
|
wrapper.find(Button).last().props().onClick();
|
||||||
|
});
|
||||||
|
|
||||||
expect(mockedProps.onConfirm).toHaveBeenCalledWith('foo');
|
expect(mockedProps.onConfirm).toHaveBeenCalledWith('foo');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -150,37 +150,40 @@ describe('ListView', () => {
|
|||||||
|
|
||||||
it('calls fetchData on mount', () => {
|
it('calls fetchData on mount', () => {
|
||||||
expect(wrapper.find(ListView)).toExist();
|
expect(wrapper.find(ListView)).toExist();
|
||||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(`
|
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(
|
||||||
Array [
|
`
|
||||||
Object {
|
Array [
|
||||||
"filters": Array [],
|
Object {
|
||||||
"pageIndex": 0,
|
"filters": Array [],
|
||||||
"pageSize": 1,
|
"pageIndex": 0,
|
||||||
"sortBy": Array [],
|
"pageSize": 1,
|
||||||
},
|
"sortBy": Array [],
|
||||||
]
|
},
|
||||||
`);
|
]
|
||||||
|
`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls fetchData on sort', () => {
|
it('calls fetchData on sort', () => {
|
||||||
wrapper.find('[data-test="sort-header"]').at(1).simulate('click');
|
wrapper.find('[data-test="sort-header"]').at(1).simulate('click');
|
||||||
|
|
||||||
expect(mockedProps.fetchData).toHaveBeenCalled();
|
expect(mockedProps.fetchData).toHaveBeenCalled();
|
||||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(`
|
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(
|
||||||
Array [
|
`
|
||||||
Object {
|
Array [
|
||||||
"filters": Array [],
|
Object {
|
||||||
"pageIndex": 0,
|
"filters": Array [],
|
||||||
"pageSize": 1,
|
"pageIndex": 0,
|
||||||
"sortBy": Array [
|
"pageSize": 1,
|
||||||
Object {
|
"sortBy": Array [
|
||||||
"desc": false,
|
Object {
|
||||||
"id": "id",
|
"desc": false,
|
||||||
},
|
"id": "id",
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
]
|
},
|
||||||
`);
|
]
|
||||||
|
`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders pagination controls', () => {
|
it('renders pagination controls', () => {
|
||||||
@@ -363,13 +366,14 @@ describe('ListView', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders and empty state when there is no data', () => {
|
it('renders and empty state when there is no data', async () => {
|
||||||
const props = {
|
const props = {
|
||||||
...mockedProps,
|
...mockedProps,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const wrapper2 = factory(props);
|
const wrapper2 = factory(props);
|
||||||
|
await waitForComponentToPaint(wrapper2);
|
||||||
expect(wrapper2.find(Empty)).toExist();
|
expect(wrapper2.find(Empty)).toExist();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -461,7 +465,7 @@ describe('ListView', () => {
|
|||||||
initialSort: [{ id: 'something' }],
|
initialSort: [{ id: 'something' }],
|
||||||
});
|
});
|
||||||
|
|
||||||
act(() => {
|
await act(async () => {
|
||||||
wrapper2.find('[data-test="card-sort-select"]').first().props().onChange({
|
wrapper2.find('[data-test="card-sort-select"]').first().props().onChange({
|
||||||
desc: false,
|
desc: false,
|
||||||
id: 'something',
|
id: 'something',
|
||||||
@@ -470,7 +474,6 @@ describe('ListView', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper2.update();
|
|
||||||
expect(mockedProps.fetchData).toHaveBeenCalled();
|
expect(mockedProps.fetchData).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,10 +23,13 @@ import { Provider } from 'react-redux';
|
|||||||
import configureStore from 'redux-mock-store';
|
import configureStore from 'redux-mock-store';
|
||||||
import SupersetResourceSelect from 'src/components/SupersetResourceSelect';
|
import SupersetResourceSelect from 'src/components/SupersetResourceSelect';
|
||||||
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
||||||
|
import fetchMock from 'fetch-mock';
|
||||||
|
|
||||||
describe('SupersetResourceSelect', () => {
|
describe('SupersetResourceSelect', () => {
|
||||||
const NOOP = () => {};
|
const NOOP = () => {};
|
||||||
|
|
||||||
|
fetchMock.get('glob:*/api/v1/dataset/?q=*', {});
|
||||||
|
|
||||||
it('is a valid element', () => {
|
it('is a valid element', () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { Provider } from 'react-redux';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow, mount } from 'enzyme';
|
import { shallow, mount } from 'enzyme';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
|
import fetchMock from 'fetch-mock';
|
||||||
import { ParentSize } from '@vx/responsive';
|
import { ParentSize } from '@vx/responsive';
|
||||||
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
||||||
import { Sticky, StickyContainer } from 'react-sticky';
|
import { Sticky, StickyContainer } from 'react-sticky';
|
||||||
@@ -44,6 +44,8 @@ import WithDragDropContext from 'spec/helpers/WithDragDropContext';
|
|||||||
const dashboardLayout = undoableDashboardLayout.present;
|
const dashboardLayout = undoableDashboardLayout.present;
|
||||||
const layoutWithTabs = undoableDashboardLayoutWithTabs.present;
|
const layoutWithTabs = undoableDashboardLayoutWithTabs.present;
|
||||||
|
|
||||||
|
fetchMock.get('glob:*/csstemplateasyncmodelview/api/read', {});
|
||||||
|
|
||||||
describe('DashboardBuilder', () => {
|
describe('DashboardBuilder', () => {
|
||||||
let favStarStub;
|
let favStarStub;
|
||||||
|
|
||||||
@@ -67,6 +69,7 @@ describe('DashboardBuilder', () => {
|
|||||||
colorScheme: undefined,
|
colorScheme: undefined,
|
||||||
handleComponentDrop() {},
|
handleComponentDrop() {},
|
||||||
setDirectPathToChild: sinon.spy(),
|
setDirectPathToChild: sinon.spy(),
|
||||||
|
setMountedTab() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
function setup(overrideProps, useProvider = false, store = mockStore) {
|
function setup(overrideProps, useProvider = false, store = mockStore) {
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ describe('DashboardGrid', () => {
|
|||||||
handleComponentDrop() {},
|
handleComponentDrop() {},
|
||||||
resizeComponent() {},
|
resizeComponent() {},
|
||||||
width: 500,
|
width: 500,
|
||||||
|
isComponentVisible: true,
|
||||||
|
setDirectPathToChild() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
function setup(overrideProps) {
|
function setup(overrideProps) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { shallow } from 'enzyme';
|
|||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import { LineEditableTabs } from 'src/common/components/Tabs';
|
import { LineEditableTabs } from 'src/common/components/Tabs';
|
||||||
import { Modal } from 'src/common/components';
|
import { Modal } from 'src/common/components';
|
||||||
|
import fetchMock from 'fetch-mock';
|
||||||
import { styledMount as mount } from 'spec/helpers/theming';
|
import { styledMount as mount } from 'spec/helpers/theming';
|
||||||
import DashboardComponent from 'src/dashboard/containers/DashboardComponent';
|
import DashboardComponent from 'src/dashboard/containers/DashboardComponent';
|
||||||
import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
|
import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
|
||||||
@@ -35,6 +35,8 @@ import { dashboardLayoutWithTabs } from 'spec/fixtures/mockDashboardLayout';
|
|||||||
import { mockStoreWithTabs } from 'spec/fixtures/mockStore';
|
import { mockStoreWithTabs } from 'spec/fixtures/mockStore';
|
||||||
|
|
||||||
describe('Tabs', () => {
|
describe('Tabs', () => {
|
||||||
|
fetchMock.post('glob:*/r/shortner/', {});
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
id: 'TABS_ID',
|
id: 'TABS_ID',
|
||||||
parentId: DASHBOARD_ROOT_ID,
|
parentId: DASHBOARD_ROOT_ID,
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export default function LanguagePicker({
|
|||||||
<NavDropdown
|
<NavDropdown
|
||||||
onMouseEnter={() => setDropdownOpen(true)}
|
onMouseEnter={() => setDropdownOpen(true)}
|
||||||
onMouseLeave={() => setDropdownOpen(false)}
|
onMouseLeave={() => setDropdownOpen(false)}
|
||||||
|
onToggle={value => setDropdownOpen(value)}
|
||||||
open={dropdownOpen}
|
open={dropdownOpen}
|
||||||
id="locale-dropdown"
|
id="locale-dropdown"
|
||||||
title={
|
title={
|
||||||
|
|||||||
Reference in New Issue
Block a user