@@ -101,43 +101,49 @@ vi.mock("./PullRequestThreadLinks", () => ({ PullRequestThreadLinks: () => null
101101vi . mock ( "./PullRequestSummaryTab" , ( ) => ( {
102102 PullRequestSummaryTab : ( {
103103 onFixFinding,
104+ scrollerRef,
104105 } : ComponentProps < typeof import ( "./PullRequestSummaryTab" ) . PullRequestSummaryTab > ) => (
105- < button
106- onClick = { ( ) =>
107- onFixFinding ?.( {
108- kind : "check" ,
109- check : { name : "Unit tests" , status : "failure" , description : "Test failed" , url : null } ,
110- } )
111- }
112- >
113- Fix check
114- </ button >
106+ < div ref = { scrollerRef } data-test-scroll = "summary" >
107+ < button
108+ onClick = { ( ) =>
109+ onFixFinding ?.( {
110+ kind : "check" ,
111+ check : { name : "Unit tests" , status : "failure" , description : "Test failed" , url : null } ,
112+ } )
113+ }
114+ >
115+ Fix check
116+ </ button >
117+ </ div >
115118 ) ,
116119} ) ) ;
117120vi . mock ( "./PullRequestCodeTab" , ( ) => ( {
118121 default : ( {
119122 onAddToAgentSelection,
123+ scrollerRef,
120124 } : ComponentProps < typeof import ( "./PullRequestCodeTab" ) . default > ) => (
121- < button
122- onClick = { ( ) =>
123- onAddToAgentSelection ?.( {
124- request : "Fix this line" ,
125- comment : {
126- id : "note-1" ,
127- sectionId : "file:a.ts" ,
128- sectionTitle : "a.ts" ,
129- filePath : "a.ts" ,
130- startIndex : 0 ,
131- endIndex : 0 ,
132- rangeLabel : "L1" ,
133- text : "Please fix" ,
134- diff : "+broken()" ,
135- } ,
136- } )
137- }
138- >
139- Add to agent
140- </ button >
125+ < div ref = { scrollerRef } data-test-scroll = "code" >
126+ < button
127+ onClick = { ( ) =>
128+ onAddToAgentSelection ?.( {
129+ request : "Fix this line" ,
130+ comment : {
131+ id : "note-1" ,
132+ sectionId : "file:a.ts" ,
133+ sectionTitle : "a.ts" ,
134+ filePath : "a.ts" ,
135+ startIndex : 0 ,
136+ endIndex : 0 ,
137+ rangeLabel : "L1" ,
138+ text : "Please fix" ,
139+ diff : "+broken()" ,
140+ } ,
141+ } )
142+ }
143+ >
144+ Add to agent
145+ </ button >
146+ </ div >
141147 ) ,
142148} ) ) ;
143149
@@ -336,3 +342,82 @@ describe.each([
336342 }
337343 } ) ;
338344} ) ;
345+
346+ it ( "changes the title only for the active tab's main scroller" , async ( ) => {
347+ const scrollers = new Map < string , { scrollTop : number ; scrollHeight : number } > ( ) ;
348+ await act ( async ( ) => {
349+ renderer = create (
350+ < PullRequestDetailPanel
351+ environmentId = { threadRef . environmentId }
352+ reference = { detail }
353+ context = "page"
354+ shortcutsEnabled = { false }
355+ getShortcutContext = { ( ) => ( {
356+ terminalFocus : false ,
357+ terminalOpen : false ,
358+ previewFocus : false ,
359+ previewOpen : false ,
360+ isWeb : true ,
361+ isDesktop : false ,
362+ } ) }
363+ /> ,
364+ {
365+ createNodeMock : ( element ) => {
366+ const props = element . props as Record < string , unknown > ;
367+ const name = props [ "data-test-scroll" ] as string | undefined ;
368+ if ( name ) {
369+ const scroller = { scrollTop : 0 , scrollHeight : 300 } ;
370+ scrollers . set ( name , scroller ) ;
371+ return scroller ;
372+ }
373+ return { scrollHeight : props . inert === false ? 100 : 20 } ;
374+ } ,
375+ } ,
376+ ) ;
377+ } ) ;
378+
379+ const mainScroll = renderer . root . findByProps ( {
380+ className : "relative flex min-h-0 flex-1 flex-col overflow-hidden" ,
381+ } ) ;
382+ const titleFold = ( ) => {
383+ let node = renderer . root . findByType ( "h1" ) ;
384+ while ( typeof node . props . inert !== "boolean" ) node = node . parent ! ;
385+ return node ;
386+ } ;
387+ const summary = scrollers . get ( "summary" ) ! ;
388+ const nested = { scrollTop : 200 } ;
389+ await act ( async ( ) => mainScroll . props . onScrollCapture ( { target : nested } ) ) ;
390+ expect ( titleFold ( ) . props . inert ) . toBe ( false ) ;
391+ summary . scrollTop = 180 ;
392+ nested . scrollTop = 0 ;
393+ await act ( async ( ) => {
394+ mainScroll . props . onScrollCapture ( { target : summary } ) ;
395+ mainScroll . props . onScrollCapture ( { target : nested } ) ;
396+ } ) ;
397+ expect ( titleFold ( ) . props . inert ) . toBe ( true ) ;
398+ expect ( summary . scrollTop ) . toBe ( 100 ) ;
399+ expect ( nested . scrollTop ) . toBe ( 0 ) ;
400+
401+ await act ( async ( ) => mainScroll . props . onScrollCapture ( { target : { scrollTop : 0 } } ) ) ;
402+ expect ( titleFold ( ) . props . inert ) . toBe ( true ) ;
403+ summary . scrollTop = 0 ;
404+ await act ( async ( ) => mainScroll . props . onScrollCapture ( { target : summary } ) ) ;
405+ expect ( titleFold ( ) . props . inert ) . toBe ( false ) ;
406+
407+ await click ( "Code" ) ;
408+ const code = scrollers . get ( "code" ) ! ;
409+ summary . scrollTop = 180 ;
410+ await act ( async ( ) => mainScroll . props . onScrollCapture ( { target : summary } ) ) ;
411+ expect ( titleFold ( ) . props . inert ) . toBe ( false ) ;
412+ code . scrollTop = 180 ;
413+ await act ( async ( ) => mainScroll . props . onScrollCapture ( { target : code } ) ) ;
414+ expect ( titleFold ( ) . props . inert ) . toBe ( true ) ;
415+ expect ( code . scrollTop ) . toBe ( 100 ) ;
416+ await click ( "Summary" ) ;
417+ expect ( titleFold ( ) . props . inert ) . toBe ( false ) ;
418+ await click ( "Code" ) ;
419+ expect ( titleFold ( ) . props . inert ) . toBe ( true ) ;
420+ code . scrollTop = 0 ;
421+ await act ( async ( ) => mainScroll . props . onScrollCapture ( { target : code } ) ) ;
422+ expect ( titleFold ( ) . props . inert ) . toBe ( false ) ;
423+ } ) ;
0 commit comments