[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:
Grace Guo
2019-05-07 23:41:18 -07:00
committed by GitHub
parent 959c35d506
commit 6b8bda6096
21 changed files with 591 additions and 57 deletions

View File

@@ -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();
});
});
});