Skip to content

Commit b426052

Browse files
authored
test: fix import-export plugin int (#13474)
CI is blocked because of failing int tests within the import/export plugin suite after #13380.
1 parent 047519f commit b426052

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

test/plugin-import-export/int.spec.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,15 @@ describe('@payloadcms/plugin-import-export', () => {
103103
id: doc.id,
104104
})
105105

106+
const { totalDocs: totalNumberOfDocs } = await payload.count({
107+
collection: 'pages',
108+
})
109+
106110
expect(doc.filename).toBeDefined()
107111
const expectedPath = path.join(dirname, './uploads', doc.filename as string)
108112
const data = await readCSV(expectedPath)
109113

110-
expect(data).toHaveLength(250)
114+
expect(data).toHaveLength(totalNumberOfDocs)
111115
})
112116

113117
it('should create a file for collection csv with all documents when no limit', async () => {
@@ -125,11 +129,15 @@ describe('@payloadcms/plugin-import-export', () => {
125129
id: doc.id,
126130
})
127131

132+
const { totalDocs: totalNumberOfDocs } = await payload.count({
133+
collection: 'pages',
134+
})
135+
128136
expect(doc.filename).toBeDefined()
129137
const expectedPath = path.join(dirname, './uploads', doc.filename as string)
130138
const data = await readCSV(expectedPath)
131139

132-
expect(data).toHaveLength(250)
140+
expect(data).toHaveLength(totalNumberOfDocs)
133141
})
134142

135143
it('should create a file for collection csv from limit and page 1', async () => {
@@ -174,12 +182,21 @@ describe('@payloadcms/plugin-import-export', () => {
174182
id: doc.id,
175183
})
176184

185+
// query pages with the same limit and page as the export made above
186+
const pages = await payload.find({
187+
collection: 'pages',
188+
limit: 100,
189+
page: 2,
190+
})
191+
192+
const firstDocOnPage2 = pages.docs?.[0]
193+
177194
expect(doc.filename).toBeDefined()
178195
const expectedPath = path.join(dirname, './uploads', doc.filename as string)
179196
const data = await readCSV(expectedPath)
180197

181198
expect(data[0].id).toBeDefined()
182-
expect(data[0].title).toStrictEqual('Doc 149')
199+
expect(data[0].title).toStrictEqual(firstDocOnPage2?.title)
183200
})
184201

185202
it('should not create a file for collection csv when limit < 0', async () => {

0 commit comments

Comments
 (0)