From 7ff58d9af9edbdfd3f1a8c508641dda12710320a Mon Sep 17 00:00:00 2001 From: Wes Date: Wed, 8 Jul 2026 08:27:20 -0600 Subject: [PATCH] test(desktop): deflake mid-scroll older-history spinner smoke test (#1632) Signed-off-by: Wes Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co> --- desktop/tests/e2e/scroll-history.spec.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/desktop/tests/e2e/scroll-history.spec.ts b/desktop/tests/e2e/scroll-history.spec.ts index 77043c849..ab99b65f0 100644 --- a/desktop/tests/e2e/scroll-history.spec.ts +++ b/desktop/tests/e2e/scroll-history.spec.ts @@ -1577,16 +1577,26 @@ test("older-history spinner stays visible in viewport while fetching mid-scroll" const timeline = page.getByTestId("message-timeline"); await expect(timeline.locator("[data-message-id]").first()).toBeVisible(); - await timeline.hover(); - await page.mouse.wheel(0, -1_500); - await page.waitForTimeout(100); - await page.mouse.wheel(0, 1_000); - await page.waitForTimeout(100); - await page.mouse.wheel(0, -1_000); + // Trigger the older fetch near the top, then move the reader mid-scroll + // while the fetch is still in flight. Set scrollTop directly instead of + // mouse.wheel: wheel deltas vary across CI environments and can land the + // timeline at scrollTop 0, which is the one position this test must avoid. + await timeline.evaluate((element) => { + const timelineElement = element as HTMLDivElement; + timelineElement.scrollTop = 150; + timelineElement.dispatchEvent(new Event("scroll", { bubbles: true })); + }); const indicator = page.getByTestId("message-timeline-fetching-older"); await expect(indicator).toBeVisible({ timeout: 2_000 }); + await timeline.evaluate((element) => { + const timelineElement = element as HTMLDivElement; + timelineElement.scrollTop = timelineElement.clientHeight; + timelineElement.dispatchEvent(new Event("scroll", { bubbles: true })); + }); + await expect(indicator).toBeVisible(); + const { scrollTop } = await getTimelineMetrics(page); expect(scrollTop).toBeGreaterThan(8);