An open source design system that's fully customizable and agent ready
TypeScript
test(Wheel): hold the coast from its start, and catch it frozen (#10340)
Christopher Chedeau065603204bde
diff --git a/packages/core/src/DateInput/__tests__/Wheel.interaction.browser.spec.ts b/packages/core/src/DateInput/__tests__/Wheel.interaction.browser.spec.tsindex 4c88d5039c..29481254b9 100644--- a/packages/core/src/DateInput/__tests__/Wheel.interaction.browser.spec.ts+++ b/packages/core/src/DateInput/__tests__/Wheel.interaction.browser.spec.ts@@ -19,7 +19,9 @@ import {type Page,} from '@astryxdesign/a11y-spec/playwright';import {+ advanceFrozenPage,animationStoryboard,+ armHold,blockMainThread,busyWindowProof,castStoryboard,@@ -28,8 +30,10 @@ import {countBetween,curveOf,flick,+ freezePageOn,freezeTimers,holdAnimations,+ installPageFreeze,installTimerGate,markElement,openStory,@@ -40,6 +44,7 @@ import {startCompositorTrace,startScreencast,tap,+ thawPage,thawTimers,timeline,touchDriver,@@ -381,10 +386,17 @@ test('a flick coasts on UIKit’s curve onto the row it projects, and commits itconst {script, offsetAtLift} = flickUp(start);expect(releaseVelocity(script).y).toBeCloseTo(-FLICK_VELOCITY, -1);await recordFingerInputs(page);+ // The wheel ends a coast from a timer: gate the page's timers so the held+ // coast is not ended while it is sampled.+ await installTimerGate(page);const watch = await watchAnimations(strip);+ const hold = await armHold(page, strip, {+ judges: {target: strip, property: 'translate'},+ newOnly: true,+ });await driver.play(script);- const coast = stripAnimationOf(await watch.started());- const held = await holdAnimations(page, strip);+ const held = await hold.held();+ await freezeTimers(page);const motion = held.find(animation => animation.kind === 'Animation');if (motion == null) {throw new Error(`no coast held: ${JSON.stringify(held)}`);@@ -394,6 +406,8 @@ test('a flick coasts on UIKit’s curve onto the row it projects, and commits it'translateY',).map(sample => ({t: sample.t, value: -sample.value}));await releaseAnimations(page);+ await thawTimers(page);+ const coast = stripAnimationOf(await watch.started());const from = samples[0].value;const rest = samples[samples.length - 1].value;@@ -673,13 +687,29 @@ test('the coast does no Layout or Paint per frame', async ({test('a finger landing on the coasting wheel stops it where it is, then it eases onto the nearest row', async ({page,}) => {+ await installPageFreeze(page);const {driver, field, strip, start} = await openWheel(page);+ await installTimerGate(page);const before = await stripOffset(strip);const watch = await watchAnimations(strip);- await driver.play(flickUp(start).script);+ // The flick plays on the scene's clock. Frozen from its first touch, the+ // scene moves on by each step's scripted time. So the page reads the+ // script's release however loaded the runner is.+ const {script} = flickUp(start);+ const times = toTouchEvents(script).map(step => step.t);+ await freezePageOn(page, 'touchstart');+ await driver.play(script, {+ onEvent: async (_step, index) => {+ if (index + 1 < times.length) {+ await advanceFrozenPage(page, times[index + 1] - times[index]);+ }+ },+ });+ // The coast starts held at the lift. The scene moves 300 ms into it, and+ // the finger lands there.+ await advanceFrozenPage(page, 300);const coast = stripAnimationOf(await watch.started({minProgressMs: 16}));const coastEnd = -stripYOf(coast.keyframes?.at(-1));- await page.waitForTimeout(300);// Land and hold still: the wheel stops at once, between rows.const hold = tap(start, {holdMs: 300});let caught = NaN;@@ -688,6 +718,7 @@ test('a finger landing on the coasting wheel stops it where it is, then it easesawait driver.play(hold, {onEvent: async () => {if (step++ === 0) {+ await thawPage(page);await page.waitForTimeout(50);caught = await stripOffset(strip);await page.waitForTimeout(150);@@ -712,6 +743,7 @@ test('storyboard: a flick and its coast onto a row',{tag: '@storyboard'},async ({page}, testInfo) => {+ await installPageFreeze(page);const {driver, minutes, strip, start} = await openWheel(page);const box = await minutes.boundingBox();if (box == null) {@@ -728,7 +760,9 @@ test(// The wheel ends a motion from a timer; gate the page's timers so the// held coast is not finished behind the filmstrip's back.await installTimerGate(page);- const watch = await watchAnimations(strip);+ // Frozen in the lift's own task, the coast starts held at its start, and+ // the hold takes it there however long the flick's film took.+ await freezePageOn(page, 'touchend');const flickBoard = await touchStoryboard(page, driver, script, {name: 'wheel-flick',clip,@@ -736,12 +770,13 @@ test(columns: 6,cellScale: 0.5,});- await watch.started();+ const held = await holdAnimations(page, strip);+ await thawPage(page);await freezeTimers(page);const {storyboard: coastBoard} = await animationStoryboard(page, {+ held,name: 'wheel-coast',clip,- scope: strip,measure,columns: 8,cellScale: 0.5,