mirror of
https://github.com/apache/superset.git
synced 2026-04-21 17:14:57 +00:00
feat(viz): add query mode switch to table chart (#10113)
1, Replace table chart rendering from jquery.DataTables to react-table: apache-superset/superset-ui#623 2. Rearrange the control panel, replace GROUP BY and NOT GROUP BY with a "Query Mode" switch: apache-superset/superset-ui#609
This commit is contained in:
@@ -62,53 +62,61 @@ describe('AsyncSelect', () => {
|
||||
});
|
||||
|
||||
describe('auto select', () => {
|
||||
it('should not call onChange if autoSelect=false', done => {
|
||||
expect.assertions(2);
|
||||
it('should not call onChange if autoSelect=false', () => {
|
||||
return new Promise(done => {
|
||||
expect.assertions(2);
|
||||
|
||||
const onChangeSpy = jest.fn();
|
||||
shallow(<AsyncSelect {...mockedProps} onChange={onChangeSpy} />);
|
||||
const onChangeSpy = jest.fn();
|
||||
shallow(<AsyncSelect {...mockedProps} onChange={onChangeSpy} />);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(fetchMock.calls(dataGlob)).toHaveLength(1);
|
||||
expect(onChangeSpy.mock.calls).toHaveLength(0);
|
||||
done();
|
||||
setTimeout(() => {
|
||||
expect(fetchMock.calls(dataGlob)).toHaveLength(1);
|
||||
expect(onChangeSpy.mock.calls).toHaveLength(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should auto select the first option if autoSelect=true', done => {
|
||||
expect.assertions(3);
|
||||
it('should auto select the first option if autoSelect=true', () => {
|
||||
return new Promise(done => {
|
||||
expect.assertions(3);
|
||||
|
||||
const onChangeSpy = jest.fn();
|
||||
const wrapper = shallow(
|
||||
<AsyncSelect {...mockedProps} onChange={onChangeSpy} autoSelect />,
|
||||
);
|
||||
const onChangeSpy = jest.fn();
|
||||
const wrapper = shallow(
|
||||
<AsyncSelect {...mockedProps} onChange={onChangeSpy} autoSelect />,
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(fetchMock.calls(dataGlob)).toHaveLength(1);
|
||||
expect(onChangeSpy.mock.calls).toHaveLength(1);
|
||||
expect(onChangeSpy).toBeCalledWith(wrapper.instance().state.options[0]);
|
||||
done();
|
||||
setTimeout(() => {
|
||||
expect(fetchMock.calls(dataGlob)).toHaveLength(1);
|
||||
expect(onChangeSpy.mock.calls).toHaveLength(1);
|
||||
expect(onChangeSpy).toBeCalledWith(
|
||||
wrapper.instance().state.options[0],
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not auto select when value prop is set and autoSelect=true', done => {
|
||||
expect.assertions(3);
|
||||
it('should not auto select when value prop is set and autoSelect=true', () => {
|
||||
return new Promise(done => {
|
||||
expect.assertions(3);
|
||||
|
||||
const onChangeSpy = jest.fn();
|
||||
const wrapper = shallow(
|
||||
<AsyncSelect
|
||||
{...mockedProps}
|
||||
value={2}
|
||||
onChange={onChangeSpy}
|
||||
autoSelect
|
||||
/>,
|
||||
);
|
||||
const onChangeSpy = jest.fn();
|
||||
const wrapper = shallow(
|
||||
<AsyncSelect
|
||||
{...mockedProps}
|
||||
value={2}
|
||||
onChange={onChangeSpy}
|
||||
autoSelect
|
||||
/>,
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(fetchMock.calls(dataGlob)).toHaveLength(1);
|
||||
expect(onChangeSpy.mock.calls).toHaveLength(0);
|
||||
expect(wrapper.find(Select)).toHaveLength(1);
|
||||
done();
|
||||
setTimeout(() => {
|
||||
expect(fetchMock.calls(dataGlob)).toHaveLength(1);
|
||||
expect(onChangeSpy.mock.calls).toHaveLength(0);
|
||||
expect(wrapper.find(Select)).toHaveLength(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import Pagination from 'src/components/Pagination';
|
||||
import { areArraysShallowEqual } from 'src/reduxUtils';
|
||||
import { supersetTheme, ThemeProvider } from '@superset-ui/style';
|
||||
|
||||
export function makeMockLocation(query) {
|
||||
function makeMockLocation(query) {
|
||||
const queryStr = encodeURIComponent(query);
|
||||
return {
|
||||
protocol: 'http:',
|
||||
@@ -292,16 +292,14 @@ Array [
|
||||
...mockedProps,
|
||||
filters: [...mockedProps.filters, { id: 'some_column' }],
|
||||
};
|
||||
try {
|
||||
expect(() => {
|
||||
shallow(<ListView {...props} />, {
|
||||
wrappingComponent: ThemeProvider,
|
||||
wrappingComponentProps: { theme: supersetTheme },
|
||||
});
|
||||
} catch (e) {
|
||||
expect(e).toMatchInlineSnapshot(
|
||||
`[ListViewError: Invalid filter config, some_column is not present in columns]`,
|
||||
);
|
||||
}
|
||||
}).toThrowErrorMatchingInlineSnapshot(
|
||||
'"Invalid filter config, some_column is not present in columns"',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ describe('TableSelector', () => {
|
||||
});
|
||||
|
||||
// Test needs to be fixed: Github issue #7768
|
||||
xit('should dispatch a danger toast on error', () => {
|
||||
it.skip('should dispatch a danger toast on error', () => {
|
||||
fetchMock.get(
|
||||
FETCH_TABLES_GLOB,
|
||||
{ throws: 'error' },
|
||||
@@ -218,7 +218,7 @@ describe('TableSelector', () => {
|
||||
});
|
||||
|
||||
// Test needs to be fixed: Github issue #7768
|
||||
xit('should dispatch a danger toast on error', () => {
|
||||
it.skip('should dispatch a danger toast on error', () => {
|
||||
const handleErrors = sinon.stub();
|
||||
expect(handleErrors.callCount).toBe(0);
|
||||
wrapper.setProps({ handleErrors });
|
||||
|
||||
Reference in New Issue
Block a user