Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(List): the row press holds are armed before the press (#10477)

Christopher Chedeau9eb9626869c0
diff --git a/packages/core/src/List/__tests__/ListRowPress.interaction.browser.spec.ts b/packages/core/src/List/__tests__/ListRowPress.interaction.browser.spec.ts
index 9dee0b6099..b99f219acb 100644
--- a/packages/core/src/List/__tests__/ListRowPress.interaction.browser.spec.ts
+++ b/packages/core/src/List/__tests__/ListRowPress.interaction.browser.spec.ts
@@ -747,13 +747,16 @@ test(
width: page.viewportSize()?.width ?? 402,
height: box.height + 32,
};
+ // Armed before the press, so the film starts where the release starts.
+ const hold = await armHold(page, row, {
+ judges: {target: row, property: 'opacity', pseudoElement: '::before'},
+ });
await driver.play(tap(center, {holdMs: HOLD_MS}));
await freezeTimers(page);
const {storyboard} = await animationStoryboard(page, {
name: 'list-row-press-release',
clip,
- scope: row,
- judges: {target: row, property: 'opacity', pseudoElement: '::before'},
+ held: await hold.held(),
measure: async () => ({
opacity: await layerOpacity(row),
state: await pressState(row),
diff --git a/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts b/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts
index 8bbb95567d..65bf45d52e 100644
--- a/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts
+++ b/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts
@@ -23,8 +23,8 @@ import {
type Page,
} from '@astryxdesign/a11y-spec/playwright';
import {
+ armHold,
drag,
- holdAnimations,
openStory,
releaseAnimations,
seekAnimations,
@@ -218,13 +218,17 @@ test('Reduce Motion keeps the release fade: a fade, not a movement', async ({
if (box == null) {
throw new Error('no row');
}
+ // The page holds the release itself as soon as it runs. A hold the test
+ // sends after the lift arrives later on a busy machine, and the release
+ // can end first.
+ const hold = await armHold(page, row, {
+ judges: {target: row, property: 'opacity', pseudoElement: '::before'},
+ });
await driver.play(
tap({x: box.x + box.width / 2, y: box.y + box.height / 2}, {holdMs: 300}),
);
const releaseMs = await exitMsOf(row);
- await holdAnimations(page, undefined, {
- judges: {target: row, property: 'opacity', pseudoElement: '::before'},
- });
+ await hold.held();
await seekAnimations(page, 0);
expect(await layerOpacity(row)).toBeCloseTo(1, 2);
await seekAnimations(page, releaseMs / 2);
@@ -290,6 +294,10 @@ test('under a finger, a row held and released between two divided rows keeps bot
if (box == null) {
throw new Error('no row');
}
+ // Armed before the press, so the page holds the release as it starts.
+ const hold = await armHold(page, pressed, {
+ judges: {target: pressed, property: 'opacity', pseudoElement: '::before'},
+ });
// Held: checked while the finger is still down, after the first event.
await driver.play(
tap({x: box.x + box.width / 2, y: box.y + box.height / 2}, {holdMs: 600}),
@@ -305,9 +313,7 @@ test('under a finger, a row held and released between two divided rows keeps bot
);
// Released: halfway through the release fade.
const releaseMs = await exitMsOf(pressed);
- await holdAnimations(page, undefined, {
- judges: {target: pressed, property: 'opacity', pseudoElement: '::before'},
- });
+ await hold.held();
await seekAnimations(page, releaseMs / 2);
expect(await pressState(pressed)).toBe('fading');
await expectDividersAsAtRest('releasing');