@@ -92,7 +92,14 @@ vi.mock(import("~/state/pullRequests"), async (original) => {
9292vi . mock ( import ( "~/state/query" ) , async ( original ) => ( {
9393 ...( await original ( ) ) ,
9494 useEnvironmentQuery : ( ( query : unknown ) => ( {
95- data : query === "detail" ? currentDetail : query === queries . diff ? diff : null ,
95+ data :
96+ query === "detail"
97+ ? ( activityDetail ?? currentDetail )
98+ : query === "activity"
99+ ? activityDetail
100+ : query === queries . diff
101+ ? diff
102+ : null ,
96103 dataUpdatedAt : 0 ,
97104 failure : null ,
98105 isPending : false ,
@@ -111,33 +118,41 @@ vi.mock(import("~/state/usePullRequestStack"), async (original) => ({
111118 refresh,
112119 } ) ) as never ,
113120} ) ) ;
114- // The summary stand-in exposes its panel actions and nested scrolling.
115- vi . mock ( import ( "./PullRequestSummaryTab" ) , async ( original ) => ( {
116- ...( await original ( ) ) ,
117- PullRequestSummaryTab : ( ( {
118- onFixFinding,
119- scrollerRef,
120- } : ComponentProps < typeof import ( "./PullRequestSummaryTab" ) . PullRequestSummaryTab > ) => (
121- < div ref = { scrollerRef } data-testid = "summary-scroller" className = "h-full overflow-y-auto" >
122- < button
123- type = "button"
124- onClick = { ( ) =>
125- onFixFinding ?.( {
126- kind : "check" ,
127- check : { name : "Unit tests" , status : "failure" , description : "Test failed" , url : null } ,
128- } )
129- }
130- >
131- Fix check
132- </ button >
133- < div data-testid = "nested-scroller" className = "h-40 overflow-y-auto" >
134- < div className = "h-[2000px]" />
135- </ div >
136- < div className = "h-[3000px]" />
137- </ div >
138- ) ) as never ,
139- } ) ) ;
140-
121+ // Action and scroll tests use stand-ins; activity tests render the real Summary.
122+ vi . mock ( import ( "./PullRequestSummaryTab" ) , async ( original ) => {
123+ const actual = await original ( ) ;
124+ return {
125+ ...actual ,
126+ PullRequestSummaryTab : ( ( props : ComponentProps < typeof actual . PullRequestSummaryTab > ) => {
127+ if ( activityDetail !== null ) return < actual . PullRequestSummaryTab { ...props } /> ;
128+ const { onFixFinding, scrollerRef } = props ;
129+ return (
130+ < div ref = { scrollerRef } data-testid = "summary-scroller" className = "h-full overflow-y-auto" >
131+ < button
132+ type = "button"
133+ onClick = { ( ) =>
134+ onFixFinding ?.( {
135+ kind : "check" ,
136+ check : {
137+ name : "Unit tests" ,
138+ status : "failure" ,
139+ description : "Test failed" ,
140+ url : null ,
141+ } ,
142+ } )
143+ }
144+ >
145+ Fix check
146+ </ button >
147+ < div data-testid = "nested-scroller" className = "h-40 overflow-y-auto" >
148+ < div className = "h-[2000px]" />
149+ </ div >
150+ < div className = "h-[3000px]" />
151+ </ div >
152+ ) ;
153+ } ) as never ,
154+ } ;
155+ } ) ;
141156vi . mock ( import ( "../ui/toast" ) , async ( original ) => {
142157 const actual = await original ( ) ;
143158 return {
@@ -203,6 +218,7 @@ const detail: PullRequestDetailView = {
203218} ;
204219
205220let currentDetail = detail ;
221+ let activityDetail : PullRequestDetailView | null = null ;
206222
207223// Enough lines to exercise the panel's title folding with the real virtualized Code tab.
208224const diff = {
@@ -258,6 +274,7 @@ function render(props: Partial<ComponentProps<typeof PullRequestDetailPanel>> =
258274}
259275
260276beforeEach ( ( ) => {
277+ activityDetail = null ;
261278 vi . stubGlobal ( "IS_REACT_ACT_ENVIRONMENT" , true ) ;
262279 currentDetail = detail ;
263280 useComposerDraftStore . setState ( { draftsByThreadKey : { } } ) ;
@@ -698,3 +715,107 @@ it("shows the current checkout recovery detail on the first failure and on retry
698715 second . detail ,
699716 ] ) ;
700717} ) ;
718+
719+ it ( "keeps discussion counts and Timeline expansion in sync with activity refreshes" , async ( ) => {
720+ activityDetail = {
721+ ...detail ,
722+ provider : SourceControlProviderKind . make ( "gitlab" ) ,
723+ url : "https://gitlab.com/owner/repo/-/merge_requests/1" ,
724+ comments : [ ] ,
725+ commentCount : 0 ,
726+ commentsTruncated : true ,
727+ reviewThreads : [
728+ {
729+ id : "discussion-1" ,
730+ path : "src/index.ts" ,
731+ line : 1 ,
732+ side : "right" ,
733+ isResolved : false ,
734+ isOutdated : false ,
735+ comments : [
736+ {
737+ id : "note-1" ,
738+ author : detail . author ,
739+ body : "Discussion finding" ,
740+ createdAt : "2026-09-01T00:01:00Z" ,
741+ url : "https://gitlab.com/owner/repo/-/merge_requests/1#note_1" ,
742+ } ,
743+ {
744+ id : "note-2" ,
745+ author : detail . author ,
746+ body : "Discussion reply" ,
747+ createdAt : "2026-09-01T00:02:00Z" ,
748+ url : "https://gitlab.com/owner/repo/-/merge_requests/1#note_2" ,
749+ } ,
750+ ] ,
751+ } ,
752+ ] ,
753+ } ;
754+ await render ( { reference : activityDetail } ) ;
755+ await expect . element ( page . getByText ( "Discussion finding" , { exact : true } ) ) . toBeVisible ( ) ;
756+ await expect . element ( page . getByText ( "Discussion reply" , { exact : true } ) ) . toBeVisible ( ) ;
757+ expect
758+ . soft ( page . getByRole ( "button" , { name : / ^ C o m m e n t s \( / } ) . element ( ) . textContent )
759+ . toBe ( "Comments (2)" ) ;
760+ const warning = page . getByText ( / o p e n i t o n t h e h o s t t o r e a d t h e r e s t / ) . element ( ) . textContent ;
761+ expect . soft ( warning ) . toMatch ( / \b 2 \b / ) ;
762+ expect . soft ( warning ) . not . toMatch ( / m o s t r e c e n t / i) ;
763+
764+ await tab ( "Timeline" ) . click ( ) ;
765+ await expect . element ( page . getByText ( "Discussion finding" , { exact : true } ) . last ( ) ) . toBeVisible ( ) ;
766+ await expect . element ( page . getByText ( "Discussion reply" , { exact : true } ) . last ( ) ) . toBeVisible ( ) ;
767+ expect . soft ( page . getByLabelText ( / ^ [ 0 - 9 ] + c o m m e n t s ? $ / ) . element ( ) . textContent ) . toBe ( "2" ) ;
768+
769+ const threadToggle = page . getByRole ( "button" , { name : / ^ s r c \/ i n d e x \. t s : 1 / } ) ;
770+ const expectThread = ( expanded : boolean , status : string | null ) => {
771+ const toggle = threadToggle . element ( ) ;
772+ if ( status ) expect ( toggle . textContent ) . toContain ( status ) ;
773+ else expect ( toggle . textContent ) . not . toMatch ( / R e s o l v e d | R e v i e w d i s m i s s e d / ) ;
774+ const visibleBody = ( toggle . parentElement as HTMLElement ) . innerText ;
775+ expect ( {
776+ expanded : toggle . getAttribute ( "aria-expanded" ) ,
777+ findingVisible : visibleBody . includes ( "Discussion finding" ) ,
778+ replyVisible : visibleBody . includes ( "Discussion reply" ) ,
779+ } ) . toEqual ( {
780+ expanded : String ( expanded ) ,
781+ findingVisible : expanded ,
782+ replyVisible : expanded ,
783+ } ) ;
784+ } ;
785+ const refreshActivity = async ( isResolved : boolean , reviewState : string | null = null ) => {
786+ await tab ( "Code" ) . click ( ) ;
787+ await expect
788+ . element ( page . getByRole ( "button" , { name : "Expand all files" , exact : true } ) )
789+ . toBeVisible ( ) ;
790+ const current = activityDetail ! ;
791+ activityDetail = {
792+ ...current ,
793+ comments : current . reviewThreads . flatMap ( ( thread ) =>
794+ thread . comments . map ( ( comment ) => ( {
795+ ...comment ,
796+ kind : "review-comment" as const ,
797+ path : thread . path ,
798+ reviewState,
799+ } ) ) ,
800+ ) ,
801+ reviewThreads : current . reviewThreads . map ( ( thread ) => ( { ...thread , isResolved } ) ) ,
802+ } ;
803+ await tab ( "Timeline" ) . click ( ) ;
804+ } ;
805+
806+ expectThread ( true , null ) ;
807+ await refreshActivity ( true ) ;
808+ expectThread ( false , "Resolved" ) ;
809+ await threadToggle . click ( ) ;
810+ expectThread ( true , "Resolved" ) ;
811+ await refreshActivity ( true ) ;
812+ expectThread ( true , "Resolved" ) ;
813+ await threadToggle . click ( ) ;
814+ expectThread ( false , "Resolved" ) ;
815+ await refreshActivity ( false ) ;
816+ expectThread ( true , null ) ;
817+ await refreshActivity ( false , "DISMISSED" ) ;
818+ expectThread ( false , "Review dismissed" ) ;
819+ await refreshActivity ( false ) ;
820+ expectThread ( true , null ) ;
821+ } ) ;
0 commit comments