Skip to content

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

TypeScript

test(RefreshControl): send the trackpad pull as one wheel burst (#10520)

Christopher Chedeauc03e4cd762bb
diff --git a/packages/lab/src/RefreshControl/__tests__/RefreshControl.interaction.browser.spec.ts b/packages/lab/src/RefreshControl/__tests__/RefreshControl.interaction.browser.spec.ts
index f1cc1eef62..507149cb8d 100644
--- a/packages/lab/src/RefreshControl/__tests__/RefreshControl.interaction.browser.spec.ts
+++ b/packages/lab/src/RefreshControl/__tests__/RefreshControl.interaction.browser.spec.ts
@@ -1143,6 +1143,12 @@ async function listScrollRest(page: Page, timeout = 3000): Promise<number> {
);
}
+/**
+ * The pause that ends a vertical trackpad scroll's gesture, ms. The page's
+ * clock counts whole ms, so a gap of 1 ms less is the longest within one.
+ */
+const TRACKPAD_SCROLL_END_MS = 180;
+
/** Why the trackpad proofs run in WebKit only. */
const TRACKPAD_SKIP =
"Chromium's driver sends each wheel step as a mouse wheel's notch; WebKit's sends a trackpad's precise deltas";
@@ -1168,8 +1174,16 @@ test('with a trackpad, a two-finger scroll at the top pulls and refreshes as a f
test.skip(browserName === 'chromium', TRACKPAD_SKIP);
const {context, page, content} = await desktopPage(browser);
try {
- // 300 px of scroll toward the top: past the trigger.
- await scrollWheel(page, 30, -10);
+ // 300 px of scroll toward the top, past the trigger, as one gesture. The
+ // steps go out on their schedule. A run the page receives with a
+ // gesture-ending pause fails by name.
+ const driver = await webInputDriver(page);
+ await driver.wheelBurst({
+ x: 200,
+ y: 300,
+ steps: Array.from({length: 30}, () => ({dy: -10})),
+ maxGapMs: TRACKPAD_SCROLL_END_MS - 1,
+ });
// The scroll's gesture ends after its last step. The pull's release
// starts the settle, and the content comes to rest on the inset.
await waitForSettleStart(content);