@@ -573,6 +573,44 @@ describe('Versions', () => {
573
573
expect ( restoredVersion . title ) . toStrictEqual ( 'v1' )
574
574
} )
575
575
576
+ it ( 'findVersions - pagination should work correctly' , async ( ) => {
577
+ const post = await payload . create ( {
578
+ collection : 'draft-posts' ,
579
+ data : { description : 'a' , title : 'title' } ,
580
+ } )
581
+ for ( let i = 0 ; i < 100 ; i ++ ) {
582
+ await payload . update ( { collection : 'draft-posts' , id : post . id , data : { } } )
583
+ }
584
+ const res = await payload . findVersions ( {
585
+ collection : 'draft-posts' ,
586
+ where : { parent : { equals : post . id } } ,
587
+ } )
588
+ expect ( res . totalDocs ) . toBe ( 101 )
589
+ expect ( res . docs ) . toHaveLength ( 10 )
590
+ const resPaginationFalse = await payload . findVersions ( {
591
+ collection : 'draft-posts' ,
592
+ where : { parent : { equals : post . id } } ,
593
+ pagination : false ,
594
+ } )
595
+ const resPaginationFalse2 = await payload . find ( {
596
+ collection : 'draft-posts' ,
597
+ // where: { parent: { equals: post.id } },
598
+ pagination : false ,
599
+ } )
600
+
601
+ expect ( resPaginationFalse . docs ) . toHaveLength ( 101 )
602
+ expect ( resPaginationFalse . totalDocs ) . toBe ( 101 )
603
+
604
+ const resPaginationFalseLimit0 = await payload . findVersions ( {
605
+ collection : 'draft-posts' ,
606
+ where : { parent : { equals : post . id } } ,
607
+ pagination : false ,
608
+ limit : 0 ,
609
+ } )
610
+ expect ( resPaginationFalseLimit0 . docs ) . toHaveLength ( 101 )
611
+ expect ( resPaginationFalseLimit0 . totalDocs ) . toBe ( 101 )
612
+ } )
613
+
576
614
describe ( 'Update' , ( ) => {
577
615
it ( 'should allow a draft to be patched' , async ( ) => {
578
616
const originalTitle = 'Here is a published post'
@@ -1802,6 +1840,31 @@ describe('Versions', () => {
1802
1840
expect ( version_1_deleted ) . toBeFalsy ( )
1803
1841
} )
1804
1842
1843
+ it ( 'findGlobalVersions - pagination should work correctly' , async ( ) => {
1844
+ for ( let i = 0 ; i < 100 ; i ++ ) {
1845
+ await payload . updateGlobal ( { slug : 'draft-unlimited-global' , data : { title : 'title' } } )
1846
+ }
1847
+ const res = await payload . findGlobalVersions ( {
1848
+ slug : 'draft-unlimited-global' ,
1849
+ } )
1850
+ expect ( res . totalDocs ) . toBe ( 100 )
1851
+ expect ( res . docs ) . toHaveLength ( 10 )
1852
+ const resPaginationFalse = await payload . findGlobalVersions ( {
1853
+ slug : 'draft-unlimited-global' ,
1854
+ pagination : false ,
1855
+ } )
1856
+ expect ( resPaginationFalse . docs ) . toHaveLength ( 100 )
1857
+ expect ( resPaginationFalse . totalDocs ) . toBe ( 100 )
1858
+
1859
+ const resPaginationFalseLimit0 = await payload . findGlobalVersions ( {
1860
+ slug : 'draft-unlimited-global' ,
1861
+ pagination : false ,
1862
+ limit : 0 ,
1863
+ } )
1864
+ expect ( resPaginationFalseLimit0 . docs ) . toHaveLength ( 100 )
1865
+ expect ( resPaginationFalseLimit0 . totalDocs ) . toBe ( 100 )
1866
+ } )
1867
+
1805
1868
describe ( 'Read' , ( ) => {
1806
1869
it ( 'should allow a version to be retrieved by ID' , async ( ) => {
1807
1870
const version = await payload . findGlobalVersionByID ( {
0 commit comments