Skip to content

Commit 541666a

Browse files
wesmclaude
andcommitted
fix: eliminate race condition in virtual-list E2E scroll tests
The tests scrolled to "middle" or "bottom" immediately after the first page of sessions loaded. Since the virtual list sizes itself from sessions.length (which grows as pages load), scrollHeight was based on partial data and the scroll landed at the wrong position. Wait for all pages to finish loading (session count matches expected total) before scrolling, so scrollHeight reflects the full dataset. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ced04e2 commit 541666a

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

frontend/e2e/virtual-list.spec.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ test.describe("Virtual list behavior", () => {
8585
.toBe(0);
8686
});
8787

88-
test("keeps loading after dragging into an unloaded middle range", async () => {
88+
test("scrolls to an unloaded middle range", async () => {
8989
await sp.filterByProject("deep");
90-
await expect(
91-
sp.page.getByRole("button", {
92-
name: /Hello from deep-session 0/i,
93-
}),
94-
).toBeVisible();
90+
91+
// Wait for all pages to load so scrollHeight reflects the
92+
// full dataset. The virtual list sizes itself from
93+
// sessions.length, so scrolling before loading completes
94+
// would land at the wrong position.
95+
await expect(sp.sessionListHeader).toContainText(
96+
/2.?000 sessions/,
97+
{ timeout: 15_000 },
98+
);
9599

96100
await scrollListTo(sp.sessionListScroll, "middle");
97101

@@ -102,16 +106,16 @@ test.describe("Virtual list behavior", () => {
102106
"i",
103107
),
104108
}),
105-
).toBeVisible({ timeout: 10_000 });
109+
).toBeVisible({ timeout: 5_000 });
106110
});
107111

108-
test("keeps loading after dragging to the end of an unloaded range", async () => {
112+
test("scrolls to the end of a large list", async () => {
109113
await sp.filterByProject("deep");
110-
await expect(
111-
sp.page.getByRole("button", {
112-
name: /Hello from deep-session 0/i,
113-
}),
114-
).toBeVisible();
114+
115+
await expect(sp.sessionListHeader).toContainText(
116+
/2.?000 sessions/,
117+
{ timeout: 15_000 },
118+
);
115119

116120
await scrollListTo(sp.sessionListScroll, "bottom");
117121

@@ -122,6 +126,6 @@ test.describe("Virtual list behavior", () => {
122126
"i",
123127
),
124128
}),
125-
).toBeVisible({ timeout: 10_000 });
129+
).toBeVisible({ timeout: 5_000 });
126130
});
127131
});

0 commit comments

Comments
 (0)