@@ -42,6 +42,21 @@ import { ThreadRelationshipsPanel } from "./ThreadRelationshipsControl";
4242
4343let renderer : ReactTestRenderer ;
4444
45+ // Row-group disclosures, excluding the section's own fold toggle in its heading.
46+ const rowGroupToggles = ( root : ReactTestInstance , expanded : boolean ) =>
47+ root . findAll ( ( node ) => {
48+ if ( node . type !== "button" || node . props [ "aria-expanded" ] !== expanded ) return false ;
49+ for ( let parent = node . parent ; parent ; parent = parent . parent ) {
50+ if ( parent . type === "h3" ) return false ;
51+ }
52+ return true ;
53+ } ) ;
54+ const rowGroupToggle = ( root : ReactTestInstance , expanded : boolean ) => {
55+ const [ toggle , ...rest ] = rowGroupToggles ( root , expanded ) ;
56+ if ( ! toggle || rest . length > 0 ) throw new Error ( `Expected one row-group toggle (${ expanded } )` ) ;
57+ return toggle ;
58+ } ;
59+
4560afterEach ( async ( ) => {
4661 await act ( async ( ) => renderer ?. unmount ( ) ) ;
4762 vi . unstubAllGlobals ( ) ;
@@ -216,7 +231,7 @@ it("shows the matching child agent details and refreshes them when the agent set
216231 expect ( text ( ) ) . not . toContain ( "tok" ) ;
217232 expect ( text ( ) ) . not . toContain ( "Unlinked agent" ) ;
218233 expect ( text ( ) ) . not . toContain ( "Active agents" ) ;
219- expect ( renderer . root . findAllByProps ( { type : "button" , "aria-expanded" : true } ) ) . toHaveLength ( 0 ) ;
234+ expect ( rowGroupToggles ( renderer . root , true ) ) . toHaveLength ( 0 ) ;
220235
221236 state . projection = {
222237 ...projection ,
@@ -231,27 +246,21 @@ it("shows the matching child agent details and refreshes them when the agent set
231246 ] ,
232247 } ;
233248 await act ( async ( ) => renderer . update ( cloneElement ( panel ) ) ) ;
234- expect ( renderer . root . findByType ( "h3" ) . children ) . toEqual ( [ "Lineage" ] ) ;
249+ expect ( renderer . root . findByType ( "h3" ) . findByType ( "span" ) . children ) . toEqual ( [ "Lineage" ] ) ;
235250 expect ( text ( ) ) . toContain ( "Previous agents (1)" ) ;
236251 expect ( text ( ) ) . not . toContain ( "Checker" ) ;
237- await act ( async ( ) =>
238- renderer . root . findByProps ( { type : "button" , "aria-expanded" : false } ) . props . onClick ( ) ,
239- ) ;
252+ await act ( async ( ) => rowGroupToggle ( renderer . root , false ) . props . onClick ( ) ) ;
240253 expect ( text ( ) ) . toContain ( "Checker" ) ;
241254 // A started agent's row shows only its compact time; the icon carries the status.
242255 expect ( text ( ) ) . toContain ( "Checker 2m" ) ;
243256 expect ( text ( ) ) . not . toContain ( "(1)" ) ;
244257 expect ( text ( ) ) . not . toContain ( "Done" ) ;
245258 expect ( text ( ) ) . not . toContain ( "running" ) ;
246259 expect ( text ( ) ) . not . toContain ( "Worker" ) ;
247- await act ( async ( ) =>
248- renderer . root . findByProps ( { type : "button" , "aria-expanded" : true } ) . props . onClick ( ) ,
249- ) ;
260+ await act ( async ( ) => rowGroupToggle ( renderer . root , true ) . props . onClick ( ) ) ;
250261 expect ( text ( ) ) . not . toContain ( "Checker" ) ;
251262 expect ( text ( ) ) . toContain ( "Previous agents (1)" ) ;
252- await act ( async ( ) =>
253- renderer . root . findByProps ( { type : "button" , "aria-expanded" : false } ) . props . onClick ( ) ,
254- ) ;
263+ await act ( async ( ) => rowGroupToggle ( renderer . root , false ) . props . onClick ( ) ) ;
255264 expect ( text ( ) ) . toContain ( "Checker" ) ;
256265
257266 state . projection = {
@@ -634,9 +643,7 @@ it("shows readable models and only differing workspace details in agent tooltips
634643 ] ,
635644 } ;
636645 await act ( async ( ) => renderer . update ( cloneElement ( panel ) ) ) ;
637- await act ( async ( ) =>
638- renderer . root . findByProps ( { type : "button" , "aria-expanded" : false } ) . props . onClick ( ) ,
639- ) ;
646+ await act ( async ( ) => rowGroupToggle ( renderer . root , false ) . props . onClick ( ) ) ;
640647 expect ( text ( ) ) . toContain ( "Final checks passed." ) ;
641648 expect ( text ( ) ) . not . toContain ( "Stale progress" ) ;
642649 expect ( text ( ) ) . not . toContain ( "Hidden tail" ) ;
0 commit comments