@@ -572,6 +572,7 @@ describe("ChatView scroll behavior regression coverage", () => {
572572 await hydrate ( 2 , buildMessagesWithMultipleCheckpoints ( Date . now ( ) - 3_000 ) )
573573 await waitForCalls ( 2 )
574574 await waitForCallsSettled ( )
575+ harness . atBottomAfterCalls = Number . POSITIVE_INFINITY
575576
576577 await act ( async ( ) => {
577578 fireEvent . keyDown ( window , { key : "PageUp" } )
@@ -581,26 +582,26 @@ describe("ChatView scroll behavior regression coverage", () => {
581582 timeout : 1_200 ,
582583 } )
583584
584- const checkpointButton = getScrollToCheckpointButton ( )
585+ const clickCheckpointAndWaitForScroll = async ( ) => {
586+ const scrollCallsBeforeClick = harness . scrollCalls
585587
586- await act ( async ( ) => {
587- ; ( checkpointButton as HTMLButtonElement ) . click ( )
588- } )
588+ await act ( async ( ) => {
589+ getScrollToCheckpointButton ( ) . click ( )
590+ } )
591+
592+ await waitForCalls ( scrollCallsBeforeClick + 1 )
593+ }
594+
595+ await clickCheckpointAndWaitForScroll ( )
589596 expect ( harness . scrollToIndexArgs . at ( - 1 ) ) . toMatchObject ( { index : 4 , align : "center" , behavior : "smooth" } )
590597
591- await act ( async ( ) => {
592- ; ( checkpointButton as HTMLButtonElement ) . click ( )
593- } )
598+ await clickCheckpointAndWaitForScroll ( )
594599 expect ( harness . scrollToIndexArgs . at ( - 1 ) ) . toMatchObject ( { index : 2 , align : "center" , behavior : "smooth" } )
595600
596- await act ( async ( ) => {
597- ; ( checkpointButton as HTMLButtonElement ) . click ( )
598- } )
601+ await clickCheckpointAndWaitForScroll ( )
599602 expect ( harness . scrollToIndexArgs . at ( - 1 ) ) . toMatchObject ( { index : 0 , align : "center" , behavior : "smooth" } )
600603
601- await act ( async ( ) => {
602- ; ( checkpointButton as HTMLButtonElement ) . click ( )
603- } )
604+ await clickCheckpointAndWaitForScroll ( )
604605 expect ( harness . scrollToIndexArgs . at ( - 1 ) ) . toMatchObject ( { index : 0 , align : "center" , behavior : "smooth" } )
605606 } )
606607} )
0 commit comments