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)); });