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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
Andreas Reinhold / reini
2026-09-15 06:27:59 +02:00
co-authored by Claude Opus 5
parent 13b975358f
commit 1945f8233a
+7 -3
View File
@@ -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 () { 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 // 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 // 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 = 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' $page->assertScript(onCarousel(0, <<<'JS'
await pause(50) 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) && items.every((item) => Math.abs(item.getBoundingClientRect().width - size) < 1.5)
JS)); JS));
}); });