test(app): make chat outline transit timing deterministic

This commit is contained in:
Mohamed Boudra
2026-08-06 00:13:17 +02:00
parent 254e72ad50
commit 212cd00405
@@ -77,6 +77,9 @@ export async function expectNoChatOutlinePreview(page: Page): Promise<void> {
export async function expectNoChatOutlinePreviewWhileCrossingToSidebar(page: Page): Promise<void> {
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<void>((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