Skip to content

Commit 64efea9

Browse files
committed
test(web): wait for thread restoration before positioning
1 parent dcbdbc0 commit 64efea9

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎apps/web/src/components/chat/MessagesTimeline.browser.test.tsx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,11 @@ describe("MessagesTimeline minimap integration", () => {
333333
async (destination) => {
334334
const entries = history("source");
335335
const destinationEntries = destination === "empty" ? [] : history("destination", 24);
336-
const props = { ...baseProps(), liveFollowEnabled: false };
336+
const props = {
337+
...baseProps(),
338+
liveFollowEnabled: false,
339+
cancelPositionRestoreRef: createRef<(() => void) | null>(),
340+
};
337341
await using screen = await renderElement(
338342
<MessagesTimeline {...props} timelineEntries={entries} />,
339343
);
@@ -397,10 +401,12 @@ describe("MessagesTimeline minimap integration", () => {
397401
});
398402

399403
if (destinationEntries.length > 0) {
404+
// Restoration owns scrolling until its effect cleans up.
405+
await vi.waitFor(() => expect(props.cancelPositionRestoreRef.current).toBeNull());
400406
const target = destinationEntries[8]!;
401407
await vi.waitFor(() => expect(list.getState().indexByKey(target.id)).toBeDefined());
402-
await act(() => {
403-
void list.scrollToIndex({
408+
await act(async () => {
409+
await list.scrollToIndex({
404410
index: list.getState().indexByKey(target.id)!,
405411
animated: false,
406412
viewOffset: 24,

0 commit comments

Comments
 (0)