From 344b53b2981c5a47db9a93a0d577948f8d375e42 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 4 Nov 2026 03:48:54 -0800 Subject: [PATCH] test(DateInput): the wheel activation proof waits on the sheet's own end, not on still frames before a deadline `openMonthYearWheels` waited for the sheet, and then for the year wheel, with the harness's `waitForRest`: three still frames within 5 s. A starved runner can present no frame for longer than that while nothing moves, so the wait ran out ("still moving") and the proof failed. The proof now checks the sheet's open transform, and then the wheels' full opacity, once a frame with no deadline of its own, and waits on each animation's `finished` promise. A starved runner only makes it later. The opening's writes are still counted from the tap until the wheels rest. --- ...heelActivation.interaction.browser.spec.ts | 60 +++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/packages/core/src/DateInput/__tests__/WheelActivation.interaction.browser.spec.ts b/packages/core/src/DateInput/__tests__/WheelActivation.interaction.browser.spec.ts index 4a7b66656e0ec..9ae235575a8b2 100644 --- a/packages/core/src/DateInput/__tests__/WheelActivation.interaction.browser.spec.ts +++ b/packages/core/src/DateInput/__tests__/WheelActivation.interaction.browser.spec.ts @@ -15,17 +15,58 @@ * a frame clock, never that count. */ -import {expect, test, type Page} from '@astryxdesign/a11y-spec/playwright'; +import { + expect, + test, + type Locator, + type Page, +} from '@astryxdesign/a11y-spec/playwright'; import { openStory, touchDriver, - waitForRest, withStorybook, } from '@astryxdesign/interaction-harness'; import {WHEEL_ROW_HEIGHT} from '../wheelOptions'; const storybook = withStorybook(test); +/** + * Resolves once `locator`'s element shows `property` at `value` and no + * animation inside it is left unfinished. The page checks the value once a + * frame, then awaits each animation's own `finished` promise. It sets no + * deadline of its own, so a starved runner only makes it later. + */ +async function settlesAt(locator: Locator, property: string, value: string) { + await locator.evaluate( + async (element, [name, expected]) => { + await new Promise(resolve => { + const check = () => { + if (getComputedStyle(element).getPropertyValue(name) === expected) { + resolve(); + } else { + requestAnimationFrame(check); + } + }; + check(); + }); + for (;;) { + const unfinished = element + .getAnimations({subtree: true}) + .filter(animation => animation.playState !== 'finished'); + if (unfinished.length === 0) { + return; + } + await Promise.all( + unfinished.map(async animation => + animation.finished.catch(() => undefined), + ), + ); + } + }, + [property, value] as const, + ); +} + interface Activation { /** Year options listed, and the year rows drawn (each option is one). */ yearOptions: number; @@ -56,7 +97,12 @@ async function openMonthYearWheels( }); const title = page.locator('[data-title="month-year"]'); await expect(title).toBeVisible(); - await waitForRest(page.locator('.astryx-bottom-sheet').first()); + // The sheet rises to its open position, where its transform is the identity. + await settlesAt( + page.locator('.astryx-bottom-sheet').first(), + 'transform', + 'matrix(1, 0, 0, 1, 0, 0)', + ); const titleBox = await title.boundingBox(); if (titleBox == null) { throw new Error('no month and year title'); @@ -97,7 +143,13 @@ async function openMonthYearWheels( }); const years = page.getByRole('listbox', {name: 'Year'}); await expect(years).toBeVisible(); - await waitForRest(years.locator('[data-wheel-strip]')); + // The wheels fade in over the calendar. The year wheel parks its strip on + // its year as they show, so it rests once they do. + await settlesAt( + page.locator('[data-panel="wheels"]').first(), + 'opacity', + '1', + ); // The committed year is drawn where the wheel shows it. await expect(years.getByRole('option', {selected: true})).toBeVisible(); return {