mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
[dashboard] After update filter, trigger new queries when charts are visible (#7233)
* trigger query when chart is visible * add integration test
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
import React from 'react';
|
||||
import configureStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
import sinon from 'sinon';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import getInitialState from 'src/explore/reducers/getInitialState';
|
||||
@@ -58,7 +59,7 @@ describe('ExploreViewContainer', () => {
|
||||
wrapper = shallow(<ExploreViewContainer />, {
|
||||
context: { store },
|
||||
disableLifecycleMethods: true,
|
||||
});
|
||||
}).dive();
|
||||
});
|
||||
|
||||
it('renders', () => {
|
||||
@@ -68,14 +69,37 @@ describe('ExploreViewContainer', () => {
|
||||
});
|
||||
|
||||
it('renders QueryAndSaveButtons', () => {
|
||||
expect(wrapper.dive().find(QueryAndSaveBtns)).toHaveLength(1);
|
||||
expect(wrapper.find(QueryAndSaveBtns)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('renders ControlPanelsContainer', () => {
|
||||
expect(wrapper.dive().find(ControlPanelsContainer)).toHaveLength(1);
|
||||
expect(wrapper.find(ControlPanelsContainer)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('renders ChartContainer', () => {
|
||||
expect(wrapper.dive().find(ChartContainer)).toHaveLength(1);
|
||||
expect(wrapper.find(ChartContainer)).toHaveLength(1);
|
||||
});
|
||||
|
||||
describe('componentWillReceiveProps()', () => {
|
||||
it('when controls change, should call resetControls', () => {
|
||||
expect(wrapper.instance().props.controls.viz_type.value).toBe('table');
|
||||
const resetControls = sinon.stub(wrapper.instance().props.actions, 'resetControls');
|
||||
const triggerQuery = sinon.stub(wrapper.instance().props.actions, 'triggerQuery');
|
||||
|
||||
// triggers componentWillReceiveProps
|
||||
wrapper.setProps({
|
||||
controls: {
|
||||
viz_type: {
|
||||
value: 'bar',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(resetControls.callCount).toBe(1);
|
||||
// exploreview container should not force chart run query
|
||||
// it should be controlled by redux state.
|
||||
expect(triggerQuery.callCount).toBe(0);
|
||||
resetControls.reset();
|
||||
triggerQuery.reset();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user