Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,10 @@ export function useQueryBarMenuPanels({

useEffect(() => {
if (savedQuery) {
const filtersHaveChanged = Boolean(
savedQuery?.attributes.filters &&
!compareFilters(filters ?? [], savedQuery.attributes.filters, COMPARE_ALL_OPTIONS)
const filtersHaveChanged = !compareFilters(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much better, thank you for making the change!

filters ?? [],
savedQuery.attributes.filters ?? [],
COMPARE_ALL_OPTIONS
);

const timeFilterHasChanged = Boolean(
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context in case you haven't come across it yet, ccs_compatibility stands for cross-cluster search, and it's odd that all our saved query management tests live here 😅 But it does seem like the most appropriate place for this test currently.

Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,37 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await queryBar.switchQueryLanguage('lucene');
expect(await queryBar.getQueryString()).to.eql('');
});

it('checks if the "Save query" button becomes enabled after adding filters, even when the query was saved with "Include filters" unchecked', async () => {
await queryBar.setQuery('response:200');
await queryBar.submitQuery();
await savedQueryManagementComponent.saveNewQuery('filterExcluded', '', false, false);
await savedQueryManagementComponent.savedQueryExistOrFail('filterExcluded');
await savedQueryManagementComponent.closeSavedQueryManagementComponent();
await savedQueryManagementComponent.openSavedQueryManagementComponent();
let isSaveButtonDisabled = await testSubjects.getAttribute(
'saved-query-management-save-button',
'disabled'
);
expect(isSaveButtonDisabled).to.equal(
'true',
'Save button should be disabled directly after saving a query'
);
await filterBar.addFilter({ field: '@message', operation: 'exists' });
await savedQueryManagementComponent.openSavedQueryManagementComponent();
isSaveButtonDisabled = await testSubjects.getAttribute(
'saved-query-management-save-button',
'disabled'
);
expect(isSaveButtonDisabled).to.equal(
null,
'Save button should be enabled after adding a filter'
);
const updateQueryButtonExists = await testSubjects.exists(
'saved-query-management-save-changes-button'
);
expect(updateQueryButtonExists).to.equal(true, 'Update query button does not exist');
});
});
});
}