[dashboard] fix chart showing loading icon when filter updated immuned fields (#7895)

This commit is contained in:
Grace Guo
2019-07-25 10:37:44 -07:00
committed by GitHub
parent 51b34e4751
commit df9efa8ed9
6 changed files with 78 additions and 12 deletions

View File

@@ -66,6 +66,24 @@ describe('Dashboard', () => {
});
describe('refreshExcept', () => {
const overrideDashboardState = {
...dashboardState,
filters: {
1: { region: [] },
2: { country_name: ['USA'] },
3: { region: [], country_name: ['USA'] },
},
refresh: true,
};
const overrideDashboardInfo = {
...dashboardInfo,
metadata: {
...dashboardInfo.metadata,
filter_immune_slice_fields: { [chartQueries[chartId].id]: ['region'] },
},
};
const overrideCharts = {
...chartQueries,
1001: {
@@ -108,6 +126,32 @@ describe('Dashboard', () => {
spy.restore();
expect(spy.callCount).toBe(0);
});
it('should not call triggerQuery for filter_immune_slice_fields', () => {
const wrapper = setup({
dashboardState: overrideDashboardState,
dashboardInfo: overrideDashboardInfo,
});
const spy = sinon.spy(props.actions, 'triggerQuery');
wrapper.instance().refreshExcept('1');
expect(spy.callCount).toBe(0);
spy.restore();
});
it('should call triggerQuery if filter has more filter-able fields', () => {
const wrapper = setup({
dashboardState: overrideDashboardState,
dashboardInfo: overrideDashboardInfo,
});
const spy = sinon.spy(props.actions, 'triggerQuery');
// if filter have additional fields besides immune ones,
// should apply filter.
wrapper.instance().refreshExcept('3');
expect(spy.callCount).toBe(1);
spy.restore();
});
});
describe('componentWillReceiveProps', () => {

View File

@@ -19,7 +19,10 @@
export default {
id: 1234,
slug: 'dashboardSlug',
metadata: {},
metadata: {
filter_immune_slices: [],
filter_immune_slice_fields: {},
},
userId: 'mock_user_id',
dash_edit_perm: true,
dash_save_perm: true,

View File

@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { id as sliceId } from './mockChartQueries';
import { sliceId } from './mockChartQueries';
import { BUILDER_PANE_TYPE } from '../../../../src/dashboard/util/constants';
export default {