@@ -113,7 +113,6 @@ describe('Tests content types', () => {
113113 expect ( tasks ) . toEqual ( 10 )
114114 } )
115115
116-
117116 test ( 'Test to add entries linked to multiple indexes in Meilisearch' , async ( ) => {
118117 const pluginMock = jest . fn ( ( ) => ( {
119118 // This rewrites only the needed methods to reach the system under test (removeSensitiveFields)
@@ -192,10 +191,10 @@ describe('Tests content types', () => {
192191
193192 expect ( strapi . log . info ) . toHaveBeenCalledTimes ( 2 )
194193 expect ( strapi . log . info ) . toHaveBeenCalledWith (
195- 'The task to add 2 documents to the Meilisearch index "customIndex" has been enqueued (Task uid: undefined).'
194+ 'The task to add 2 documents to the Meilisearch index "customIndex" has been enqueued (Task uid: undefined).' ,
196195 )
197196 expect ( strapi . log . info ) . toHaveBeenCalledWith (
198- 'The task to add 2 documents to the Meilisearch index "anotherIndex" has been enqueued (Task uid: undefined).'
197+ 'The task to add 2 documents to the Meilisearch index "anotherIndex" has been enqueued (Task uid: undefined).' ,
199198 )
200199 expect ( client . index ( '' ) . addDocuments ) . toHaveBeenCalledTimes ( 2 )
201200 expect ( client . index ) . toHaveBeenCalledWith ( 'customIndex' )
@@ -256,10 +255,10 @@ describe('Tests content types', () => {
256255
257256 expect ( customStrapi . log . info ) . toHaveBeenCalledTimes ( 2 )
258257 expect ( customStrapi . log . info ) . toHaveBeenCalledWith (
259- 'A task to delete 2 documents of the index "customIndex" in Meilisearch has been enqueued (Task uid: undefined).'
258+ 'A task to delete 2 documents of the index "customIndex" in Meilisearch has been enqueued (Task uid: undefined).' ,
260259 )
261260 expect ( customStrapi . log . info ) . toHaveBeenCalledWith (
262- 'A task to delete 2 documents of the index "anotherIndex" in Meilisearch has been enqueued (Task uid: undefined).'
261+ 'A task to delete 2 documents of the index "anotherIndex" in Meilisearch has been enqueued (Task uid: undefined).' ,
263262 )
264263 expect ( client . index ( '' ) . deleteDocuments ) . toHaveBeenCalledTimes ( 2 )
265264 expect ( client . index ( '' ) . deleteDocuments ) . toHaveBeenCalledWith ( [
@@ -335,6 +334,95 @@ describe('Tests content types', () => {
335334 )
336335 } )
337336
337+ test ( 'Test to update the content of a collection in Meilisearch with a custom index name' , async ( ) => {
338+ const customStrapi = createStrapiMock ( {
339+ restaurantConfig : {
340+ indexName : [ 'customIndex' ] ,
341+ entriesQuery : {
342+ limit : 1 ,
343+ fields : [ 'id' ] ,
344+ filters : { } ,
345+ sort : { } ,
346+ populate : [ ] ,
347+ publicationState : 'preview' ,
348+ } ,
349+ } ,
350+ } )
351+
352+ const meilisearchService = createMeilisearchService ( {
353+ strapi : customStrapi ,
354+ } )
355+
356+ await meilisearchService . addContentTypeInMeiliSearch ( {
357+ contentType : 'restaurant' ,
358+ } )
359+
360+ expect (
361+ customStrapi . plugin ( ) . service ( ) . actionInBatches
362+ ) . toHaveBeenCalledWith ( {
363+ contentType : 'restaurant' ,
364+ callback : expect . anything ( ) ,
365+ entriesQuery : {
366+ limit : 1 ,
367+ fields : [ 'id' ] ,
368+ filters : { } ,
369+ sort : { } ,
370+ populate : [ ] ,
371+ publicationState : 'preview' ,
372+ } ,
373+ } )
374+ expect ( customStrapi . log . info ) . toHaveBeenCalledTimes ( 1 )
375+ expect ( customStrapi . log . info ) . toHaveBeenCalledWith (
376+ 'A task to update the settings to the Meilisearch index "customIndex" has been enqueued (Task uid: undefined).'
377+ )
378+ } )
379+
380+ test ( 'Test to update the content of a collection in Meilisearch with a multiple index names' , async ( ) => {
381+ const customStrapi = createStrapiMock ( {
382+ restaurantConfig : {
383+ indexName : [ 'customIndex' , 'anotherIndex' ] ,
384+ entriesQuery : {
385+ limit : 1 ,
386+ fields : [ 'id' ] ,
387+ filters : { } ,
388+ sort : { } ,
389+ populate : [ ] ,
390+ publicationState : 'preview' ,
391+ } ,
392+ } ,
393+ } )
394+
395+ const meilisearchService = createMeilisearchService ( {
396+ strapi : customStrapi ,
397+ } )
398+
399+ await meilisearchService . addContentTypeInMeiliSearch ( {
400+ contentType : 'restaurant' ,
401+ } )
402+
403+ expect (
404+ customStrapi . plugin ( ) . service ( ) . actionInBatches
405+ ) . toHaveBeenCalledWith ( {
406+ contentType : 'restaurant' ,
407+ callback : expect . anything ( ) ,
408+ entriesQuery : {
409+ limit : 1 ,
410+ fields : [ 'id' ] ,
411+ filters : { } ,
412+ sort : { } ,
413+ populate : [ ] ,
414+ publicationState : 'preview' ,
415+ } ,
416+ } )
417+ expect ( customStrapi . log . info ) . toHaveBeenCalledTimes ( 2 )
418+ expect ( customStrapi . log . info ) . toHaveBeenCalledWith (
419+ 'A task to update the settings to the Meilisearch index "customIndex" has been enqueued (Task uid: undefined).'
420+ )
421+ expect ( customStrapi . log . info ) . toHaveBeenCalledWith (
422+ 'A task to update the settings to the Meilisearch index "anotherIndex" has been enqueued (Task uid: undefined).'
423+ )
424+ } )
425+
338426 test ( 'Test to update the content of a collection in Meilisearch with a custom index name' , async ( ) => {
339427 const customStrapi = createStrapiMock ( {
340428 restaurantConfig : {
0 commit comments