mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +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:
@@ -181,36 +181,40 @@ describe('MetricsControl', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('handles aggregates being selected', done => {
|
||||
const { wrapper, onChange } = setup();
|
||||
const select = wrapper.find(OnPasteSelect);
|
||||
it('handles aggregates being selected', () => {
|
||||
return new Promise(done => {
|
||||
const { wrapper, onChange } = setup();
|
||||
const select = wrapper.find(OnPasteSelect);
|
||||
|
||||
// mock out the Select ref
|
||||
const instance = wrapper.instance();
|
||||
const handleInputChangeSpy = jest.fn();
|
||||
const focusInputSpy = jest.fn();
|
||||
// simulate react-select StateManager
|
||||
instance.selectRef({
|
||||
select: {
|
||||
handleInputChange: handleInputChangeSpy,
|
||||
inputRef: { value: '' },
|
||||
focusInput: focusInputSpy,
|
||||
},
|
||||
});
|
||||
// mock out the Select ref
|
||||
const instance = wrapper.instance();
|
||||
const handleInputChangeSpy = jest.fn();
|
||||
const focusInputSpy = jest.fn();
|
||||
// simulate react-select StateManager
|
||||
instance.selectRef({
|
||||
select: {
|
||||
handleInputChange: handleInputChangeSpy,
|
||||
inputRef: { value: '' },
|
||||
focusInput: focusInputSpy,
|
||||
},
|
||||
});
|
||||
|
||||
select.simulate('change', [{ aggregate_name: 'SUM', optionName: 'SUM' }]);
|
||||
select.simulate('change', [
|
||||
{ aggregate_name: 'SUM', optionName: 'SUM' },
|
||||
]);
|
||||
|
||||
expect(instance.select.inputRef.value).toBe('SUM()');
|
||||
expect(handleInputChangeSpy).toHaveBeenCalledWith({
|
||||
currentTarget: { value: 'SUM()' },
|
||||
});
|
||||
expect(onChange.calledOnceWith([])).toBe(true);
|
||||
expect(focusInputSpy).toHaveBeenCalledTimes(0);
|
||||
setTimeout(() => {
|
||||
expect(focusInputSpy).toHaveBeenCalledTimes(1);
|
||||
expect(instance.select.inputRef.selectionStart).toBe(4);
|
||||
expect(instance.select.inputRef.selectionEnd).toBe(4);
|
||||
done();
|
||||
expect(instance.select.inputRef.value).toBe('SUM()');
|
||||
expect(handleInputChangeSpy).toHaveBeenCalledWith({
|
||||
currentTarget: { value: 'SUM()' },
|
||||
});
|
||||
expect(onChange.calledOnceWith([])).toBe(true);
|
||||
expect(focusInputSpy).toHaveBeenCalledTimes(0);
|
||||
setTimeout(() => {
|
||||
expect(focusInputSpy).toHaveBeenCalledTimes(1);
|
||||
expect(instance.select.inputRef.selectionStart).toBe(4);
|
||||
expect(instance.select.inputRef.selectionEnd).toBe(4);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user