mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat(native-filters): add support for preselect filters (#15427)
* feat(native-filters): add support for sharing preselected filters * abc * add serialization
This commit is contained in:
@@ -34,35 +34,64 @@ describe('getChartIdsFromLayout', () => {
|
||||
});
|
||||
|
||||
it('should encode filters', () => {
|
||||
const url = getDashboardUrl('path', filters);
|
||||
const url = getDashboardUrl({ pathname: 'path', filters });
|
||||
expect(url).toBe(
|
||||
'path?preselect_filters=%7B%2235%22%3A%7B%22key%22%3A%5B%22value%22%5D%7D%7D',
|
||||
);
|
||||
});
|
||||
|
||||
it('should encode filters with hash', () => {
|
||||
const urlWithHash = getDashboardUrl('path', filters, 'iamhashtag');
|
||||
const urlWithHash = getDashboardUrl({
|
||||
pathname: 'path',
|
||||
filters,
|
||||
hash: 'iamhashtag',
|
||||
});
|
||||
expect(urlWithHash).toBe(
|
||||
'path?preselect_filters=%7B%2235%22%3A%7B%22key%22%3A%5B%22value%22%5D%7D%7D#iamhashtag',
|
||||
);
|
||||
});
|
||||
|
||||
it('should encode filters with standalone', () => {
|
||||
const urlWithStandalone = getDashboardUrl(
|
||||
'path',
|
||||
const urlWithStandalone = getDashboardUrl({
|
||||
pathname: 'path',
|
||||
filters,
|
||||
'',
|
||||
DashboardStandaloneMode.HIDE_NAV,
|
||||
);
|
||||
standalone: DashboardStandaloneMode.HIDE_NAV,
|
||||
});
|
||||
expect(urlWithStandalone).toBe(
|
||||
`path?preselect_filters=%7B%2235%22%3A%7B%22key%22%3A%5B%22value%22%5D%7D%7D&standalone=${DashboardStandaloneMode.HIDE_NAV}`,
|
||||
);
|
||||
});
|
||||
|
||||
it('should encode filters with missing standalone', () => {
|
||||
const urlWithStandalone = getDashboardUrl('path', filters, '', null);
|
||||
const urlWithStandalone = getDashboardUrl({
|
||||
pathname: 'path',
|
||||
filters,
|
||||
standalone: null,
|
||||
});
|
||||
expect(urlWithStandalone).toBe(
|
||||
'path?preselect_filters=%7B%2235%22%3A%7B%22key%22%3A%5B%22value%22%5D%7D%7D',
|
||||
);
|
||||
});
|
||||
|
||||
it('should encode native filters', () => {
|
||||
const urlWithNativeFilters = getDashboardUrl({
|
||||
pathname: 'path',
|
||||
dataMask: {
|
||||
'NATIVE_FILTER-foo123': {
|
||||
filterState: {
|
||||
label: 'custom label',
|
||||
value: ['a', 'b'],
|
||||
},
|
||||
},
|
||||
'NATIVE_FILTER-bar456': {
|
||||
filterState: {
|
||||
value: undefined,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(urlWithNativeFilters).toBe(
|
||||
'path?preselect_filters=%7B%7D&native_filters=%28NATIVE_FILTER-bar456%3A%21n%2CNATIVE_FILTER-foo123%3A%21%28a%2Cb%29%29',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user