-
Notifications
You must be signed in to change notification settings - Fork 21
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
Set correctly the filters in History Query when selecting a Query Preview with filters #1325
Conversation
There was a problem hiding this 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
...-modules/history-queries/store/actions/update-history-queries-with-search-response.action.ts
Outdated
Show resolved
Hide resolved
...-modules/history-queries/store/actions/update-history-queries-with-search-response.action.ts
Outdated
Show resolved
Hide resolved
...-modules/history-queries/store/actions/update-history-queries-with-search-response.action.ts
Outdated
Show resolved
Hide resolved
...-modules/history-queries/store/actions/update-history-queries-with-search-response.action.ts
Outdated
Show resolved
Hide resolved
packages/x-components/src/x-modules/history-queries/store/__tests__/actions.spec.ts
Outdated
Show resolved
Hide resolved
3d03a19
to
e0e34ac
Compare
...-modules/history-queries/store/actions/update-history-queries-with-search-response.action.ts
Outdated
Show resolved
Hide resolved
…ons/update-history-queries-with-search-response.action.ts Co-authored-by: Guillermo Cacheda <[email protected]>
@@ -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 () => { |
There was a problem hiding this comment.
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 👍
…known__' facet id in the response EMP-2427
gato.totalResults = 50; | ||
const selectedFilters = Object.values(requestFilters)[0]; | ||
resetStateWith({ historyQueries: [gato, perro] }); | ||
await store.dispatch('updateHistoryQueriesWithSearchResponse', { |
There was a problem hiding this comment.
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.
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 aQueryPreview
, we only haveid
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 theid
available.TEST
Use VueDevTools and check the history queries state:
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:
queryPreview
with filters, and delete the query. If you select the query from history queries, the filters are applied.