@@ -103,11 +103,15 @@ describe('@payloadcms/plugin-import-export', () => {
103
103
id : doc . id ,
104
104
} )
105
105
106
+ const { totalDocs : totalNumberOfDocs } = await payload . count ( {
107
+ collection : 'pages' ,
108
+ } )
109
+
106
110
expect ( doc . filename ) . toBeDefined ( )
107
111
const expectedPath = path . join ( dirname , './uploads' , doc . filename as string )
108
112
const data = await readCSV ( expectedPath )
109
113
110
- expect ( data ) . toHaveLength ( 250 )
114
+ expect ( data ) . toHaveLength ( totalNumberOfDocs )
111
115
} )
112
116
113
117
it ( 'should create a file for collection csv with all documents when no limit' , async ( ) => {
@@ -125,11 +129,15 @@ describe('@payloadcms/plugin-import-export', () => {
125
129
id : doc . id ,
126
130
} )
127
131
132
+ const { totalDocs : totalNumberOfDocs } = await payload . count ( {
133
+ collection : 'pages' ,
134
+ } )
135
+
128
136
expect ( doc . filename ) . toBeDefined ( )
129
137
const expectedPath = path . join ( dirname , './uploads' , doc . filename as string )
130
138
const data = await readCSV ( expectedPath )
131
139
132
- expect ( data ) . toHaveLength ( 250 )
140
+ expect ( data ) . toHaveLength ( totalNumberOfDocs )
133
141
} )
134
142
135
143
it ( 'should create a file for collection csv from limit and page 1' , async ( ) => {
@@ -174,12 +182,21 @@ describe('@payloadcms/plugin-import-export', () => {
174
182
id : doc . id ,
175
183
} )
176
184
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
+
177
194
expect ( doc . filename ) . toBeDefined ( )
178
195
const expectedPath = path . join ( dirname , './uploads' , doc . filename as string )
179
196
const data = await readCSV ( expectedPath )
180
197
181
198
expect ( data [ 0 ] . id ) . toBeDefined ( )
182
- expect ( data [ 0 ] . title ) . toStrictEqual ( 'Doc 149' )
199
+ expect ( data [ 0 ] . title ) . toStrictEqual ( firstDocOnPage2 ?. title )
183
200
} )
184
201
185
202
it ( 'should not create a file for collection csv when limit < 0' , async ( ) => {
0 commit comments