Skip to content

Commit affcccc

Browse files
Copilothasparus
andcommitted
Replace scrollIntoViewIfNeeded with manual scroll and networkidle wait
Co-authored-by: hasparus <15332326+hasparus@users.noreply.github.com>
1 parent c1ce9ba commit affcccc

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

test/e2e/community-events.spec.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ test("map tooltip appears on marker hover", async ({ page }) => {
141141
test("event type filters hide cards and lock the last active tag", async ({
142142
page,
143143
}) => {
144-
await page.goto("/community/events")
144+
await page.goto("/community/events", { waitUntil: "networkidle" })
145+
await page.waitForLoadState("domcontentloaded")
146+
145147
const pastEventsSection = page
146148
.locator("section")
147149
.filter({
@@ -152,9 +154,9 @@ test("event type filters hide cards and lock the last active tag", async ({
152154
})
153155
.first()
154156

155-
await pastEventsSection.waitFor({ state: "visible" })
156-
await pastEventsSection.scrollIntoViewIfNeeded({ timeout: 10000 })
157-
await page.waitForTimeout(300) // Brief stabilization to prevent DOM detachment
157+
await pastEventsSection.waitFor({ state: "visible", timeout: 15000 })
158+
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight))
159+
await page.waitForTimeout(500)
158160

159161
const filterGroup = pastEventsSection.locator("fieldset")
160162

@@ -218,7 +220,9 @@ test("event type filters hide cards and lock the last active tag", async ({
218220
test("upcoming and past sections only show events on the correct side of now", async ({
219221
page,
220222
}) => {
221-
await page.goto("/community/events")
223+
await page.goto("/community/events", { waitUntil: "networkidle" })
224+
await page.waitForLoadState("domcontentloaded")
225+
222226
const upcomingSection = page
223227
.locator("section")
224228
.filter({
@@ -235,10 +239,13 @@ test("upcoming and past sections only show events on the correct side of now", a
235239
})
236240
.first()
237241

238-
// Scroll sections sequentially to avoid DOM detachment issues on CI
239-
await upcomingSection.scrollIntoViewIfNeeded({ timeout: 10000 })
240-
await page.waitForTimeout(200)
241-
await pastEventsSection.scrollIntoViewIfNeeded({ timeout: 10000 })
242+
// Wait for both sections to be present before scrolling
243+
await upcomingSection.waitFor({ state: "attached", timeout: 15000 })
244+
await pastEventsSection.waitFor({ state: "attached", timeout: 15000 })
245+
246+
// Scroll to bottom to ensure everything is loaded
247+
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight))
248+
await page.waitForTimeout(500)
242249

243250
const now = Date.now()
244251

0 commit comments

Comments
 (0)