From 4125d08fb47ddb57707e01837b9764b4ac7d04f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 2 Oct 2026 22:33:17 +0200 Subject: [PATCH] test(e2e): wait for the lab review sheet to stop sliding before measuring On a phone and a small tablet the review sheet slides up from the bottom; its width settles before the slide ends, so waiting on width alone still compared fields from different frames. The spec now waits for every running animation to finish and for the surface to hold its position and width across two frames. --- e2e/dialog-horizontal-overflow.spec.ts | 28 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/e2e/dialog-horizontal-overflow.spec.ts b/e2e/dialog-horizontal-overflow.spec.ts index 3dbbbde62..07b198b23 100644 --- a/e2e/dialog-horizontal-overflow.spec.ts +++ b/e2e/dialog-horizontal-overflow.spec.ts @@ -428,14 +428,23 @@ test.describe("lab-scan review dialog uses the width it is given", () => { await expect(rows).toHaveCount(REVIEW_ROWS.length); const label = `scan review @${vp.label}`; - // The sheet widens from the picking stage to the review stage and the - // row grid re-flows from the container width it is given. Measuring in - // the middle of that sees a half-laid-out row, so wait until the - // surface has kept the same width across two frames. + // The sheet widens from the picking stage to the review stage, and on a + // phone or small tablet it also slides up from the bottom. Measuring + // while either runs compares fields from different frames (the width + // settles before the slide ends, so waiting on width alone was not + // enough). Wait for every running animation and transition to finish, + // then for the surface to hold still across two frames. + await page.evaluate(() => + Promise.all( + document + .getAnimations() + .map((animation) => animation.finished.catch(() => undefined)), + ), + ); await expect .poll( async () => { - const before = (await surface.boundingBox())!.width; + const before = (await surface.boundingBox())!; await page.evaluate( () => new Promise((resolve) => @@ -444,10 +453,13 @@ test.describe("lab-scan review dialog uses the width it is given", () => { ), ), ); - const after = (await surface.boundingBox())!.width; - return Math.abs(after - before); + const after = (await surface.boundingBox())!; + return ( + Math.abs(after.width - before.width) + + Math.abs(after.y - before.y) + ); }, - { message: `${label}: dialog width settles` }, + { message: `${label}: dialog settles` }, ) .toBeLessThan(0.5); await expectNoSidewaysScroll(page, label);