-
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
Changes from all commits
a44644b
b47d1cf
13ac230
014e1df
8e8f8e7
e0e34ac
b672565
93d4c47
c0bf51b
b2cdd3f
953d9f7
2f0a701
70f8641
7234dca
7acbbac
108a463
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import { | |
HistoryQueriesMutations, | ||
HistoryQueriesState | ||
} from '../types'; | ||
import { InternalSearchResponse } from '../../../search/index'; | ||
import { resetHistoryQueriesStateWith } from './utils'; | ||
|
||
describe('testing history queries module actions', () => { | ||
|
@@ -279,12 +280,43 @@ describe('testing history queries module actions', () => { | |
const requestFilters: Record<string, Filter[]> = { | ||
categoryPaths: [ | ||
{ | ||
id: 'categoryIds:c018019b6', | ||
id: 'categoryIds:66dd06d9f', | ||
selected: true, | ||
modelName: 'HierarchicalFilter' | ||
} | ||
] | ||
}; | ||
const selectedFilters: Filter[] = [ | ||
{ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
facetId: 'categoryPaths', | ||
id: 'categoryIds:66dd06d9f', | ||
label: 'suede', | ||
modelName: 'HierarchicalFilter', | ||
selected: true, | ||
totalResults: 2 | ||
} | ||
]; | ||
const responseFacets: InternalSearchResponse['facets'] = [ | ||
{ | ||
filters: [ | ||
{ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
facetId: 'categoryPaths', | ||
id: 'categoryIds:66dd06d9f', | ||
label: 'suede', | ||
modelName: 'HierarchicalFilter', | ||
selected: true, | ||
totalResults: 2 | ||
} | ||
], | ||
id: 'categoryPaths', | ||
label: 'categoryPaths', | ||
modelName: 'HierarchicalFacet' | ||
} | ||
]; | ||
let gato: HistoryQuery, perro: HistoryQuery; | ||
|
||
beforeEach(() => { | ||
|
@@ -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 () => { | ||
gato.totalResults = 50; | ||
const selectedFilters = Object.values(requestFilters)[0]; | ||
resetStateWith({ historyQueries: [gato, perro] }); | ||
await store.dispatch('updateHistoryQueriesWithSearchResponse', { | ||
request: { | ||
|
@@ -380,6 +411,33 @@ describe('testing history queries module actions', () => { | |
filters: requestFilters | ||
}, | ||
status: 'success', | ||
facets: responseFacets, | ||
results, | ||
totalResults | ||
}); | ||
expectHistoryQueriesToEqual([{ ...gato, totalResults, selectedFilters }, perro]); | ||
}); | ||
|
||
// eslint-disable-next-line max-len | ||
it('updates a history query when the search response changes although the facet id is unknown', async () => { | ||
gato.totalResults = 50; | ||
resetStateWith({ historyQueries: [gato, perro] }); | ||
await store.dispatch('updateHistoryQueriesWithSearchResponse', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 |
||
request: { | ||
query: 'gato', | ||
page: 1, | ||
filters: { | ||
__unknown__: [ | ||
{ | ||
id: 'categoryIds:66dd06d9f', | ||
selected: true, | ||
modelName: 'RawFilter' | ||
} | ||
] | ||
} | ||
}, | ||
status: 'success', | ||
facets: responseFacets, | ||
results, | ||
totalResults | ||
}); | ||
|
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 👍