From 7496624b9a0d9363ab539f82042d105aa102038b Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Thu, 29 Oct 2026 23:35:43 +1100 Subject: [PATCH] test(desktop): measure inline video controls against their player The hover test compared the controls' page y before and after hovering, so a 1px timeline shift of the whole row failed it about one run in fifteen. Measure the controls' offset from their player in one frame instead, which still fails if the controls slide in on hover. Co-authored-by: Jitter <2b2e6415e748c35180847a37aadae06a11e30dddc76b784e7fd9354c4eb42e7a@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 Signed-off-by: Matt Toohey --- desktop/tests/e2e/video-attachment.spec.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/desktop/tests/e2e/video-attachment.spec.ts b/desktop/tests/e2e/video-attachment.spec.ts index 060d356d28e..f2741733794 100644 --- a/desktop/tests/e2e/video-attachment.spec.ts +++ b/desktop/tests/e2e/video-attachment.spec.ts @@ -895,18 +895,24 @@ test("inline video hover reveals a timeline without a second play control", asyn ) .toBe("50%"); - const restingControlsBox = await controls.boundingBox(); + // The timeline can shift the whole row by a pixel while the pointer moves + // in, so measure the controls against their own player in a single frame. + const controlsOffset = () => + controls.evaluate((element) => { + const playerTop = element + .closest('[data-testid="video-player"]') + ?.getBoundingClientRect().top; + return element.getBoundingClientRect().top - (playerTop ?? Number.NaN); + }); + const restingControlsOffset = await controlsOffset(); const restingIconTransform = await centerIcon.evaluate( (element) => window.getComputedStyle(element).transform, ); - expect(restingControlsBox).not.toBeNull(); await expect(controls).toHaveCSS("opacity", "0"); await surface.hover(); await expect(controls).toHaveCSS("opacity", "1"); - const hoveredControlsBox = await controls.boundingBox(); - expect(hoveredControlsBox).not.toBeNull(); expect( - Math.abs((hoveredControlsBox?.y ?? 0) - (restingControlsBox?.y ?? 0)), + Math.abs((await controlsOffset()) - restingControlsOffset), ).toBeLessThan(0.5); await expect .poll(() =>