Skip to content

Commit d87f06b

Browse files
committed
test: fix combined-reveal e2e scroll detection race condition
- Use incremental scroll loops with delays instead of a single scrollTo. - This ensures the scroll-direction hook captures the event in slower CI environments.
1 parent 3ec5c5c commit d87f06b

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

e2e/combined-reveal.spec.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,26 @@ test.describe("Combined reveal behaviors", () => {
1010
await expect(header).toBeVisible();
1111
await expect(footer).toBeVisible();
1212

13-
// Scroll down - Footer should hide, Header row sub-parts (reveal-all) should hide from main header
14-
await page.evaluate(() => {
15-
window.scrollTo(0, 1000);
16-
});
17-
await page.waitForTimeout(500);
13+
// Scroll down incrementally to reliably trigger scroll-direction detection.
14+
for (let i = 0; i < 5; i++) {
15+
await page.evaluate(() => window.scrollBy(0, 400));
16+
await page.waitForTimeout(200);
17+
}
1818

19-
// Footer should be hidden (translated out of view or opacity 0 depending on implementation)
20-
// Actually our Footer uses AnimatePresence, so it might be removed or hidden.
21-
await expect(footer).not.toBeVisible();
19+
// Footer should be removed by AnimatePresence
20+
await expect(footer).not.toBeVisible({ timeout: 5000 });
2221

23-
// Scroll up - both should reveal
24-
await page.evaluate(() => {
25-
window.scrollBy(0, -200);
26-
});
27-
await page.waitForTimeout(500);
22+
// Scroll up incrementally
23+
for (let i = 0; i < 5; i++) {
24+
await page.evaluate(() => window.scrollBy(0, -400));
25+
await page.waitForTimeout(200);
26+
}
2827

2928
// Header overlay should be visible
3029
const headerOverlay = page.locator("[aria-hidden]").first();
31-
await expect(headerOverlay).toBeVisible();
30+
await expect(headerOverlay).toBeVisible({ timeout: 5000 });
3231

3332
// Footer should be visible again
34-
await expect(footer).toBeVisible();
33+
await expect(footer).toBeVisible({ timeout: 5000 });
3534
});
3635
});

0 commit comments

Comments
 (0)