parent
7152e02ada
commit
497892e300
2 changed files with 18 additions and 2 deletions
|
@ -56,6 +56,18 @@ describe('filter saved object references', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
it('should remove index and value from persistable filter', () => {
|
||||
const { persistableFilters } = extractFilterReferences([
|
||||
{ ...filters[0], meta: { ...filters[0].meta, value: 'CN' } },
|
||||
{ ...filters[1], meta: { ...filters[1].meta, value: 'US' } },
|
||||
]);
|
||||
expect(persistableFilters.length).toBe(2);
|
||||
persistableFilters.forEach((filter) => {
|
||||
expect(filter.meta.hasOwnProperty('index')).toBe(false);
|
||||
expect(filter.meta.hasOwnProperty('value')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('should restore the same filter after extracting and injecting', () => {
|
||||
const { persistableFilters, references } = extractFilterReferences(filters);
|
||||
expect(injectFilterReferences(persistableFilters, references)).toEqual(filters);
|
||||
|
|
|
@ -22,14 +22,18 @@ export function extractFilterReferences(
|
|||
type: 'index-pattern',
|
||||
id: filterRow.meta.index,
|
||||
});
|
||||
return {
|
||||
const newFilter = {
|
||||
...filterRow,
|
||||
meta: {
|
||||
...filterRow.meta,
|
||||
indexRefName: refName,
|
||||
index: undefined,
|
||||
},
|
||||
};
|
||||
// remove index because it's specified by indexRefName
|
||||
delete newFilter.meta.index;
|
||||
// remove value because it can't be persisted
|
||||
delete newFilter.meta.value;
|
||||
return newFilter;
|
||||
});
|
||||
|
||||
return { persistableFilters, references };
|
||||
|
|
Loading…
Reference in a new issue