mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
feat(native-filters): apply scoping of native filters to dashboard (#12716)
* feat: scoping native filters in dashboard * test: add tests / fix reducer * test: fix tests * chore: merge with master * fix: fix undefined cases * fix: fix code according cypress * refactor: fix mocks according CRs * chore: re run pipeline
This commit is contained in:
@@ -28,10 +28,17 @@ import newComponentFactory from 'src/dashboard/util/newComponentFactory';
|
||||
// mock data
|
||||
import chartQueries from 'spec/fixtures/mockChartQueries';
|
||||
import datasources from 'spec/fixtures/mockDatasource';
|
||||
import {
|
||||
extraFormData,
|
||||
NATIVE_FILTER_ID,
|
||||
layoutForSingleNativeFilter,
|
||||
singleNativeFiltersState,
|
||||
} from 'spec/fixtures/mockNativeFilters';
|
||||
import dashboardInfo from 'spec/fixtures/mockDashboardInfo';
|
||||
import { dashboardLayout } from 'spec/fixtures/mockDashboardLayout';
|
||||
import dashboardState from 'spec/fixtures/mockDashboardState';
|
||||
import { sliceEntitiesForChart as sliceEntities } from 'spec/fixtures/mockSliceEntities';
|
||||
import { getActiveNativeFilters } from 'src/dashboard/util/activeDashboardNativeFilters';
|
||||
|
||||
describe('Dashboard', () => {
|
||||
const props = {
|
||||
@@ -141,6 +148,27 @@ describe('Dashboard', () => {
|
||||
expect(wrapper.instance().appliedFilters).toBe(OVERRIDE_FILTERS);
|
||||
});
|
||||
|
||||
it('should call refresh when native filters changed', () => {
|
||||
wrapper.setProps({
|
||||
activeFilters: {
|
||||
...OVERRIDE_FILTERS,
|
||||
...getActiveNativeFilters({
|
||||
nativeFilters: singleNativeFiltersState,
|
||||
layout: layoutForSingleNativeFilter,
|
||||
}),
|
||||
},
|
||||
});
|
||||
wrapper.instance().componentDidUpdate(prevProps);
|
||||
expect(refreshSpy.callCount).toBe(1);
|
||||
expect(wrapper.instance().appliedFilters).toEqual({
|
||||
...OVERRIDE_FILTERS,
|
||||
[NATIVE_FILTER_ID]: {
|
||||
scope: [230],
|
||||
values: [extraFormData],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should call refresh if a filter is added', () => {
|
||||
const newFilter = {
|
||||
gender: { values: ['boy', 'girl'], scope: [1] },
|
||||
|
||||
Reference in New Issue
Block a user