@@ -692,7 +692,9 @@ describe('Lifecycle Meilisearch integration', () => {
692692 contentTypeService . getEntry . mockResolvedValueOnce ( fetchedEntry )
693693 meilisearchService . entriesQuery . mockReturnValueOnce ( baseEntriesQuery )
694694
695- await lifecycleHandler . subscribeContentType ( { contentType : contentTypeUid } )
695+ await lifecycleHandler . subscribeContentType ( {
696+ contentType : contentTypeUid ,
697+ } )
696698 await strapiMock . db . lifecycles . subscribe . mock . calls [ 0 ] [ 0 ] . afterCreate ( {
697699 result,
698700 } )
@@ -723,12 +725,17 @@ describe('Lifecycle Meilisearch integration', () => {
723725 title : 'Test Entry' ,
724726 publishedAt : null ,
725727 }
726- const baseEntriesQuery = { populate : { category : true } , fields : [ 'title' ] }
728+ const baseEntriesQuery = {
729+ populate : { category : true } ,
730+ fields : [ 'title' ] ,
731+ }
727732
728733 contentTypeService . getEntry . mockResolvedValueOnce ( fetchedEntry )
729734 meilisearchService . entriesQuery . mockReturnValueOnce ( baseEntriesQuery )
730735
731- await lifecycleHandler . subscribeContentType ( { contentType : contentTypeUid } )
736+ await lifecycleHandler . subscribeContentType ( {
737+ contentType : contentTypeUid ,
738+ } )
732739 await strapiMock . db . lifecycles . subscribe . mock . calls [ 0 ] [ 0 ] . afterUpdate ( {
733740 result,
734741 } )
@@ -756,7 +763,7 @@ describe('Lifecycle Meilisearch integration', () => {
756763 roles : { count : 2 } , // Only count, not actual role data
757764 profile : { count : 1 } , // Only count, not actual profile data
758765 }
759-
766+
760767 // getEntry returns complete entry with full relation objects
761768 const fetchedEntryWithRelations = {
762769 documentId : '456' ,
@@ -773,13 +780,17 @@ describe('Lifecycle Meilisearch integration', () => {
773780 avatar : 'avatar.jpg' ,
774781 } ,
775782 }
776-
783+
777784 const entriesQuery = { populate : '*' , fields : '*' }
778785
779- contentTypeService . getEntry . mockResolvedValueOnce ( fetchedEntryWithRelations )
786+ contentTypeService . getEntry . mockResolvedValueOnce (
787+ fetchedEntryWithRelations ,
788+ )
780789 meilisearchService . entriesQuery . mockReturnValueOnce ( entriesQuery )
781790
782- await lifecycleHandler . subscribeContentType ( { contentType : contentTypeUid } )
791+ await lifecycleHandler . subscribeContentType ( {
792+ contentType : contentTypeUid ,
793+ } )
783794 await strapiMock . db . lifecycles . subscribe . mock . calls [ 0 ] [ 0 ] . afterCreate ( {
784795 result : lifecycleResult ,
785796 } )
@@ -792,7 +803,8 @@ describe('Lifecycle Meilisearch integration', () => {
792803
793804 // The key fix: fetchedEntryWithRelations contains full relation objects,
794805 // not the counts from lifecycleResult
795- const actualCallArgs = meilisearchService . addEntriesToMeilisearch . mock . calls [ 0 ] [ 0 ]
806+ const actualCallArgs =
807+ meilisearchService . addEntriesToMeilisearch . mock . calls [ 0 ] [ 0 ]
796808 expect ( actualCallArgs . entries . roles ) . toEqual ( [
797809 { id : 1 , name : 'Admin' , permissions : [ 'read' , 'write' ] } ,
798810 { id : 2 , name : 'Editor' , permissions : [ 'read' ] } ,
@@ -817,13 +829,15 @@ describe('Lifecycle Meilisearch integration', () => {
817829 contentTypeService . getEntry . mockResolvedValueOnce ( null )
818830 meilisearchService . entriesQuery . mockReturnValueOnce ( { populate : '*' } )
819831
820- await lifecycleHandler . subscribeContentType ( { contentType : contentTypeUid } )
821-
832+ await lifecycleHandler . subscribeContentType ( {
833+ contentType : contentTypeUid ,
834+ } )
835+
822836 // Should not throw error when getEntry returns null
823837 await expect (
824838 strapiMock . db . lifecycles . subscribe . mock . calls [ 0 ] [ 0 ] . afterCreate ( {
825839 result,
826- } )
840+ } ) ,
827841 ) . resolves . not . toThrow ( )
828842
829843 // Should still attempt to add to Meilisearch (with null entry)
@@ -864,15 +878,19 @@ describe('Lifecycle Meilisearch integration', () => {
864878 ] ,
865879 }
866880
867- const entriesQuery = {
868- populate : { category : true , tags : true } ,
869- fields : [ 'name' , 'description' ]
881+ const entriesQuery = {
882+ populate : { category : true , tags : true } ,
883+ fields : [ 'name' , 'description' ] ,
870884 }
871885
872- contentTypeService . getEntry . mockResolvedValueOnce ( fetchedEntryWithCompleteRelations )
886+ contentTypeService . getEntry . mockResolvedValueOnce (
887+ fetchedEntryWithCompleteRelations ,
888+ )
873889 meilisearchService . entriesQuery . mockReturnValueOnce ( entriesQuery )
874890
875- await lifecycleHandler . subscribeContentType ( { contentType : contentTypeUid } )
891+ await lifecycleHandler . subscribeContentType ( {
892+ contentType : contentTypeUid ,
893+ } )
876894 await strapiMock . db . lifecycles . subscribe . mock . calls [ 0 ] [ 0 ] . afterUpdate ( {
877895 result,
878896 } )
@@ -892,13 +910,16 @@ describe('Lifecycle Meilisearch integration', () => {
892910 } )
893911
894912 // Verify complete relations are sent to Meilisearch (not counts)
895- expect ( meilisearchService . updateEntriesInMeilisearch ) . toHaveBeenCalledWith ( {
913+ expect (
914+ meilisearchService . updateEntriesInMeilisearch ,
915+ ) . toHaveBeenCalledWith ( {
896916 contentType : contentTypeUid ,
897917 entries : fetchedEntryWithCompleteRelations ,
898918 } )
899919
900920 // Specifically verify relations are complete objects, not counts
901- const actualEntry = meilisearchService . updateEntriesInMeilisearch . mock . calls [ 0 ] [ 0 ] . entries
921+ const actualEntry =
922+ meilisearchService . updateEntriesInMeilisearch . mock . calls [ 0 ] [ 0 ] . entries
902923 expect ( actualEntry . category ) . toEqual ( {
903924 id : 5 ,
904925 name : 'Electronics' ,
@@ -930,7 +951,9 @@ describe('Lifecycle Meilisearch integration', () => {
930951 contentTypeService . getEntry . mockResolvedValueOnce ( fetchedEntry )
931952 meilisearchService . entriesQuery . mockReturnValueOnce ( { populate : '*' } )
932953
933- await lifecycleHandler . subscribeContentType ( { contentType : contentTypeUid } )
954+ await lifecycleHandler . subscribeContentType ( {
955+ contentType : contentTypeUid ,
956+ } )
934957 await strapiMock . db . lifecycles . subscribe . mock . calls [ 0 ] [ 0 ] . afterCreate ( {
935958 result,
936959 } )
0 commit comments