Skip to content

Commit 2395a87

Browse files
committed
Improve footer e2e scroll detection reliability
Replace single instantaneous scrolls with incremental scrollBy loops and short waits to avoid missing scroll events (SSR hydration race on slow CI runners). Increase visibility timeouts to 5000ms and reuse the existing footer locator (remove redundant footerAgain). These changes make the test more robust when detecting scroll-direction-driven footer show/hide behavior.
1 parent ea69f86 commit 2395a87

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

e2e/footer-variants.spec.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@ test.describe("Footer variants", () => {
88
const footer = page.locator("footer").first();
99
await expect(footer).toBeVisible();
1010

11-
// Scroll down in steps to reliably trigger the scroll-direction detection
12-
await page.evaluate(() => window.scrollTo({ top: document.body.scrollHeight, behavior: "instant" }));
13-
await page.waitForTimeout(800);
14-
await expect(footer).not.toBeVisible({ timeout: 3000 });
11+
// Scroll down incrementally to reliably trigger scroll-direction detection.
12+
// A single scrollTo can be missed if useScrollDirection's useEffect hasn't
13+
// registered the scroll listener yet (SSR hydration race on slow CI runners).
14+
for (let i = 0; i < 5; i++) {
15+
await page.evaluate(() => window.scrollBy(0, 400));
16+
await page.waitForTimeout(200);
17+
}
18+
await expect(footer).not.toBeVisible({ timeout: 5000 });
1519

16-
// Scroll up — footer should reappear
17-
await page.evaluate(() => window.scrollTo({ top: 0, behavior: "instant" }));
18-
await page.waitForTimeout(800);
19-
20-
const footerAgain = page.locator("footer").first();
21-
await expect(footerAgain).toBeVisible({ timeout: 3000 });
20+
// Scroll up incrementally — footer should reappear
21+
for (let i = 0; i < 5; i++) {
22+
await page.evaluate(() => window.scrollBy(0, -400));
23+
await page.waitForTimeout(200);
24+
}
25+
await expect(footer).toBeVisible({ timeout: 5000 });
2226
});
2327

2428
test("tab navigation clicks change active state", async ({ page }) => {

0 commit comments

Comments
 (0)