@@ -33,6 +33,10 @@ jest.unstable_mockModule(
3333const { handleScrollToElement } =
3434 await import ( '../../../tools/gestures/handlers/scroll-to-element.js' ) ;
3535
36+ function resultText ( result : { content : Array < { type : string } > } ) : string {
37+ return ( result . content [ 0 ] as unknown as { text : string } ) . text ;
38+ }
39+
3640const NO_SUCH_ELEMENT = {
3741 error : 'no such element' ,
3842 message :
@@ -51,14 +55,15 @@ describe('handleScrollToElement', () => {
5155 mockPerformVerticalScroll . mockClear ( ) ;
5256
5357 const result = await handleScrollToElement ( remoteDriver as never , {
58+ action : 'scroll_to_element' ,
5459 strategy : 'accessibility id' ,
5560 selector : 'missing' ,
5661 maxScrollAttempts : 1 ,
5762 } ) ;
5863
5964 expect ( result . isError ) . toBe ( true ) ;
60- expect ( result . content [ 0 ] . text ) . toContain ( 'not found after 1 scroll' ) ;
61- expect ( result . content [ 0 ] . text ) . not . toContain ( 'already visible' ) ;
65+ expect ( resultText ( result ) ) . toContain ( 'not found after 1 scroll' ) ;
66+ expect ( resultText ( result ) ) . not . toContain ( 'already visible' ) ;
6267 expect ( mockPerformVerticalScroll ) . toHaveBeenCalledTimes ( 1 ) ;
6368 } ) ;
6469
@@ -72,13 +77,14 @@ describe('handleScrollToElement', () => {
7277 mockPerformVerticalScroll . mockClear ( ) ;
7378
7479 const result = await handleScrollToElement ( remoteDriver as never , {
80+ action : 'scroll_to_element' ,
7581 strategy : 'accessibility id' ,
7682 selector : 'submit' ,
7783 maxScrollAttempts : 1 ,
7884 } ) ;
7985
8086 expect ( result . isError ) . toBeFalsy ( ) ;
81- expect ( result . content [ 0 ] . text ) . toContain ( 'already visible' ) ;
87+ expect ( resultText ( result ) ) . toContain ( 'already visible' ) ;
8288 expect ( mockPerformVerticalScroll ) . not . toHaveBeenCalled ( ) ;
8389 } ) ;
8490} ) ;
0 commit comments