Skip to content

Commit 78dd466

Browse files
Merge pull request #1 from mimartinez/patch-2
Wrap fetchedEntry in an array for Meilisearch calls
2 parents 150883a + 6d2f4b7 commit 78dd466

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

server/src/__tests__/lifecycle.test.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('Lifecycle Meilisearch integration', () => {
118118
// Verify the fetched entry is passed to Meilisearch
119119
expect(meilisearchService.addEntriesToMeilisearch).toHaveBeenCalledWith({
120120
contentType: contentTypeUid,
121-
entries: fetchedEntry,
121+
entries: [fetchedEntry],
122122
})
123123
expect(storeService.addListenedContentType).toHaveBeenCalledWith({
124124
contentType: contentTypeUid,
@@ -271,7 +271,7 @@ describe('Lifecycle Meilisearch integration', () => {
271271
// Verify the fetched entry is passed to Meilisearch
272272
expect(meilisearchService.updateEntriesInMeilisearch).toHaveBeenCalledWith({
273273
contentType: contentTypeUid,
274-
entries: fetchedEntry,
274+
entries: [fetchedEntry],
275275
})
276276
})
277277

@@ -339,7 +339,7 @@ describe('Lifecycle Meilisearch integration', () => {
339339
// Verify the entry sent to Meilisearch is the fetched entry
340340
expect(meilisearchService.addEntriesToMeilisearch).toHaveBeenCalledWith({
341341
contentType: contentTypeUid,
342-
entries: fetchedEntry,
342+
entries: [fetchedEntry],
343343
})
344344
})
345345

@@ -373,7 +373,7 @@ describe('Lifecycle Meilisearch integration', () => {
373373
// Verify the entry sent to Meilisearch is the fetched entry
374374
expect(meilisearchService.updateEntriesInMeilisearch).toHaveBeenCalledWith({
375375
contentType: contentTypeUid,
376-
entries: fetchedEntry,
376+
entries: [fetchedEntry],
377377
})
378378
})
379379

@@ -407,7 +407,7 @@ describe('Lifecycle Meilisearch integration', () => {
407407
// Verify the entry sent to Meilisearch is the fetched entry
408408
expect(meilisearchService.addEntriesToMeilisearch).toHaveBeenCalledWith({
409409
contentType: contentTypeUid,
410-
entries: fetchedEntry,
410+
entries: [fetchedEntry],
411411
})
412412
})
413413

@@ -486,7 +486,7 @@ describe('Lifecycle Meilisearch integration', () => {
486486
// Verify the entry sent to Meilisearch is the fetched entry
487487
expect(meilisearchService.addEntriesToMeilisearch).toHaveBeenCalledWith({
488488
contentType: contentTypeUid,
489-
entries: fetchedEntry,
489+
entries: [fetchedEntry],
490490
})
491491
})
492492

@@ -520,7 +520,7 @@ describe('Lifecycle Meilisearch integration', () => {
520520
// Verify the entry sent to Meilisearch is the fetched entry
521521
expect(meilisearchService.updateEntriesInMeilisearch).toHaveBeenCalledWith({
522522
contentType: contentTypeUid,
523-
entries: fetchedEntry,
523+
entries: [fetchedEntry],
524524
})
525525
})
526526

@@ -798,18 +798,18 @@ describe('Lifecycle Meilisearch integration', () => {
798798
// Verify the complete entry with full relations is sent to Meilisearch, not the lifecycle result with counts
799799
expect(meilisearchService.addEntriesToMeilisearch).toHaveBeenCalledWith({
800800
contentType: contentTypeUid,
801-
entries: fetchedEntryWithRelations,
801+
entries: [fetchedEntryWithRelations],
802802
})
803803

804804
// The key fix: fetchedEntryWithRelations contains full relation objects,
805805
// not the counts from lifecycleResult
806806
const actualCallArgs =
807-
meilisearchService.addEntriesToMeilisearch.mock.calls[0][0]
808-
expect(actualCallArgs.entries.roles).toEqual([
807+
meilisearchService.addEntriesToMeilisearch.mock.calls[0][0].entries[0]
808+
expect(actualCallArgs.roles).toEqual([
809809
{ id: 1, name: 'Admin', permissions: ['read', 'write'] },
810810
{ id: 2, name: 'Editor', permissions: ['read'] },
811811
])
812-
expect(actualCallArgs.entries.profile).toEqual({
812+
expect(actualCallArgs.profile).toEqual({
813813
id: 10,
814814
bio: 'User biography',
815815
avatar: 'avatar.jpg',
@@ -843,7 +843,7 @@ describe('Lifecycle Meilisearch integration', () => {
843843
// Should still attempt to add to Meilisearch (with null entry)
844844
expect(meilisearchService.addEntriesToMeilisearch).toHaveBeenCalledWith({
845845
contentType: contentTypeUid,
846-
entries: null,
846+
entries: [null],
847847
})
848848
})
849849

@@ -914,12 +914,13 @@ describe('Lifecycle Meilisearch integration', () => {
914914
meilisearchService.updateEntriesInMeilisearch,
915915
).toHaveBeenCalledWith({
916916
contentType: contentTypeUid,
917-
entries: fetchedEntryWithCompleteRelations,
917+
entries: [fetchedEntryWithCompleteRelations],
918918
})
919919

920920
// Specifically verify relations are complete objects, not counts
921921
const actualEntry =
922-
meilisearchService.updateEntriesInMeilisearch.mock.calls[0][0].entries
922+
meilisearchService.updateEntriesInMeilisearch.mock.calls[0][0]
923+
.entries[0]
923924
expect(actualEntry.category).toEqual({
924925
id: 5,
925926
name: 'Electronics',

0 commit comments

Comments
 (0)