@@ -125,6 +125,60 @@ describe('buildAskAiSearchParameters', () => {
125125 } ) ;
126126 } ) ;
127127
128+ it ( 'merges config facetFilters on the same facet with an OR' , ( ) => {
129+ expect (
130+ buildAskAiSearchParameters (
131+ {
132+ agentId : 'agent' ,
133+ searchParameters : { 'index-1' : { facetFilters : [ 'language:fr' ] } } ,
134+ } ,
135+ contextualFacetFilters ,
136+ ) ,
137+ ) . toEqual ( {
138+ agentId : 'agent' ,
139+ searchParameters : {
140+ 'index-1' : {
141+ facetFilters : [
142+ [ 'language:en' , 'language:fr' ] ,
143+ [ 'docusaurus_tag:default' , 'docusaurus_tag:docs-default-current' ] ,
144+ ] ,
145+ } ,
146+ } ,
147+ } ) ;
148+ } ) ;
149+
150+ it ( 'merges negated config facetFilters on the same facet with an AND' , ( ) => {
151+ expect (
152+ buildAskAiSearchParameters (
153+ {
154+ agentId : 'agent' ,
155+ searchParameters : { 'index-1' : { facetFilters : [ 'language:-fr' ] } } ,
156+ } ,
157+ contextualFacetFilters ,
158+ ) ,
159+ ) . toEqual ( {
160+ agentId : 'agent' ,
161+ searchParameters : {
162+ 'index-1' : { facetFilters : [ ...contextualFacetFilters , 'language:-fr' ] } ,
163+ } ,
164+ } ) ;
165+ } ) ;
166+
167+ it ( 'removes config facetFilters duplicating the contextual ones' , ( ) => {
168+ expect (
169+ buildAskAiSearchParameters (
170+ {
171+ agentId : 'agent' ,
172+ searchParameters : { 'index-1' : { facetFilters : [ 'language:en' ] } } ,
173+ } ,
174+ contextualFacetFilters ,
175+ ) ,
176+ ) . toEqual ( {
177+ agentId : 'agent' ,
178+ searchParameters : { 'index-1' : { facetFilters : contextualFacetFilters } } ,
179+ } ) ;
180+ } ) ;
181+
128182 it ( 'keeps the config filters' , ( ) => {
129183 expect (
130184 buildAskAiSearchParameters (
0 commit comments