@@ -92,6 +92,18 @@ describe('GlobalSearchState', () => {
9292 expect ( mockGetFilterOptions ) . not . toHaveBeenCalled ( ) ;
9393 } ) ;
9494
95+ it ( 'should set isLoaded to true for a CEDAR filter when short-circuiting' , ( ) => {
96+ const { store } = setup ( ) ;
97+
98+ store . dispatch ( new SetExtraFilters ( [ CEDAR_FILTER ] ) ) ;
99+ store . dispatch ( new FetchResources ( ) ) ;
100+ store . dispatch ( new LoadFilterOptions ( CEDAR_FILTER . key ) ) ;
101+
102+ const filters = store . selectSnapshot ( GlobalSearchSelectors . getFilters ) ;
103+ const cedarFilterState = filters . find ( ( f ) => f . key === CEDAR_FILTER . key ) ;
104+ expect ( cedarFilterState ?. isLoaded ) . toBe ( true ) ;
105+ } ) ;
106+
95107 it ( 'should call the API for a regular filter' , ( ) => {
96108 const { store, mockGetFilterOptions } = setup ( ) ;
97109
@@ -180,10 +192,35 @@ describe('GlobalSearchState', () => {
180192 store . dispatch ( new FetchResources ( ) ) ;
181193
182194 const params = mockGetResources . mock . calls [ 0 ] [ 0 ] ;
183- expect ( params [ `cardSearchText[osf:hasCedarRecord.cedar:${ CEDAR_FILTER . cedarPropertyIri } ]` ] ) . toBe ( '"High School"' ) ;
195+ expect ( params [ `cardSearchText[osf:hasCedarRecord.cedar:${ CEDAR_FILTER . cedarPropertyIri } ][]` ] ) . toEqual ( [
196+ '"High School"' ,
197+ ] ) ;
184198 expect ( params [ `cardSearchFilter[${ CEDAR_FILTER . key } ][]` ] ) . toBeUndefined ( ) ;
185199 } ) ;
186200
201+ it ( 'should include all selected values for a CEDAR filter' , ( ) => {
202+ const { store, mockGetResources } = setup ( ) ;
203+ store . dispatch ( new SetExtraFilters ( [ CEDAR_FILTER ] ) ) ;
204+ store . dispatch ( new FetchResources ( ) ) ;
205+ mockGetResources . mockClear ( ) ;
206+
207+ store . dispatch (
208+ new LoadFilterOptionsAndSetValues ( {
209+ [ CEDAR_FILTER . key ] : [
210+ { label : 'High School' , value : 'High School' , cardSearchResultCount : null } ,
211+ { label : 'Middle School' , value : 'Middle School' , cardSearchResultCount : null } ,
212+ ] ,
213+ } )
214+ ) ;
215+ store . dispatch ( new FetchResources ( ) ) ;
216+
217+ const params = mockGetResources . mock . calls [ 0 ] [ 0 ] ;
218+ expect ( params [ `cardSearchText[osf:hasCedarRecord.cedar:${ CEDAR_FILTER . cedarPropertyIri } ][]` ] ) . toEqual ( [
219+ '"High School"' ,
220+ '"Middle School"' ,
221+ ] ) ;
222+ } ) ;
223+
187224 it ( 'should use extraFilters as fallback for CEDAR lookup before state.filters is populated' , ( ) => {
188225 const { store, mockGetResources } = setup ( ) ;
189226 store . dispatch ( new SetExtraFilters ( [ CEDAR_FILTER ] ) ) ;
@@ -197,7 +234,9 @@ describe('GlobalSearchState', () => {
197234 store . dispatch ( new FetchResources ( ) ) ;
198235
199236 const params = mockGetResources . mock . calls [ 0 ] [ 0 ] ;
200- expect ( params [ `cardSearchText[osf:hasCedarRecord.cedar:${ CEDAR_FILTER . cedarPropertyIri } ]` ] ) . toBe ( '"High School"' ) ;
237+ expect ( params [ `cardSearchText[osf:hasCedarRecord.cedar:${ CEDAR_FILTER . cedarPropertyIri } ][]` ] ) . toEqual ( [
238+ '"High School"' ,
239+ ] ) ;
201240 } ) ;
202241 } ) ;
203242} ) ;
0 commit comments