-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dashboard] fix searchSessionId not updated when pinned filter changes (
#151390) Fixes #151219 and #151224 PR separates shouldRefresh logic from unsavedChanges logic to account for difference in filter check. shouldRefresh filter check: * includes pinned filters * excludes disabled filters * excludes $state so pinning/unpinning a filter does not cause a refresh. --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
a1361cf
commit cd910be
Showing
5 changed files
with
171 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...hboard_container/embeddable/integrations/diff_state/dashboard_diffing_integration.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { buildExistsFilter, disableFilter, pinFilter, toggleFilterNegated } from '@kbn/es-query'; | ||
import type { DataViewFieldBase, DataViewBase } from '@kbn/es-query'; | ||
import { getShouldRefresh } from './dashboard_diffing_integration'; | ||
import { DashboardContainer } from '../../dashboard_container'; | ||
import { DashboardContainerByValueInput } from '../../../../../common'; | ||
|
||
describe('getShouldRefresh', () => { | ||
const dashboardContainerMock = { | ||
untilInitialized: () => {}, | ||
} as unknown as DashboardContainer; | ||
|
||
const existsFilter = buildExistsFilter( | ||
{ | ||
name: 'myFieldName', | ||
} as DataViewFieldBase, | ||
{ | ||
id: 'myDataViewId', | ||
} as DataViewBase | ||
); | ||
|
||
test('should return true when pinned filters change', async () => { | ||
const pinnedFilter = pinFilter(existsFilter); | ||
const lastInput = { | ||
filters: [pinnedFilter], | ||
} as unknown as DashboardContainerByValueInput; | ||
const input = { | ||
filters: [toggleFilterNegated(pinnedFilter)], | ||
} as unknown as DashboardContainerByValueInput; | ||
expect(await getShouldRefresh.bind(dashboardContainerMock)(lastInput, { ...lastInput })).toBe( | ||
false | ||
); | ||
expect(await getShouldRefresh.bind(dashboardContainerMock)(lastInput, input)).toBe(true); | ||
}); | ||
|
||
test('should return false when disabled filters change', async () => { | ||
const disabledFilter = disableFilter(existsFilter); | ||
const lastInput = { | ||
filters: [disabledFilter], | ||
} as unknown as DashboardContainerByValueInput; | ||
const input = { | ||
filters: [toggleFilterNegated(disabledFilter)], | ||
} as unknown as DashboardContainerByValueInput; | ||
expect(await getShouldRefresh.bind(dashboardContainerMock)(lastInput, input)).toBe(false); | ||
}); | ||
|
||
test('should return false when pinned filter changes to unpinned', async () => { | ||
const lastInput = { | ||
filters: [existsFilter], | ||
} as unknown as DashboardContainerByValueInput; | ||
const input = { | ||
filters: [pinFilter(existsFilter)], | ||
} as unknown as DashboardContainerByValueInput; | ||
expect(await getShouldRefresh.bind(dashboardContainerMock)(lastInput, input)).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters