mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
committed by
GitHub
parent
4d04565c9a
commit
20503f92ae
@@ -49,6 +49,7 @@ describe('ExploreResultsButton', () => {
|
||||
database,
|
||||
show: true,
|
||||
query: queries[0],
|
||||
onClick() {},
|
||||
};
|
||||
const mockColumns = {
|
||||
ds: {
|
||||
@@ -90,6 +91,7 @@ describe('ExploreResultsButton', () => {
|
||||
database,
|
||||
show: true,
|
||||
query: queryWithBadColumns,
|
||||
onClick() {},
|
||||
});
|
||||
|
||||
const badCols = wrapper.instance().getInvalidColumns();
|
||||
@@ -147,6 +149,7 @@ describe('ExploreResultsButton', () => {
|
||||
show: true,
|
||||
query: longQuery,
|
||||
database,
|
||||
onClick() {},
|
||||
};
|
||||
const longQueryWrapper = shallow(
|
||||
<ExploreResultsButton store={store} {...props} />,
|
||||
|
||||
@@ -26,9 +26,10 @@ import { queries } from './fixtures';
|
||||
describe('QueryTable', () => {
|
||||
const mockedProps = {
|
||||
queries,
|
||||
displayLimit: 100,
|
||||
};
|
||||
it('is valid', () => {
|
||||
expect(React.isValidElement(<QueryTable />)).toBe(true);
|
||||
expect(React.isValidElement(<QueryTable displayLimit={100} />)).toBe(true);
|
||||
});
|
||||
it('is valid with props', () => {
|
||||
expect(React.isValidElement(<QueryTable {...mockedProps} />)).toBe(true);
|
||||
|
||||
@@ -23,6 +23,8 @@ import URI from 'urijs';
|
||||
import { Provider } from 'react-redux';
|
||||
import { shallow, mount } from 'enzyme';
|
||||
import sinon from 'sinon';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import fetchMock from 'fetch-mock';
|
||||
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
||||
import { EditableTabs } from 'src/common/components/Tabs';
|
||||
import TabbedSqlEditors from 'src/SqlLab/components/TabbedSqlEditors';
|
||||
@@ -30,6 +32,10 @@ import SqlEditor from 'src/SqlLab/components/SqlEditor';
|
||||
|
||||
import { table, initialState } from './fixtures';
|
||||
|
||||
fetchMock.get('glob:*/api/v1/database/*', {});
|
||||
fetchMock.get('glob:*/savedqueryviewapi/api/get/*', {});
|
||||
fetchMock.get('glob:*/kv/*', {});
|
||||
|
||||
describe('TabbedSqlEditors', () => {
|
||||
const middlewares = [thunk];
|
||||
const mockStore = configureStore(middlewares);
|
||||
@@ -58,6 +64,7 @@ describe('TabbedSqlEditors', () => {
|
||||
id: 'B1-VQU1zW',
|
||||
sqlEditorId: 'newEditorId',
|
||||
tableName: 'ab_user',
|
||||
state: 'success',
|
||||
},
|
||||
};
|
||||
const mockedProps = {
|
||||
@@ -78,6 +85,19 @@ describe('TabbedSqlEditors', () => {
|
||||
.dive()
|
||||
.dive();
|
||||
|
||||
const mountWithAct = async () =>
|
||||
act(async () => {
|
||||
mount(
|
||||
<Provider store={store}>
|
||||
<TabbedSqlEditors {...mockedProps} />
|
||||
</Provider>,
|
||||
{
|
||||
wrappingComponent: ThemeProvider,
|
||||
wrappingComponentProps: { theme: supersetTheme },
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
let wrapper;
|
||||
it('is valid', () => {
|
||||
expect(React.isValidElement(<TabbedSqlEditors {...mockedProps} />)).toBe(
|
||||
@@ -88,64 +108,29 @@ describe('TabbedSqlEditors', () => {
|
||||
let uriStub;
|
||||
beforeEach(() => {
|
||||
sinon.stub(window.history, 'replaceState');
|
||||
// sinon.spy(TabbedSqlEditors.prototype, 'componentDidMount');
|
||||
uriStub = sinon.stub(URI.prototype, 'search');
|
||||
});
|
||||
afterEach(() => {
|
||||
window.history.replaceState.restore();
|
||||
// TabbedSqlEditors.prototype.componentDidMount.restore();
|
||||
uriStub.restore();
|
||||
});
|
||||
it('should handle id', () => {
|
||||
it('should handle id', async () => {
|
||||
uriStub.returns({ id: 1 });
|
||||
wrapper = mount(
|
||||
<Provider store={store}>
|
||||
<TabbedSqlEditors {...mockedProps} />
|
||||
</Provider>,
|
||||
{
|
||||
wrappingComponent: ThemeProvider,
|
||||
wrappingComponentProps: { theme: supersetTheme },
|
||||
},
|
||||
);
|
||||
/* expect(TabbedSqlEditors.prototype.componentDidMount.calledOnce).toBe(
|
||||
true,
|
||||
); */
|
||||
await mountWithAct();
|
||||
expect(window.history.replaceState.getCall(0).args[2]).toBe(
|
||||
'/superset/sqllab',
|
||||
);
|
||||
});
|
||||
it('should handle savedQueryId', () => {
|
||||
it('should handle savedQueryId', async () => {
|
||||
uriStub.returns({ savedQueryId: 1 });
|
||||
wrapper = mount(
|
||||
<Provider store={store}>
|
||||
<TabbedSqlEditors {...mockedProps} />
|
||||
</Provider>,
|
||||
{
|
||||
wrappingComponent: ThemeProvider,
|
||||
wrappingComponentProps: { theme: supersetTheme },
|
||||
},
|
||||
);
|
||||
/* expect(TabbedSqlEditors.prototype.componentDidMount.calledOnce).toBe(
|
||||
true,
|
||||
); */
|
||||
await mountWithAct();
|
||||
expect(window.history.replaceState.getCall(0).args[2]).toBe(
|
||||
'/superset/sqllab',
|
||||
);
|
||||
});
|
||||
it('should handle sql', () => {
|
||||
it('should handle sql', async () => {
|
||||
uriStub.returns({ sql: 1, dbid: 1 });
|
||||
wrapper = mount(
|
||||
<Provider store={store}>
|
||||
<TabbedSqlEditors {...mockedProps} />
|
||||
</Provider>,
|
||||
{
|
||||
wrappingComponent: ThemeProvider,
|
||||
wrappingComponentProps: { theme: supersetTheme },
|
||||
},
|
||||
);
|
||||
/* expect(TabbedSqlEditors.prototype.componentDidMount.calledOnce).toBe(
|
||||
true,
|
||||
); */
|
||||
await mountWithAct();
|
||||
expect(window.history.replaceState.getCall(0).args[2]).toBe(
|
||||
'/superset/sqllab',
|
||||
);
|
||||
|
||||
@@ -478,6 +478,7 @@ export const initialState = {
|
||||
conf: {
|
||||
DEFAULT_SQLLAB_LIMIT: 1000,
|
||||
SQL_MAX_ROW: 100000,
|
||||
DISPLAY_MAX_ROW: 100,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user