From 1945f8233a300c8bd61fdd6108a6f5380d7f4d58 Mon Sep 17 00:00:00 2001 From: Andreas Reinhold / reini Date: Tue, 15 Sep 2026 06:27:59 +0200 Subject: [PATCH] Prove again that the carousel scrolls instantly under reduced motion Plan step 38 review: de-flaking the reduced-motion test moved the click out of the retried assertScript, which was right, but also dropped the arrival read in the click's own task, so a smooth scroll finishing within assertScript's retries would now pass a test named "scrolls instantly". The click script records at(1) at once and the assertion requires it. It is read against the slot size measured before the click: the row re-measures a frame later (222 against 217.7px at 1280px), which is why a later read in the same evaluation fails. Chromium: CarouselTest 10 of 10, the test itself three runs green. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9 --- tests/Browser/CarouselTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Browser/CarouselTest.php b/tests/Browser/CarouselTest.php index d6e0fe01..500618a3 100644 --- a/tests/Browser/CarouselTest.php +++ b/tests/Browser/CarouselTest.php @@ -170,14 +170,18 @@ it('brings a partly hidden item into focus when it is pressed, and leaves an ope it('scrolls instantly and leaves every item unmasked under reduced motion', function () { // A click, then a separate read-only assertScript: assertScript retries its whole expression // on a false result (this file's own comment above), and a click inside it would fire again on - // every retry, drifting the carousel one further item each time and never recovering. + // every retry, drifting the carousel one further item each time and never recovering. Whether + // the row had arrived is read in the same task as the click, against the slot size measured + // before it, and kept, so a retry cannot turn a smooth scroll that finishes later into a pass: + // under reduced motion it must be instant. (The row re-measures its slot a frame later, so the + // assertion below reads a fresh size rather than this one.) $page = carouselShowcase(['reducedMotion' => 'reduce']); - $page->script(onCarousel(0, 'root.querySelector(\'[aria-label="Next"]\').click()')); + $page->script(onCarousel(0, 'root.querySelector(\'[aria-label="Next"]\').click(); window.__arrivedAtOnce = at(1)')); $page->assertScript(onCarousel(0, <<<'JS' await pause(50) - return at(1) && items.every((_, i) => inset(i) === 0) + return window.__arrivedAtOnce === true && at(1) && items.every((_, i) => inset(i) === 0) && items.every((item) => Math.abs(item.getBoundingClientRect().width - size) < 1.5) JS)); });