feat(locator): duration option for path screen.swipe (#831)
Merged
MO
2mo ago+204+204+012345678901234567890123456789-29-29-01234567890123456789
Fixes #831
What and why
- Adds an optional
durationMs?: numbertoscreen.swipe({ from, to, durationMs? }). - On mobile (e.g., Android emulators with React Native
ScrollView), path swipes at the default ~100 ms duration are often dropped or cancelled as taps/flings. Allowing tests to specifydurationMsenables reliable scrolls, carousels, and pull-to-refresh gestures. - Routes path swipes with
durationMstoclient.interactions.panonagent-device(sinceagent-device'sinteractions.swipedisallows custom durations and delegates timed gestures to pan), while preservinginteractions.swipefor swipes without duration. - On web, dispatches multi-step pointer dragging via
page.mouse.move(..., { steps })matchingMath.round(durationMs / 16). - Directional swipes (
screen.swipe({ direction, momentum? })) strictly rejectdurationMsat compile time (durationMs?: never) and at runtime viarejectUnknownOptions. - Duration bounds are validated from
16to10000ms (matching hardware frame rate minimum and device limits).
Verified
Ran it locally: yes
- Typecheck:
pnpm --filter e2e run typecheck,pnpm --filter @e2e-dev/web run typecheck,pnpm --filter @e2e-dev/mobile run typecheckpassed (0 errors, verified compile-time assertions insdk-types.ts). - Unit Tests:
pnpm --filter e2e exec vitest run tests/unit/fixture-runtime.test.tspassed (47/47 tests, including Issue #831 parameters{ from: { x: 540, y: 1560 }, to: { x: 540, y: 840 }, durationMs: 300 }, bounds validation, and step recording).pnpm --filter @e2e-dev/web exec vitest run tests/unit/actions.test.tspassed (39/39 tests, multi-step pointer drag).pnpm --filter @e2e-dev/mobile exec vitest run tests/unit/engine.test.ts -t "maps every supported action"passed (verifiesswipevspandispatch).
- Linter:
npx oxlintpassed (0 warnings, 0 errors across 943 files). - Error Codes:
node --experimental-strip-types scripts/check-error-codes.tspassed (all 84 error codes documented).
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.