@@ -392,7 +392,7 @@ describe("MessagesTimeline messages", () => {
392392 expect ( ( globalThis as { __t3Xss ?: number } ) . __t3Xss ) . toBeUndefined ( ) ;
393393 } ) ;
394394
395- it . each ( [ "inline" , "delayed" ] ) ( "handles %s output expanded above the composer " , async ( mode ) => {
395+ it . each ( [ "inline" , "delayed" , "grouped-delayed" ] ) ( "reveals %s output" , async ( mode ) => {
396396 setup ( ) ;
397397 environmentQuery . data = null ;
398398 environmentQuery . error = null ;
@@ -446,14 +446,61 @@ describe("MessagesTimeline messages", () => {
446446 } ) ,
447447 } ,
448448 } ,
449+ ...( mode === "grouped-delayed"
450+ ? [
451+ {
452+ id : "another-tool" ,
453+ kind : "work" as const ,
454+ createdAt : CREATED_AT ,
455+ entry : {
456+ id : "another-tool" ,
457+ createdAt : CREATED_AT ,
458+ label : "Other tool" ,
459+ tone : "tool" as const ,
460+ itemType : "dynamic_tool" as const ,
461+ toolLifecycleStatus : "completed" as const ,
462+ toolData : { input : { query : "other" } } ,
463+ } ,
464+ } ,
465+ ]
466+ : [ ] ) ,
449467 ...tallEntries . slice ( 6 ) ,
450468 ] }
451469 />
452470 ) ;
453471 await using screen = await renderElement ( timeline ( ) ) ;
454472 await vi . waitFor ( ( ) => expect ( props . listRef . current ?. getScrollableNode ( ) ) . toBeTruthy ( ) ) ;
455473 const viewport = props . listRef . current ! . getScrollableNode ( ) ! ;
474+ if ( mode === "grouped-delayed" ) {
475+ await act ( ( ) => {
476+ void props . listRef . current ! . scrollToIndex ( { index : 6 , animated : false } ) ;
477+ } ) ;
478+ await vi . waitFor ( ( ) =>
479+ expect (
480+ screen . container . querySelector ( '[data-timeline-row-kind="work-toggle"] button' ) ,
481+ ) . not . toBeNull ( ) ,
482+ ) ;
483+ const group = ( ) =>
484+ screen . container . querySelector < HTMLElement > (
485+ '[data-timeline-row-kind="work-toggle"] button' ,
486+ ) ! ;
487+ await click ( group ( ) ) ;
488+ await vi . waitFor ( ( ) =>
489+ expect (
490+ screen . container . querySelector ( '[data-work-entry-id="tool-near-composer"]' ) ,
491+ ) . not . toBeNull ( ) ,
492+ ) ;
493+ await click (
494+ screen . container . querySelector < HTMLElement > ( '[data-work-entry-id="tool-near-composer"]' ) ! ,
495+ ) ;
496+ await vi . waitFor ( ( ) => expect ( screen . text ( ) ) . toContain ( "Loading output" ) ) ;
497+ await click ( group ( ) ) ;
498+ }
456499 const header = ( ) => {
500+ if ( mode === "grouped-delayed" )
501+ return screen . container . querySelector < HTMLElement > (
502+ '[data-timeline-row-kind="work-toggle"] button' ,
503+ ) ! ;
457504 const rows = screen . container . querySelectorAll < HTMLElement > (
458505 '[data-timeline-row-kind="work"] [role="button"]' ,
459506 ) ;
@@ -475,7 +522,11 @@ describe("MessagesTimeline messages", () => {
475522 ) ;
476523 } ) ;
477524
525+ const collapsedScrollTop = viewport . scrollTop ;
478526 await click ( header ( ) ) ;
527+ if ( mode === "grouped-delayed" ) {
528+ await vi . waitFor ( ( ) => expect ( viewport . scrollTop ) . toBeGreaterThan ( collapsedScrollTop ) ) ;
529+ }
479530 if ( mode !== "inline" ) {
480531 await vi . waitFor ( ( ) =>
481532 expect ( header ( ) . getBoundingClientRect ( ) . bottom ) . toBeLessThanOrEqual ( visibleBottom ( ) + 1 ) ,
0 commit comments