This is an automated email from the ASF dual-hosted git repository. graceguo pushed a commit to branch gg-Test-Scoped-Filters in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit a4e3ca22355e483ce65f7da67cfaa70e32a93ee4 Author: Grace <[email protected]> AuthorDate: Mon Nov 11 02:04:46 2019 -0800 fix/add unit tests --- .../dashboard/actions/dashboardLayout_spec.js | 70 ++++++++---- .../dashboard/components/Dashboard_spec.jsx | 121 ++++----------------- .../components/FilterIndicatorsContainer_spec.jsx | 43 +++++--- .../dashboard/fixtures/mockDashboardFilters.js | 1 + .../dashboard/fixtures/mockDashboardLayout.js | 51 +++++++++ .../dashboard/reducers/dashboardFilters_spec.js | 4 +- .../dashboard/util/getDashboardUrl_spec.js | 8 +- .../util/getFormDataWithExtraFilters_spec.js | 32 +----- 8 files changed, 163 insertions(+), 167 deletions(-) diff --git a/superset/assets/spec/javascripts/dashboard/actions/dashboardLayout_spec.js b/superset/assets/spec/javascripts/dashboard/actions/dashboardLayout_spec.js index 0dfca9c..1da0568 100644 --- a/superset/assets/spec/javascripts/dashboard/actions/dashboardLayout_spec.js +++ b/superset/assets/spec/javascripts/dashboard/actions/dashboardLayout_spec.js @@ -39,6 +39,7 @@ import { } from '../../../../src/dashboard/actions/dashboardLayout'; import { setUnsavedChanges } from '../../../../src/dashboard/actions/dashboardState'; +import * as dashboardFilters from '../../../../src/dashboard/actions/dashboardFilters'; import { addWarningToast, ADD_TOAST, @@ -80,6 +81,12 @@ describe('dashboardLayout actions', () => { return { getState, dispatch, state }; } + beforeEach(() => { + sinon.spy(dashboardFilters, 'updateLayoutComponents'); + }); + afterEach(() => { + dashboardFilters.updateLayoutComponents.restore(); + }); describe('updateComponents', () => { it('should dispatch an updateLayout action', () => { @@ -92,6 +99,9 @@ describe('dashboardLayout actions', () => { type: UPDATE_COMPONENTS, payload: { nextComponents }, }); + + // update component should not trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(0); }); it('should dispatch a setUnsavedChanges action if hasUnsavedChanges=false', () => { @@ -101,8 +111,10 @@ describe('dashboardLayout actions', () => { const nextComponents = { 1: {} }; const thunk = updateComponents(nextComponents); thunk(dispatch, getState); - expect(dispatch.callCount).toBe(2); expect(dispatch.getCall(1).args[0]).toEqual(setUnsavedChanges(true)); + + // update component should not trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(0); }); }); @@ -111,11 +123,13 @@ describe('dashboardLayout actions', () => { const { getState, dispatch } = setup(); const thunk = deleteComponent('id', 'parentId'); thunk(dispatch, getState); - expect(dispatch.callCount).toBe(1); expect(dispatch.getCall(0).args[0]).toEqual({ type: DELETE_COMPONENT, payload: { id: 'id', parentId: 'parentId' }, }); + + // delete components should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); it('should dispatch a setUnsavedChanges action if hasUnsavedChanges=false', () => { @@ -124,8 +138,10 @@ describe('dashboardLayout actions', () => { }); const thunk = deleteComponent('id', 'parentId'); thunk(dispatch, getState); - expect(dispatch.callCount).toBe(2); - expect(dispatch.getCall(1).args[0]).toEqual(setUnsavedChanges(true)); + expect(dispatch.getCall(2).args[0]).toEqual(setUnsavedChanges(true)); + + // delete components should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); }); @@ -149,7 +165,8 @@ describe('dashboardLayout actions', () => { }, }); - expect(dispatch.callCount).toBe(2); + // update dashboard title should not trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(0); }); }); @@ -159,11 +176,13 @@ describe('dashboardLayout actions', () => { const dropResult = {}; const thunk = createTopLevelTabs(dropResult); thunk(dispatch, getState); - expect(dispatch.callCount).toBe(1); expect(dispatch.getCall(0).args[0]).toEqual({ type: CREATE_TOP_LEVEL_TABS, payload: { dropResult }, }); + + // create top level tabs should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); it('should dispatch a setUnsavedChanges action if hasUnsavedChanges=false', () => { @@ -173,8 +192,10 @@ describe('dashboardLayout actions', () => { const dropResult = {}; const thunk = createTopLevelTabs(dropResult); thunk(dispatch, getState); - expect(dispatch.callCount).toBe(2); - expect(dispatch.getCall(1).args[0]).toEqual(setUnsavedChanges(true)); + expect(dispatch.getCall(2).args[0]).toEqual(setUnsavedChanges(true)); + + // create top level tabs should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); }); @@ -184,11 +205,13 @@ describe('dashboardLayout actions', () => { const dropResult = {}; const thunk = deleteTopLevelTabs(dropResult); thunk(dispatch, getState); - expect(dispatch.callCount).toBe(1); expect(dispatch.getCall(0).args[0]).toEqual({ type: DELETE_TOP_LEVEL_TABS, payload: {}, }); + + // delete top level tabs should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); it('should dispatch a setUnsavedChanges action if hasUnsavedChanges=false', () => { @@ -198,8 +221,10 @@ describe('dashboardLayout actions', () => { const dropResult = {}; const thunk = deleteTopLevelTabs(dropResult); thunk(dispatch, getState); - expect(dispatch.callCount).toBe(2); - expect(dispatch.getCall(1).args[0]).toEqual(setUnsavedChanges(true)); + expect(dispatch.getCall(2).args[0]).toEqual(setUnsavedChanges(true)); + + // delete top level tabs should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); }); @@ -261,6 +286,9 @@ describe('dashboardLayout actions', () => { thunk2(dispatch, getState); expect(dispatch.callCount).toBe(3); + + // resize components should not trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(0); }); }); @@ -286,7 +314,8 @@ describe('dashboardLayout actions', () => { }, }); - expect(dispatch.callCount).toBe(2); + // create components should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); it('should move a component if the component is not new', () => { @@ -315,7 +344,8 @@ describe('dashboardLayout actions', () => { }, }); - expect(dispatch.callCount).toBe(2); + // create components should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); it('should dispatch a toast if the drop overflows the destination', () => { @@ -379,9 +409,6 @@ describe('dashboardLayout actions', () => { parentId: 'parentId', }, }); - - // move thunk, delete thunk, delete result actions - expect(dispatch.callCount).toBe(3); }); it('should create top-level tabs if dropped on root', () => { @@ -404,8 +431,6 @@ describe('dashboardLayout actions', () => { dropResult, }, }); - - expect(dispatch.callCount).toBe(2); }); it('should dispatch a toast if drop top-level tab into nested tab', () => { @@ -497,8 +522,10 @@ describe('dashboardLayout actions', () => { const thunk = redoLayoutAction(); thunk(dispatch, getState); - expect(dispatch.callCount).toBe(1); expect(dispatch.getCall(0).args[0]).toEqual(UndoActionCreators.redo()); + + // redo/undo should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); it('should dispatch a setUnsavedChanges(true) action if hasUnsavedChanges=false', () => { @@ -507,9 +534,10 @@ describe('dashboardLayout actions', () => { }); const thunk = redoLayoutAction(); thunk(dispatch, getState); + expect(dispatch.getCall(2).args[0]).toEqual(setUnsavedChanges(true)); - expect(dispatch.callCount).toBe(2); - expect(dispatch.getCall(1).args[0]).toEqual(setUnsavedChanges(true)); + // redo/undo should trigger action for dashboardFilters + expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1); }); }); }); diff --git a/superset/assets/spec/javascripts/dashboard/components/Dashboard_spec.jsx b/superset/assets/spec/javascripts/dashboard/components/Dashboard_spec.jsx index 02e71e4..fbf44fa 100644 --- a/superset/assets/spec/javascripts/dashboard/components/Dashboard_spec.jsx +++ b/superset/assets/spec/javascripts/dashboard/components/Dashboard_spec.jsx @@ -24,7 +24,7 @@ import Dashboard from '../../../../src/dashboard/components/Dashboard'; import DashboardBuilder from '../../../../src/dashboard/containers/DashboardBuilder'; // mock data -import chartQueries, { sliceId as chartId } from '../fixtures/mockChartQueries'; +import chartQueries from '../fixtures/mockChartQueries'; import datasources from '../../../fixtures/mockDatasource'; import dashboardInfo from '../fixtures/mockDashboardInfo'; import { dashboardLayout } from '../fixtures/mockDashboardLayout'; @@ -46,7 +46,7 @@ describe('Dashboard', () => { dashboardState, dashboardInfo, charts: chartQueries, - filters: {}, + activeFilters: {}, slices: sliceEntities.slices, datasources, layout: dashboardLayout.present, @@ -61,10 +61,12 @@ describe('Dashboard', () => { return wrapper; } + // activeFilters map use id_column) as key const OVERRIDE_FILTERS = { - 1: { region: [] }, - 2: { country_name: ['USA'] }, - 3: { region: [], country_name: ['USA'] }, + '1_region': [], + '2_country_name': ['USA'], + '3_region': [], + '3_country_name': ['USA'], }; it('should render a DashboardBuilder', () => { @@ -72,85 +74,6 @@ describe('Dashboard', () => { expect(wrapper.find(DashboardBuilder)).toHaveLength(1); }); - describe('refreshExcept', () => { - const overrideDashboardInfo = { - ...dashboardInfo, - metadata: { - ...dashboardInfo.metadata, - filterImmuneSliceFields: { [chartQueries[chartId].id]: ['region'] }, - }, - }; - - const overrideCharts = { - ...chartQueries, - 1001: { - ...chartQueries[chartId], - id: 1001, - }, - }; - - const overrideSlices = { - ...props.slices, - 1001: { - ...props.slices[chartId], - slice_id: 1001, - }, - }; - - it('should call triggerQuery for all non-exempt slices', () => { - const wrapper = setup({ charts: overrideCharts, slices: overrideSlices }); - const spy = sinon.spy(props.actions, 'triggerQuery'); - wrapper.instance().refreshExcept('1001'); - spy.restore(); - expect(spy.callCount).toBe(Object.keys(overrideCharts).length - 1); - }); - - it('should not call triggerQuery for filterImmuneSlices', () => { - const wrapper = setup({ - charts: overrideCharts, - dashboardInfo: { - ...dashboardInfo, - metadata: { - ...dashboardInfo.metadata, - filterImmuneSlices: Object.keys(overrideCharts).map(id => - Number(id), - ), - }, - }, - }); - const spy = sinon.spy(props.actions, 'triggerQuery'); - wrapper.instance().refreshExcept(); - spy.restore(); - expect(spy.callCount).toBe(0); - }); - - it('should not call triggerQuery for filterImmuneSliceFields', () => { - const wrapper = setup({ - filters: OVERRIDE_FILTERS, - 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({ - filters: OVERRIDE_FILTERS, - 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', () => { const layoutWithExtraChart = { ...props.layout, @@ -186,17 +109,17 @@ describe('Dashboard', () => { describe('componentDidUpdate', () => { let wrapper; let prevProps; - let refreshExceptSpy; + let refreshSpy; beforeEach(() => { - wrapper = setup({ filters: OVERRIDE_FILTERS }); + wrapper = setup({ activeFilters: OVERRIDE_FILTERS }); wrapper.instance().appliedFilters = OVERRIDE_FILTERS; prevProps = wrapper.instance().props; - refreshExceptSpy = sinon.spy(wrapper.instance(), 'refreshExcept'); + refreshSpy = sinon.spy(wrapper.instance(), 'refreshCharts'); }); afterEach(() => { - refreshExceptSpy.restore(); + refreshSpy.restore(); }); it('should not call refresh when is editMode', () => { @@ -207,15 +130,15 @@ describe('Dashboard', () => { }, }); wrapper.instance().componentDidUpdate(prevProps); - expect(refreshExceptSpy.callCount).toBe(0); + expect(refreshSpy.callCount).toBe(0); }); it('should not call refresh when there is no change', () => { wrapper.setProps({ - filters: OVERRIDE_FILTERS, + activeFilters: OVERRIDE_FILTERS, }); wrapper.instance().componentDidUpdate(prevProps); - expect(refreshExceptSpy.callCount).toBe(0); + expect(refreshSpy.callCount).toBe(0); expect(wrapper.instance().appliedFilters).toBe(OVERRIDE_FILTERS); }); @@ -224,12 +147,12 @@ describe('Dashboard', () => { gender: ['boy', 'girl'], }; wrapper.setProps({ - filters: { + activeFilters: { ...OVERRIDE_FILTERS, ...newFilter, }, }); - expect(refreshExceptSpy.callCount).toBe(1); + expect(refreshSpy.callCount).toBe(1); expect(wrapper.instance().appliedFilters).toEqual({ ...OVERRIDE_FILTERS, ...newFilter, @@ -238,23 +161,23 @@ describe('Dashboard', () => { it('should call refresh if a filter is removed', () => { wrapper.setProps({ - filters: {}, + activeFilters: {}, }); - expect(refreshExceptSpy.callCount).toBe(1); + expect(refreshSpy.callCount).toBe(1); expect(wrapper.instance().appliedFilters).toEqual({}); }); it('should call refresh if a filter is changed', () => { wrapper.setProps({ - filters: { + activeFilters: { ...OVERRIDE_FILTERS, - region: ['Canada'], + '1_region': ['Canada'], }, }); - expect(refreshExceptSpy.callCount).toBe(1); + expect(refreshSpy.callCount).toBe(1); expect(wrapper.instance().appliedFilters).toEqual({ ...OVERRIDE_FILTERS, - region: ['Canada'], + '1_region': ['Canada'], }); }); }); diff --git a/superset/assets/spec/javascripts/dashboard/components/FilterIndicatorsContainer_spec.jsx b/superset/assets/spec/javascripts/dashboard/components/FilterIndicatorsContainer_spec.jsx index 0e5392f..089f185 100644 --- a/superset/assets/spec/javascripts/dashboard/components/FilterIndicatorsContainer_spec.jsx +++ b/superset/assets/spec/javascripts/dashboard/components/FilterIndicatorsContainer_spec.jsx @@ -20,28 +20,34 @@ import React from 'react'; import { shallow } from 'enzyme'; import { dashboardFilters } from '../fixtures/mockDashboardFilters'; +import { sliceId as chartId } from '../fixtures/mockChartQueries'; import { filterId, column } from '../fixtures/mockSliceEntities'; import FilterIndicatorsContainer from '../../../../src/dashboard/components/FilterIndicatorsContainer'; import FilterIndicator from '../../../../src/dashboard/components/FilterIndicator'; import * as colorMap from '../../../../src/dashboard/util/dashboardFiltersColorMap'; +import { buildActiveFilters } from '../../../../src/dashboard/util/activeDashboardFilters'; +import { getDashboardFilterKey } from '../../../../src/dashboard/util/getDashboardFilterKey'; +import { DASHBOARD_ROOT_ID } from '../../../../src/dashboard/util/constants'; +import { dashboardWithFilter } from '../fixtures/mockDashboardLayout'; describe('FilterIndicatorsContainer', () => { - const chartId = 1; const mockedProps = { dashboardFilters, chartId, chartStatus: 'success', - filterImmuneSlices: [], - filterImmuneSliceFields: {}, setDirectPathToChild: () => {}, filterFieldOnFocus: {}, }; - colorMap.getFilterColorKey = jest.fn(() => 'id_column'); colorMap.getFilterColorMap = jest.fn(() => ({ - id_column: 'badge-1', + [getDashboardFilterKey({ chartId, column })]: 'badge-1', })); + buildActiveFilters({ + dashboardFilters, + components: dashboardWithFilter, + }); + function setup(overrideProps) { return shallow( <FilterIndicatorsContainer {...mockedProps} {...overrideProps} />, @@ -58,18 +64,25 @@ describe('FilterIndicatorsContainer', () => { expect(wrapper.find(FilterIndicator)).toHaveLength(0); }); - it('should not show indicator when chart is immune', () => { - const wrapper = setup({ filterImmuneSlices: [chartId] }); - expect(wrapper.find(FilterIndicator)).toHaveLength(0); - }); - - it('should not show indicator when chart field is immune', () => { - const wrapper = setup({ filterImmuneSliceFields: { [chartId]: [column] } }); - expect(wrapper.find(FilterIndicator)).toHaveLength(0); - }); - it('should show indicator', () => { const wrapper = setup(); expect(wrapper.find(FilterIndicator)).toHaveLength(1); }); + + it('should not show indicator when chart is immune', () => { + const overwriteDashboardFilters = { + ...dashboardFilters, + [filterId]: { + ...dashboardFilters[filterId], + scopes: { + region: { + scope: [DASHBOARD_ROOT_ID], + immune: [chartId], + }, + }, + }, + }; + const wrapper = setup({ dashboardFilters: overwriteDashboardFilters }); + expect(wrapper.find(FilterIndicator)).toHaveLength(0); + }); }); diff --git a/superset/assets/spec/javascripts/dashboard/fixtures/mockDashboardFilters.js b/superset/assets/spec/javascripts/dashboard/fixtures/mockDashboardFilters.js index 7f13db7..c5640c5 100644 --- a/superset/assets/spec/javascripts/dashboard/fixtures/mockDashboardFilters.js +++ b/superset/assets/spec/javascripts/dashboard/fixtures/mockDashboardFilters.js @@ -36,6 +36,7 @@ export const dashboardFilters = { ], scopes: { region: DASHBOARD_FILTER_SCOPE_GLOBAL, + gender: DASHBOARD_FILTER_SCOPE_GLOBAL, }, isDateFilter: false, isInstantFilter: true, diff --git a/superset/assets/spec/javascripts/dashboard/fixtures/mockDashboardLayout.js b/superset/assets/spec/javascripts/dashboard/fixtures/mockDashboardLayout.js index 3267c5c..ee1dc4f 100644 --- a/superset/assets/spec/javascripts/dashboard/fixtures/mockDashboardLayout.js +++ b/superset/assets/spec/javascripts/dashboard/fixtures/mockDashboardLayout.js @@ -207,3 +207,54 @@ export const filterComponent = { sliceName: 'Filter', }, }; + +export const dashboardWithFilter = { + [DASHBOARD_ROOT_ID]: { + type: DASHBOARD_ROOT_TYPE, + id: DASHBOARD_ROOT_ID, + children: [DASHBOARD_GRID_ID], + }, + + [DASHBOARD_GRID_ID]: { + type: DASHBOARD_GRID_TYPE, + id: DASHBOARD_GRID_ID, + children: ['ROW_ID'], + meta: {}, + }, + + [DASHBOARD_HEADER_ID]: { + type: DASHBOARD_HEADER_TYPE, + id: DASHBOARD_HEADER_ID, + meta: { + text: 'New dashboard', + }, + }, + + ROW_ID: { + ...newComponentFactory(ROW_TYPE), + id: 'ROW_ID', + children: ['CHART_ID', 'FILTER_ID'], + }, + + FILTER_ID: { + ...newComponentFactory(CHART_TYPE), + id: 'FILTER_ID', + meta: { + chartId: filterId, + width: 3, + height: 10, + chartName: 'filter name', + }, + }, + + CHART_ID: { + ...newComponentFactory(CHART_TYPE), + id: 'CHART_ID', + meta: { + chartId, + width: 3, + height: 10, + chartName: 'Mock chart name', + }, + }, +}; diff --git a/superset/assets/spec/javascripts/dashboard/reducers/dashboardFilters_spec.js b/superset/assets/spec/javascripts/dashboard/reducers/dashboardFilters_spec.js index e234248..5573772 100644 --- a/superset/assets/spec/javascripts/dashboard/reducers/dashboardFilters_spec.js +++ b/superset/assets/spec/javascripts/dashboard/reducers/dashboardFilters_spec.js @@ -98,6 +98,7 @@ describe('dashboardFilters reducer', () => { }, scopes: { [column]: DASHBOARD_FILTER_SCOPE_GLOBAL, + gender: DASHBOARD_FILTER_SCOPE_GLOBAL, }, }, }); @@ -129,7 +130,8 @@ describe('dashboardFilters reducer', () => { [column]: column, }, scopes: { - [column]: DASHBOARD_FILTER_SCOPE_GLOBAL, + region: DASHBOARD_FILTER_SCOPE_GLOBAL, + gender: DASHBOARD_FILTER_SCOPE_GLOBAL, }, }, }); diff --git a/superset/assets/spec/javascripts/dashboard/util/getDashboardUrl_spec.js b/superset/assets/spec/javascripts/dashboard/util/getDashboardUrl_spec.js index 76a2da6..8b6b7fc 100644 --- a/superset/assets/spec/javascripts/dashboard/util/getDashboardUrl_spec.js +++ b/superset/assets/spec/javascripts/dashboard/util/getDashboardUrl_spec.js @@ -17,10 +17,16 @@ * under the License. */ import getDashboardUrl from '../../../../src/dashboard/util/getDashboardUrl'; +import { DASHBOARD_FILTER_SCOPE_GLOBAL } from '../../../../src/dashboard/reducers/dashboardFilters'; describe('getChartIdsFromLayout', () => { it('should encode filters', () => { - const filters = { 35: { key: ['value'] } }; + const filters = { + '35_key': { + values: ['value'], + scope: DASHBOARD_FILTER_SCOPE_GLOBAL, + }, + }; const url = getDashboardUrl('path', filters); expect(url).toBe( 'path?preselect_filters=%7B%2235%22%3A%7B%22key%22%3A%5B%22value%22%5D%7D%7D', diff --git a/superset/assets/spec/javascripts/dashboard/util/getFormDataWithExtraFilters_spec.js b/superset/assets/spec/javascripts/dashboard/util/getFormDataWithExtraFilters_spec.js index 544b2d4..95cb141 100644 --- a/superset/assets/spec/javascripts/dashboard/util/getFormDataWithExtraFilters_spec.js +++ b/superset/assets/spec/javascripts/dashboard/util/getFormDataWithExtraFilters_spec.js @@ -33,15 +33,9 @@ describe('getFormDataWithExtraFilters', () => { ], }, }, - dashboardMetadata: { - filterImmuneSlices: [], - filterImmuneSliceFields: {}, - }, filters: { - filterId: { - region: ['Spain'], - color: ['pink', 'purple'], - }, + region: ['Spain'], + color: ['pink', 'purple'], }, sliceId: chartId, }; @@ -60,26 +54,4 @@ describe('getFormDataWithExtraFilters', () => { val: ['pink', 'purple'], }); }); - - it('should not add additional filters if the slice is immune to them', () => { - const result = getFormDataWithExtraFilters({ - ...mockArgs, - dashboardMetadata: { - filterImmuneSlices: [chartId], - }, - }); - expect(result.extra_filters).toHaveLength(0); - }); - - it('should not add additional filters for fields to which the slice is immune', () => { - const result = getFormDataWithExtraFilters({ - ...mockArgs, - dashboardMetadata: { - filterImmuneSliceFields: { - [chartId]: ['region'], - }, - }, - }); - expect(result.extra_filters).toHaveLength(1); - }); });
