From 212cd004054cca1df099ad7d8a185c38f77700ed Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Thu, 6 Aug 2026 00:13:17 +0200 Subject: [PATCH] test(app): make chat outline transit timing deterministic --- .../app/e2e/support/helpers/chat-outline.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/app/e2e/support/helpers/chat-outline.ts b/packages/app/e2e/support/helpers/chat-outline.ts index 7f903a79a..e3f488f19 100644 --- a/packages/app/e2e/support/helpers/chat-outline.ts +++ b/packages/app/e2e/support/helpers/chat-outline.ts @@ -77,6 +77,9 @@ export async function expectNoChatOutlinePreview(page: Page): Promise { export async function expectNoChatOutlinePreviewWhileCrossingToSidebar(page: Page): Promise { const railBox = await requireBoundingBox(chatOutlineRail(page)); + const clockStart = Date.now(); + await page.clock.install({ time: clockStart }); + await page.clock.pauseAt(clockStart + 60_000); await page.mouse.move(railBox.x + railBox.width + 2, railBox.y + railBox.height / 2); await page.evaluate(() => { document.body.dataset.chatOutlinePreviewObserved = String( @@ -91,19 +94,19 @@ export async function expectNoChatOutlinePreviewWhileCrossingToSidebar(page: Pag Object.assign(window, { __chatOutlinePreviewObserver: observer }); }); - for (let step = 0; step <= 10; step += 1) { + // Keep the transit slower than the activation delay at every point while making the whole + // crossing longer than it. Horizontal motion must keep postponing activation until leave + // cancels the final pending timer. + const transitSteps = 6; + for (let step = 0; step < transitSteps; step += 1) { await page.mouse.move( - railBox.x + railBox.width - 1 - (step * railBox.width) / 10, + railBox.x + railBox.width - 1 - (step * railBox.width) / transitSteps, railBox.y + railBox.height / 2, ); - await page.evaluate( - () => - new Promise((resolve) => { - requestAnimationFrame(() => requestAnimationFrame(() => resolve())); - }), - ); + await page.clock.runFor(100); } await page.mouse.move(railBox.x - 2, railBox.y + railBox.height / 2); + await page.clock.runFor(200); const previewAppeared = await page.evaluate(() => { const observer = Reflect.get(window, "__chatOutlinePreviewObserver") as