Skip to content

Commit c3309ca

Browse files
test(web): wait for painted timeline before measuring work heading (#58)
Wait for LegendList to finish its hidden initial layout before recording the heading position. Keep real timers running through the click and expansion so the virtualizer can complete its layout work. Co-authored-by: GPT-6 Astra <noreply@openai.com>
1 parent 21fc2b0 commit c3309ca

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,15 @@ describe("MessagesTimeline work rows", () => {
238238
const heading = screen.getByRole("button", { name: /^Worked for/ });
239239
await expect.element(heading).toBeVisible();
240240
const viewport = props.listRef.current!.getScrollableNode()!;
241-
await vi.waitFor(() =>
242-
expect(viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop).toBeLessThan(2),
243-
);
241+
await vi.waitFor(() => {
242+
// LegendList hides its initial layout with opacity, which toBeVisible does not check.
243+
expect(heading.element().checkVisibility({ checkOpacity: true })).toBe(true);
244+
expect(viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop).toBeLessThan(2);
245+
});
244246
expect(viewport.scrollTop).toBeGreaterThan(0);
245247
const top = heading.element().getBoundingClientRect().top;
246248
const height = viewport.scrollHeight;
247-
using _timers = fakeTimers();
248249
await heading.click();
249-
await act(() => vi.advanceTimersByTime(1000));
250250
await vi.waitFor(() => {
251251
expect(viewport.scrollHeight).toBeGreaterThan(height + 500);
252252
expect(heading.element().getBoundingClientRect().top).toBeCloseTo(top, 0);

0 commit comments

Comments
 (0)