File tree Expand file tree Collapse file tree
apps/desktop/src/main/browser-agent Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -683,6 +683,23 @@ describe('collectSnapshot', () => {
683683 expect ( clickElement ( ref ) ) . toMatchObject ( { dispatched : true } )
684684 } )
685685
686+ it ( 'acts on a text line whose accessible name differs from its rendered text' , ( ) => {
687+ document . body . innerHTML = '<p><span aria-label="Details">i</span></p>'
688+ visible ( document . querySelector ( 'span' ) as HTMLSpanElement )
689+ const ref = refFor ( outlineOf ( collectSnapshot ( ) ) , 'i' )
690+
691+ expect ( clickElement ( ref ) ) . toMatchObject ( { dispatched : true } )
692+ } )
693+
694+ it ( 'acts on a text line longer than the identity name budget' , ( ) => {
695+ const text = 'Terms of service ' . repeat ( 10 ) . trim ( )
696+ document . body . innerHTML = `<p>${ text } </p>`
697+ visible ( document . querySelector ( 'p' ) as HTMLParagraphElement )
698+ const ref = refFor ( outlineOf ( collectSnapshot ( ) ) , text . slice ( 0 , 160 ) )
699+
700+ expect ( clickElement ( ref ) ) . toMatchObject ( { dispatched : true } )
701+ } )
702+
686703 it ( 'invalidates a connected ref whose name changed to a longer, different word' , ( ) => {
687704 document . body . innerHTML = '<div role="listitem">Item 1</div>'
688705 const row = visible ( document . querySelector ( '[role="listitem"]' ) as HTMLDivElement )
Original file line number Diff line number Diff line change @@ -691,7 +691,9 @@ export function collectSnapshot(
691691 160
692692 )
693693 if ( ! text ) return
694- const id = registerElement ( el , roleFor ( el ) , text )
694+ // Identity uses the name the resolver recomputes, not the displayed text,
695+ // which differs for aria-labelled leaves and past the name's length cap.
696+ const id = registerElement ( el , roleFor ( el ) , nameFor ( el ) )
695697 textLineCount ++
696698 const marker = isNew ( el ) ? ' new' : ''
697699 const lineIndex = lines . length
You can’t perform that action at this time.
0 commit comments