From 1d671deab842fb379a45ac1f1070e68104dc3534 Mon Sep 17 00:00:00 2001 From: Wes Date: Wed, 8 Jul 2026 08:10:10 -0600 Subject: [PATCH] test(desktop): deflake mid-scroll older-history spinner smoke test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "older-history spinner stays visible in viewport while fetching mid-scroll" smoke test drove the timeline with three mouse.wheel gestures and fixed 100ms sleeps, then asserted scrollTop > 8. Wheel delta handling varies across CI runners, so the final net position sometimes landed at scrollTop 0 — failing the assertion on all retries and intermittently breaking main (e.g. runs 28915175821, 28891719863) with no related code change. Replace the wheel choreography with direct scrollTop writes: park at 150 to trigger the older fetch, wait for the spinner, then jump one viewport down while the fetch is still in flight. Deterministic mid-scroll position, same assertion targets (spinner visible + pinned within the viewport away from the top). Verified locally: 10/10 repeats pass; full scroll-history smoke suite passes. Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co> Signed-off-by: Wes --- 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 77043c8496..ab99b65f03 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);