@@ -361,28 +361,79 @@ describe("MessagesTimeline", () => {
361361 } ) ;
362362 const questionToggle = renderer ! . root . find (
363363 ( node ) =>
364- node . props [ "aria-label" ] ?. startsWith ( "Question answer submitted: " ) &&
364+ node . props [ "aria-label" ] ?. startsWith ( "Provide a spec " ) &&
365365 node . props [ "aria-expanded" ] === false ,
366366 ) ;
367367 expect ( questionToggle . props [ "aria-label" ] ) . toContain (
368368 Object . values ( answers ) [ 0 ] ?? "spec.txt" ,
369369 ) ;
370- expect ( JSON . stringify ( renderer ! . toJSON ( ) ) ) . not . toContain ( "Provide a spec" ) ;
370+ // The question leads the collapsed row so the exchange reads as a
371+ // question and answer without expanding (heading + accessible label).
372+ expect ( JSON . stringify ( renderer ! . toJSON ( ) ) . match ( / P r o v i d e a s p e c / g) ) . toHaveLength ( 2 ) ;
371373 await act ( ( ) => questionToggle . props . onClick ( ) ) ;
372374 const markup = JSON . stringify ( renderer ! . toJSON ( ) ) ;
373- expect ( markup . match ( / P r o v i d e a s p e c / g) ) . toHaveLength ( 1 ) ;
375+ // Expanded, the question also appears in the history: label, heading, history.
376+ expect ( markup . match ( / P r o v i d e a s p e c / g) ) . toHaveLength ( 3 ) ;
374377 expect ( markup ) . toContain ( "spec.txt" ) ;
375378 expect ( markup ) . toContain ( "Provide a screenshot" ) ;
376379 expect ( markup ) . toContain ( "shot.png" ) ;
377380 for ( const answer of Object . values ( answers ) ) expect ( markup ) . toContain ( answer ) ;
378381 await act ( ( ) => questionToggle . props . onClick ( ) ) ;
379- expect ( JSON . stringify ( renderer ! . toJSON ( ) ) ) . not . toContain ( "Provide a spec" ) ;
382+ // Collapsing hides the history but keeps the question heading.
383+ expect ( JSON . stringify ( renderer ! . toJSON ( ) ) ) . toContain ( "Provide a spec" ) ;
380384 } finally {
381385 await act ( ( ) => renderer ?. unmount ( ) ) ;
382386 }
383387 } ,
384388 ) ;
385389
390+ it ( "leads an unanswered question row with the question text" , async ( ) => {
391+ vi . stubGlobal ( "IS_REACT_ACT_ENVIRONMENT" , true ) ;
392+ vi . stubGlobal ( "requestAnimationFrame" , ( ) => 0 ) ;
393+ vi . stubGlobal ( "cancelAnimationFrame" , ( ) => { } ) ;
394+ let renderer : ReactTestRenderer | undefined ;
395+ try {
396+ await act ( ( ) => {
397+ renderer = create (
398+ < MessagesTimeline
399+ { ...buildProps ( ) }
400+ timelineEntries = { [
401+ {
402+ id : "question-entry" ,
403+ kind : "work" ,
404+ createdAt : MESSAGE_CREATED_AT ,
405+ entry : {
406+ id : "question-work" ,
407+ createdAt : MESSAGE_CREATED_AT ,
408+ label : "User input requested" ,
409+ tone : "tool" ,
410+ questionAnswer : {
411+ requestId : ApprovalRequestId . make ( "question-request" ) ,
412+ answers : { } ,
413+ questionTextById : { scope : "Which repository?" } ,
414+ attachmentsByQuestionId : { } ,
415+ } ,
416+ } ,
417+ } ,
418+ ] }
419+ /> ,
420+ ) ;
421+ } ) ;
422+ const questionToggle = renderer ! . root . find (
423+ ( node ) =>
424+ node . props [ "aria-label" ] === "Which repository?" && node . props [ "aria-expanded" ] === false ,
425+ ) ;
426+ const markup = JSON . stringify ( renderer ! . toJSON ( ) ) ;
427+ // Heading + accessible label.
428+ expect ( markup . match ( / W h i c h r e p o s i t o r y \? / g) ) . toHaveLength ( 2 ) ;
429+ await act ( ( ) => questionToggle . props . onClick ( ) ) ;
430+ // Expanded history adds a third occurrence alongside heading and label.
431+ expect ( JSON . stringify ( renderer ! . toJSON ( ) ) . match ( / W h i c h r e p o s i t o r y \? / g) ) . toHaveLength ( 3 ) ;
432+ } finally {
433+ await act ( ( ) => renderer ?. unmount ( ) ) ;
434+ }
435+ } ) ;
436+
386437 it . each ( [
387438 { toolLifecycleStatus : "inProgress" , isAtEnd : true } ,
388439 { toolLifecycleStatus : "inProgress" , isAtEnd : false } ,
0 commit comments