@@ -93,6 +93,7 @@ const legendListTestState = vi.hoisted(() => ({
9393} ) ) ;
9494
9595vi . mock ( "@legendapp/list/react" , async ( ) => {
96+ const { useLayoutEffect } = await import ( "react" ) ;
9697 const legendListTestId = "legend-list" ;
9798
9899 const LegendList = ( props : {
@@ -130,8 +131,10 @@ vi.mock("@legendapp/list/react", async () => {
130131 onScroll ?: ( ) => void ;
131132 ref ?: Ref < LegendListRef > ;
132133 } ) => {
133- legendListTestState . data = props . data ;
134- legendListTestState . onScroll = props . onScroll ;
134+ useLayoutEffect ( ( ) => {
135+ legendListTestState . data = props . data ;
136+ legendListTestState . onScroll = props . onScroll ;
137+ } ) ;
135138 if ( props . anchoredEndSpace ) {
136139 props . anchoredEndSpace . onSizeChanged ?.( 240 ) ;
137140 props . anchoredEndSpace . onReady ?.( { anchorIndex : props . anchoredEndSpace . anchorIndex } ) ;
@@ -227,9 +230,8 @@ function matchMedia() {
227230}
228231
229232let MessagesTimeline : typeof import ( "./MessagesTimeline" ) . MessagesTimeline ;
230- let resolvePreviewAnnotationImage : typeof import ( "./MessagesTimeline" ) . resolvePreviewAnnotationImage ;
231233
232- const ElementStub = class ElementStub { } ;
234+ const ElementStub = function ElementStub ( ) { } ;
233235function stubDomGlobals ( ) {
234236 const classList = {
235237 add : ( ) => { } ,
@@ -271,7 +273,7 @@ beforeEach(stubDomGlobals);
271273// Cold transformation of the full chat dependency graph needs extra time on slower CI workers.
272274beforeAll ( async ( ) => {
273275 Object . defineProperty ( window , "matchMedia" , { value : matchMedia , configurable : true } ) ;
274- ( { MessagesTimeline, resolvePreviewAnnotationImage } = await import ( "./MessagesTimeline" ) ) ;
276+ ( { MessagesTimeline } = await import ( "./MessagesTimeline" ) ) ;
275277} , 120_000 ) ;
276278
277279const ACTIVE_THREAD_ENVIRONMENT_ID = EnvironmentId . make ( "environment-local" ) ;
@@ -790,16 +792,14 @@ describe("MessagesTimeline", () => {
790792 const { readTimelinePosition } = await import ( "./timelineScrollAnchoring" ) ;
791793 const timeline = stubFollowTimeline ( "environment-local:manual-departure" ) ;
792794 const { props } = timeline ;
793- let navigateManually = ( ) => { } ;
794795 function ChatProbe ( ) {
795796 const [ liveFollowEnabled , setLiveFollowEnabled ] = useState ( true ) ;
796- navigateManually = ( ) => setLiveFollowEnabled ( false ) ;
797797 return (
798798 < MessagesTimeline
799799 { ...props }
800800 timelineEntries = { [ buildUserTimelineEntry ( "First prompt" ) ] }
801801 liveFollowEnabled = { liveFollowEnabled }
802- onManualNavigation = { navigateManually }
802+ onManualNavigation = { ( ) => setLiveFollowEnabled ( false ) }
803803 />
804804 ) ;
805805 }
@@ -813,7 +813,7 @@ describe("MessagesTimeline", () => {
813813
814814 timeline . scrollTop = 1300 ;
815815 await act ( ( ) => {
816- navigateManually ( ) ;
816+ renderer ?. root . findByType ( MessagesTimeline ) . props . onManualNavigation ?. ( ) ;
817817 legendListTestState . onScroll ?.( ) ;
818818 } ) ;
819819 await act ( ( ) => renderer ?. unmount ( ) ) ;
@@ -2233,7 +2233,7 @@ describe("MessagesTimeline", () => {
22332233 activityTestState . expandedRuns = true ;
22342234 activityTestState . subagentTooltips = true ;
22352235 vi . stubGlobal ( "HTMLElement" , ElementStub ) ;
2236- window . HTMLElement = ElementStub as typeof HTMLElement ;
2236+ window . HTMLElement = ElementStub as unknown as typeof HTMLElement ;
22372237 vi . stubGlobal ( "IS_REACT_ACT_ENVIRONMENT" , true ) ;
22382238 vi . stubGlobal ( "requestAnimationFrame" , ( ) => 0 ) ;
22392239 vi . stubGlobal ( "cancelAnimationFrame" , ( ) => { } ) ;
0 commit comments