Skip to content

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

TypeScript

test(Popover): the entrance proof arms its hold before the tap (#10504)

Christopher Chedeau0d433063c47a
diff --git a/packages/core/src/Popover/__tests__/PopoverTouchMotion.interaction.browser.spec.ts b/packages/core/src/Popover/__tests__/PopoverTouchMotion.interaction.browser.spec.ts
index 12ba5fd04b..662f5eac9a 100644
--- a/packages/core/src/Popover/__tests__/PopoverTouchMotion.interaction.browser.spec.ts
+++ b/packages/core/src/Popover/__tests__/PopoverTouchMotion.interaction.browser.spec.ts
@@ -35,7 +35,6 @@ import {
countBetween,
drag,
freezeTimers,
- holdAnimations,
installLongTaskLog,
installTimerGate,
markElement,
@@ -213,17 +212,6 @@ function expectedBox(final: Box, trigger: Box, p: number): Box {
};
}
-/** The layer's own scale animation among those running in it. */
-async function scaleAnimationOf(locator: Locator) {
- for (;;) {
- const found = await waitForAnimation(locator);
- const scale = found.find(a => a.keyframes.some(k => 'scale' in k));
- if (scale != null) {
- return scale;
- }
- }
-}
-
/** A scale animation's `animate()` call and its own start, epoch ms. */
interface ScaleStart {
call: number;
@@ -458,11 +446,7 @@ test('the presentation grows out of the trigger on the theme\u2019s entrance tok
await expect(story.trigger).toHaveAttribute('aria-expanded', 'false');
// Presenting during the dismissal would turn back from the closing frame.
await expect(exitCopyOf(page)).toHaveCount(0);
- await openWithTap(story);
- await scaleAnimationOf(story.layer);
- const held = await holdAnimations(page, story.layer, {
- judges: {target: story.layer, property: 'scale'},
- });
+ const held = await openHeldWhileGrowing(page, story);
const samples = await sampleBoxes(
story.layer,
final,
@@ -1167,10 +1151,11 @@ async function armExitCopyHold(
}
/**
- * Opens the popover with a tap and holds its presentation where it starts, so
- * the next press lands while it grows. Under Reduce Motion it holds the
- * cross-fade (`property: 'opacity'`). Returns the held motion; release it
- * with `releaseAnimations`.
+ * Opens the popover with a tap and holds its presentation where it starts.
+ * The page takes the hold itself, so a busy runner cannot miss the motion. A
+ * test then samples the growth, or presses while it grows. Under Reduce
+ * Motion it holds the cross-fade (`property: 'opacity'`). Returns the held
+ * motion; release it with `releaseAnimations`.
*/
async function openHeldWhileGrowing(
page: Page,