mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Unified search] Unloads selected query if is deleted (#154644)
## Summary Closes https://github.com/elastic/kibana/issues/151554 Unloads the selected saved query if it is deleted in order to be able to be re-applied.  ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
4dfebedd2f
commit
3840136d75
2 changed files with 26 additions and 0 deletions
|
@ -158,4 +158,29 @@ describe('Saved query management list component', () => {
|
|||
findTestSubject(component, 'delete-saved-query-Test-button').simulate('click');
|
||||
expect(component.find('[data-test-subj="confirmModalConfirmButton"]').length).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render the onClearSavedQuery on delete of the current selected query', async () => {
|
||||
const onClearSavedQuerySpy = jest.fn();
|
||||
const newProps = {
|
||||
...props,
|
||||
loadedSavedQuery: {
|
||||
id: '8a0b7cd0-b0c4-11ec-92b2-73d62e0d28a9',
|
||||
attributes: {
|
||||
title: 'Test',
|
||||
description: '',
|
||||
query: {
|
||||
query: 'category.keyword : "Men\'s Shoes" ',
|
||||
language: 'kuery',
|
||||
},
|
||||
filters: [],
|
||||
},
|
||||
},
|
||||
onClearSavedQuery: onClearSavedQuerySpy,
|
||||
};
|
||||
const component = mount(wrapSavedQueriesListComponentInContext(newProps));
|
||||
await flushEffect(component);
|
||||
findTestSubject(component, 'delete-saved-query-Test-button').simulate('click');
|
||||
findTestSubject(component, 'confirmModalConfirmButton').simulate('click');
|
||||
expect(onClearSavedQuerySpy).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -174,6 +174,7 @@ export function SavedQueryManagementList({
|
|||
|
||||
if (loadedSavedQuery && loadedSavedQuery.id === savedQueryId) {
|
||||
onClearSavedQuery();
|
||||
setSelectedSavedQuery(undefined);
|
||||
}
|
||||
|
||||
await savedQueryService.deleteSavedQuery(savedQueryId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue