mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
[dashboard] fix chart showing loading icon when filter updated immuned fields (#7895)
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user