@@ -823,7 +823,6 @@ describe('get collection articles', () => {
823
823
collectionInput : { id : collectionGlobalId } ,
824
824
articleInput : {
825
825
last : 1 ,
826
- // 6
827
826
before : data2 ?. node . articles . pageInfo . endCursor ,
828
827
reversed : false ,
829
828
} ,
@@ -854,41 +853,61 @@ describe('get collection articles', () => {
854
853
expect ( data4 ?. node . articles . pageInfo . hasNextPage ) . toBe ( true )
855
854
expect ( data4 ?. node . articles . edges [ 0 ] . node . id ) . toBe ( articleGlobalIds [ 0 ] )
856
855
857
- // reversed by default
856
+ // backward pagination order is correct
858
857
const { errors : errors5 , data : data5 } = await server . executeOperation ( {
859
858
query : GET_COLLECTION_ARTICLES ,
860
859
variables : {
861
860
collectionInput : { id : collectionGlobalId } ,
862
- articleInput : { first : 2 } ,
861
+ articleInput : {
862
+ last : 2 ,
863
+ before : data2 ?. node . articles . pageInfo . endCursor ,
864
+ reversed : false ,
865
+ } ,
863
866
} ,
864
867
} )
865
868
expect ( errors5 ) . toBeUndefined ( )
866
869
expect ( data5 ?. node . articles . totalCount ) . toBe ( 3 )
867
870
expect ( data5 ?. node . articles . edges . length ) . toBe ( 2 )
868
871
expect ( data5 ?. node . articles . pageInfo . hasPreviousPage ) . toBe ( false )
869
872
expect ( data5 ?. node . articles . pageInfo . hasNextPage ) . toBe ( true )
870
- expect ( data5 ?. node . articles . edges [ 0 ] . node . id ) . toBe ( articleGlobalIds [ 2 ] )
873
+ expect ( data5 ?. node . articles . edges [ 0 ] . node . id ) . toBe ( articleGlobalIds [ 0 ] )
871
874
expect ( data5 ?. node . articles . edges [ 1 ] . node . id ) . toBe ( articleGlobalIds [ 1 ] )
872
875
873
- // includeAfter
876
+ // reversed by default
874
877
const { errors : errors6 , data : data6 } = await server . executeOperation ( {
878
+ query : GET_COLLECTION_ARTICLES ,
879
+ variables : {
880
+ collectionInput : { id : collectionGlobalId } ,
881
+ articleInput : { first : 2 } ,
882
+ } ,
883
+ } )
884
+ expect ( errors6 ) . toBeUndefined ( )
885
+ expect ( data6 ?. node . articles . totalCount ) . toBe ( 3 )
886
+ expect ( data6 ?. node . articles . edges . length ) . toBe ( 2 )
887
+ expect ( data6 ?. node . articles . pageInfo . hasPreviousPage ) . toBe ( false )
888
+ expect ( data6 ?. node . articles . pageInfo . hasNextPage ) . toBe ( true )
889
+ expect ( data6 ?. node . articles . edges [ 0 ] . node . id ) . toBe ( articleGlobalIds [ 2 ] )
890
+ expect ( data6 ?. node . articles . edges [ 1 ] . node . id ) . toBe ( articleGlobalIds [ 1 ] )
891
+
892
+ // includeAfter
893
+ const { errors : errors7 , data : data7 } = await server . executeOperation ( {
875
894
query : GET_COLLECTION_ARTICLES ,
876
895
variables : {
877
896
collectionInput : { id : collectionGlobalId } ,
878
897
articleInput : {
879
898
first : 2 ,
880
- after : data5 ?. node . articles . pageInfo . endCursor ,
899
+ after : data6 ?. node . articles . pageInfo . endCursor ,
881
900
includeAfter : true ,
882
901
} ,
883
902
} ,
884
903
} )
885
- expect ( errors6 ) . toBeUndefined ( )
886
- expect ( data6 ?. node . articles . totalCount ) . toBe ( 3 )
887
- expect ( data6 ?. node . articles . edges . length ) . toBe ( 2 )
888
- expect ( data6 ?. node . articles . pageInfo . hasPreviousPage ) . toBe ( true )
889
- expect ( data6 ?. node . articles . pageInfo . hasNextPage ) . toBe ( false )
890
- expect ( data6 ?. node . articles . edges [ 0 ] . node . id ) . toBe ( articleGlobalIds [ 1 ] )
891
- expect ( data6 ?. node . articles . edges [ 1 ] . node . id ) . toBe ( articleGlobalIds [ 0 ] )
904
+ expect ( errors7 ) . toBeUndefined ( )
905
+ expect ( data7 ?. node . articles . totalCount ) . toBe ( 3 )
906
+ expect ( data7 ?. node . articles . edges . length ) . toBe ( 2 )
907
+ expect ( data7 ?. node . articles . pageInfo . hasPreviousPage ) . toBe ( true )
908
+ expect ( data7 ?. node . articles . pageInfo . hasNextPage ) . toBe ( false )
909
+ expect ( data7 ?. node . articles . edges [ 0 ] . node . id ) . toBe ( articleGlobalIds [ 1 ] )
910
+ expect ( data7 ?. node . articles . edges [ 1 ] . node . id ) . toBe ( articleGlobalIds [ 0 ] )
892
911
893
912
// return total count if first is 0
894
913
const { errors : errors0 , data : data0 } = await server . executeOperation ( {
0 commit comments