From ecb6b0981388f858af9ab1791abab1afc8236e81 Mon Sep 17 00:00:00 2001 From: Vito Sansevero Date: Fri, 30 Oct 2026 18:32:56 -0700 Subject: [PATCH] test(viewer): wait for the viewer's first fit before reading it The keys spec read the fit as soon as Zoom enabled, a frame before the viewer fits the image to the stage. Under load it then compared 873.6px with 901.2px. Failed 3 of 3 under --cpus=2 on WebKit, on the combined head and on #534's own head; with the wait the spec passes 96 of 96. --- tests/browser/workspace-viewer-keys.spec.mjs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/browser/workspace-viewer-keys.spec.mjs b/tests/browser/workspace-viewer-keys.spec.mjs index 2d2a1a60..4816c446 100644 --- a/tests/browser/workspace-viewer-keys.spec.mjs +++ b/tests/browser/workspace-viewer-keys.spec.mjs @@ -139,6 +139,15 @@ const synth = (page, key, init = {}) => page.evaluate(([key, init]) => { }, [key, init]); async function ready(page) { await expect(control(page, 'Zoom in')).toHaveAttribute('aria-disabled', 'false'); + // Zoom opens as the image is viewed; the viewer's first fit to the stage follows a frame later. + let previous; + await expect.poll(async () => { + await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))); + const settled = await transform(page); + const same = settled === previous; + previous = settled; + return same; + }).toBe(true); await stage(page).focus(); } /** Nothing the keys can change has changed. */