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.
This commit is contained in:
Vito Sansevero
2026-10-30 18:32:56 -07:00
parent 2ebc5d9280
commit df0a798eea
@@ -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. */