@@ -100,9 +100,12 @@ describe('<SearchUI />', () => {
100
100
// because otherwise Instantsearch will update the UI and change the query,
101
101
// leading to unexpected results in the test cases.
102
102
mockResult . results [ 0 ] . query = query ;
103
+ mockResult . results [ 2 ] . query = query ;
103
104
// And fake the required '_formatted' fields; it contains the highlighting <mark>...</mark> around matched words
104
105
// eslint-disable-next-line no-underscore-dangle, no-param-reassign
105
106
mockResult . results [ 0 ] ?. hits . forEach ( ( hit ) => { hit . _formatted = { ...hit } ; } ) ;
107
+ // eslint-disable-next-line no-underscore-dangle, no-param-reassign
108
+ mockResult . results [ 2 ] ?. hits . forEach ( ( hit ) => { hit . _formatted = { ...hit } ; } ) ;
106
109
return mockResult ;
107
110
} ) ;
108
111
fetchMock . post ( tagsKeywordSearchEndpoint , mockTagsKeywordSearchResult ) ;
@@ -174,8 +177,8 @@ describe('<SearchUI />', () => {
174
177
expect ( fetchMock ) . toHaveLastFetched ( ( _url , req ) => {
175
178
const requestData = JSON . parse ( req . body ?. toString ( ) ?? '' ) ;
176
179
const requestedFilter = requestData ?. queries [ 0 ] . filter ;
177
- return requestedFilter ?. [ 1 ] === 'type = "course_block"'
178
- && requestedFilter ?. [ 2 ] === 'context_key = "course-v1:org+test+123"' ;
180
+ return requestedFilter ?. [ 2 ] === 'type = "course_block"'
181
+ && requestedFilter ?. [ 3 ] === 'context_key = "course-v1:org+test+123"' ;
179
182
} ) ;
180
183
// Now we should see the results:
181
184
expect ( queryByText ( 'Enter a keyword' ) ) . toBeNull ( ) ;
@@ -398,8 +401,9 @@ describe('<SearchUI />', () => {
398
401
expect ( fetchMock ) . toHaveLastFetched ( ( _url , req ) => {
399
402
const requestData = JSON . parse ( req . body ?. toString ( ) ?? '' ) ;
400
403
const requestedFilter = requestData ?. queries [ 0 ] . filter ;
401
- // the filter is: ['type = "course_block"', 'context_key = "course-v1:org+test+123"']
402
- return ( requestedFilter ?. length === 3 ) ;
404
+ // the filter is:
405
+ // ['NOT type == "collection"', '', 'type = "course_block"', 'context_key = "course-v1:org+test+123"']
406
+ return ( requestedFilter ?. length === 4 ) ;
403
407
} ) ;
404
408
// Now we should see the results:
405
409
expect ( getByText ( '6 results found' ) ) . toBeInTheDocument ( ) ;
@@ -425,6 +429,7 @@ describe('<SearchUI />', () => {
425
429
const requestData = JSON . parse ( req . body ?. toString ( ) ?? '' ) ;
426
430
const requestedFilter = requestData ?. queries [ 0 ] . filter ;
427
431
return JSON . stringify ( requestedFilter ) === JSON . stringify ( [
432
+ 'NOT type = "collection"' ,
428
433
[
429
434
'block_type = problem' ,
430
435
'content.problem_types = choiceresponse' ,
@@ -458,6 +463,7 @@ describe('<SearchUI />', () => {
458
463
const requestData = JSON . parse ( req . body ?. toString ( ) ?? '' ) ;
459
464
const requestedFilter = requestData ?. queries ?. [ 0 ] ?. filter ;
460
465
return JSON . stringify ( requestedFilter ) === JSON . stringify ( [
466
+ 'NOT type = "collection"' ,
461
467
[ ] ,
462
468
'type = "course_block"' ,
463
469
'context_key = "course-v1:org+test+123"' ,
@@ -493,6 +499,7 @@ describe('<SearchUI />', () => {
493
499
const requestData = JSON . parse ( req . body ?. toString ( ) ?? '' ) ;
494
500
const requestedFilter = requestData ?. queries ?. [ 0 ] ?. filter ;
495
501
return JSON . stringify ( requestedFilter ) === JSON . stringify ( [
502
+ 'NOT type = "collection"' ,
496
503
[ ] ,
497
504
'type = "course_block"' ,
498
505
'context_key = "course-v1:org+test+123"' ,
0 commit comments