@@ -629,10 +629,9 @@ describe('Sort', () => {
629629 )
630630 } )
631631
632- // TODO: this test is currently not working, come back to fix in a separate PR, issue: 12907
633- it . skip ( 'should not break with existing base 62 digits' , async ( ) => {
632+ it ( 'should not break with existing base 62 digits' , async ( ) => {
634633 const collection = orderableSlug
635- // create seed docs with aa, aA, AA
634+ // create seed docs with aa, aA, a0 (legacy base64 chars for backward compatibility)
636635 const aa = await payload . create ( {
637636 collection,
638637 data : {
@@ -647,11 +646,11 @@ describe('Sort', () => {
647646 _order : 'aA' ,
648647 } ,
649648 } )
650- const AA = await payload . create ( {
649+ const a0 = await payload . create ( {
651650 collection,
652651 data : {
653- title : 'Base62 AA ' ,
654- _order : 'AA ' ,
652+ title : 'Base62 a0 ' ,
653+ _order : 'a0 ' ,
655654 } ,
656655 } )
657656
@@ -687,10 +686,18 @@ describe('Sort', () => {
687686 } ,
688687 } )
689688
690- expect ( docs [ 0 ] ?. id ) . toStrictEqual ( aa . id )
691- expect ( docs [ 1 ] ?. id ) . toStrictEqual ( aA . id )
692- expect ( docs [ 2 ] ?. id ) . toStrictEqual ( orderableDoc . id )
693- expect ( docs [ 3 ] ?. id ) . toStrictEqual ( AA . id )
689+ expect ( docs ) . toHaveLength ( 4 )
690+ const ids = [ aa . id , aA . id , a0 . id , orderableDoc . id ]
691+ expect ( docs . every ( ( { id } ) => ids . includes ( id ) ) ) . toBe ( true )
692+
693+ const a0Index = docs . findIndex ( ( d ) => d . id === a0 . id )
694+ const aAIndex = docs . findIndex ( ( d ) => d . id === aA . id )
695+ const orderableIndex = docs . findIndex ( ( d ) => d . id === orderableDoc . id )
696+
697+ // The reordered document should be positioned after the target (aA) since newKeyWillBe: 'greater'
698+ // and before the target (a0) since (a0) is the smallest fractional index
699+ expect ( orderableIndex ) . toBeGreaterThan ( aAIndex )
700+ expect ( orderableIndex ) . toBeLessThan ( a0Index )
694701 } )
695702 } )
696703
@@ -732,13 +739,11 @@ describe('Sort', () => {
732739 } )
733740 } )
734741
735- // TODO: this test is currently not working, come back to fix in a separate PR, issue: 12907
736- it . skip ( 'should set order by default' , ( ) => {
742+ it ( 'should set order by default' , ( ) => {
737743 expect ( orderable1 . _orderable_orderableJoinField1_order ) . toBeDefined ( )
738744 } )
739745
740- // TODO: this test is currently not working, come back to fix in a separate PR, issue: 12907
741- it . skip ( 'should allow setting the order with the local API' , async ( ) => {
746+ it ( 'should allow setting the order with the local API' , async ( ) => {
742747 // create two orderableJoinSlug docs
743748 orderable2 = await payload . update ( {
744749 collection : orderableSlug ,
@@ -760,8 +765,8 @@ describe('Sort', () => {
760765 expect ( orderable2 . _orderable_orderableJoinField1_order ) . toBe ( 'e4' )
761766 expect ( orderable4 . _orderable_orderableJoinField1_order ) . toBe ( 'e2' )
762767 } )
763- // TODO: this test is currently not working, come back to fix in a separate PR, issue: 12907
764- it . skip ( 'should sort join docs in the correct' , async ( ) => {
768+
769+ it ( 'should sort join docs in the correct' , async ( ) => {
765770 related = await payload . findByID ( {
766771 collection : orderableJoinSlug ,
767772 id : related . id ,
0 commit comments