Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set correctly the filters in History Query when selecting a Query Preview with filters #1325

Merged
merged 16 commits into from
Oct 26, 2023

Conversation

annacv
Copy link
Contributor

@annacv annacv commented Oct 16, 2023

EMP-2428

When we save the filters in the History Queries action update-history-queries-with-search-response.action.ts we were doing: const filters = createHistoryQueriesFiltersList(searchResponse.request.filters); In the case of filters that come from a QueryPreview, we only have id so we should compare the filters with the response to get the rest of the data.

In this PR we use facets with selected filters from the response to be able to provide a label for the selectedFilters although the stored item has only the id available.

TEST
Use VueDevTools and check the history queries state:

  • click a queryPreview with filters (e.g. cortina) and check the historyQuery's filters have a label.

Check that saving filters on history queries is still working properly:

  • write a query & filter it, delete the query. If you select the query from history queries, the filters are applied.
  • select a queryPreview with filters, and delete the query. If you select the query from history queries, the filters are applied.

@annacv annacv requested a review from a team as a code owner October 16, 2023 13:55
Copy link
Contributor

@CachedaCodes CachedaCodes left a comment

Choose a reason for hiding this comment

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

This flow results in the history query not applying the filters:
Open X -> search query -> select filter -> click "clear" in searchbar -> select new HQ

Screen.Recording.2023-10-18.at.09.22.48.mov

@annacv annacv force-pushed the bugfix/EMP-2427-Set-filters-from-query-preview branch from 3d03a19 to e0e34ac Compare October 18, 2023 11:20
@annacv annacv requested a review from CachedaCodes October 18, 2023 14:08
annacv and others added 2 commits October 23, 2023 09:13
@annacv annacv requested a review from CachedaCodes October 23, 2023 10:06
@@ -369,9 +401,8 @@ describe('testing history queries module actions', () => {
});

// eslint-disable-next-line max-len
it('updates a history query if search response change because a filter is selected', async () => {
it('updates a history query when the search response changes because a filter is selected', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's worth testing with facets with __unknown__ as id. Create a new test for it and where done 👍

@annacv annacv requested a review from CachedaCodes October 23, 2023 13:56
gato.totalResults = 50;
const selectedFilters = Object.values(requestFilters)[0];
resetStateWith({ historyQueries: [gato, perro] });
await store.dispatch('updateHistoryQueriesWithSearchResponse', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Testing this doesn't make much sense to me. The response shouldn't return facets with id __unknown__. The backend should know the id of the facet and __unknown__ is a key used only in the front to identify a filter which we don't know the facet id.

The test I was suggesting was the behaviour of the action when a Query preview was selected. Selecting a QP creates a HQ of that request, but the QP creates the filters with facet id __unknown__. The test should check that the filters map correctly when the requestFilters have an unknown facet id.

@CachedaCodes CachedaCodes merged commit 61fdfd1 into main Oct 26, 2023
4 checks passed
@CachedaCodes CachedaCodes deleted the bugfix/EMP-2427-Set-filters-from-query-preview branch October 26, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants