@@ -663,7 +663,8 @@ describe('PresentationEditor - goToAnchor', () => {
663663 documentId : 'test-doc' ,
664664 } ) ;
665665
666- mockActiveEditor . commands . setCursorById = vi . fn ( ) . mockReturnValueOnce ( false ) . mockReturnValueOnce ( true ) ;
666+ const bodyEditor = editor . getActiveEditor ( ) ;
667+ bodyEditor . commands . setCursorById = vi . fn ( ) . mockReturnValueOnce ( false ) . mockReturnValueOnce ( true ) ;
667668 editor . getActiveEditor = vi . fn ( ( ) => mockActiveEditor as never ) ;
668669 mockResolveTrackedChange . mockReturnValueOnce ( {
669670 id : 'canonical-tc-id' ,
@@ -683,13 +684,14 @@ describe('PresentationEditor - goToAnchor', () => {
683684 } ) ;
684685
685686 expect ( result ) . toBe ( true ) ;
686- expect ( mockActiveEditor . commands . setCursorById ) . toHaveBeenNthCalledWith ( 1 , 'canonical-tc-id' , {
687+ expect ( bodyEditor . commands . setCursorById ) . toHaveBeenNthCalledWith ( 1 , 'canonical-tc-id' , {
687688 preferredActiveThreadId : 'canonical-tc-id' ,
688689 } ) ;
689- expect ( mockResolveTrackedChange ) . toHaveBeenCalledWith ( mockActiveEditor , 'canonical-tc-id' ) ;
690- expect ( mockActiveEditor . commands . setCursorById ) . toHaveBeenNthCalledWith ( 2 , 'raw-tc-id' , {
690+ expect ( mockResolveTrackedChange ) . toHaveBeenCalledWith ( bodyEditor , 'canonical-tc-id' ) ;
691+ expect ( bodyEditor . commands . setCursorById ) . toHaveBeenNthCalledWith ( 2 , 'raw-tc-id' , {
691692 preferredActiveThreadId : 'raw-tc-id' ,
692693 } ) ;
694+ expect ( mockActiveEditor . commands . setCursorById ) . toBeUndefined ( ) ;
693695 } ) ;
694696
695697 it ( 'falls back to scroll + setTextSelection when both setCursorById attempts fail for tracked changes' , async ( ) => {
@@ -698,7 +700,8 @@ describe('PresentationEditor - goToAnchor', () => {
698700 documentId : 'test-doc' ,
699701 } ) ;
700702
701- mockActiveEditor . commands . setCursorById = vi . fn ( ) . mockReturnValue ( false ) ;
703+ const bodyEditor = editor . getActiveEditor ( ) ;
704+ bodyEditor . commands . setCursorById = vi . fn ( ) . mockReturnValue ( false ) ;
702705 editor . getActiveEditor = vi . fn ( ( ) => mockActiveEditor as never ) ;
703706 editor . scrollToPositionAsync = vi . fn ( ) . mockResolvedValue ( undefined ) ;
704707
@@ -720,12 +723,13 @@ describe('PresentationEditor - goToAnchor', () => {
720723 } ) ;
721724
722725 expect ( result ) . toBe ( true ) ;
723- expect ( mockActiveEditor . commands . setCursorById ) . toHaveBeenCalledTimes ( 2 ) ;
726+ expect ( bodyEditor . commands . setCursorById ) . toHaveBeenCalledTimes ( 2 ) ;
724727 expect ( editor . scrollToPositionAsync ) . toHaveBeenCalledWith ( 88 , {
725728 behavior : 'auto' ,
726729 block : 'center' ,
727730 } ) ;
728- expect ( mockActiveEditor . commands . setTextSelection ) . toHaveBeenCalledWith ( { from : 88 , to : 88 } ) ;
729- expect ( mockActiveEditor . view ?. focus ) . toHaveBeenCalled ( ) ;
731+ expect ( bodyEditor . commands . setTextSelection ) . toHaveBeenCalledWith ( { from : 88 , to : 88 } ) ;
732+ expect ( bodyEditor . view ?. focus ) . toHaveBeenCalled ( ) ;
733+ expect ( mockResolveTrackedChange ) . toHaveBeenCalledWith ( bodyEditor , 'canonical-tc-id' ) ;
730734 } ) ;
731735} ) ;
0 commit comments