feat(locator): duration option for path screen.swipe (#831)

Merged
MO
2mo ago
+204-29

Fixes #831

What and why

  • Adds an optional durationMs?: number to screen.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 specify durationMs enables reliable scrolls, carousels, and pull-to-refresh gestures.
  • Routes path swipes with durationMs to client.interactions.pan on agent-device (since agent-device's interactions.swipe disallows custom durations and delegates timed gestures to pan), while preserving interactions.swipe for swipes without duration.
  • On web, dispatches multi-step pointer dragging via page.mouse.move(..., { steps }) matching Math.round(durationMs / 16).
  • Directional swipes (screen.swipe({ direction, momentum? })) strictly reject durationMs at compile time (durationMs?: never) and at runtime via rejectUnknownOptions.
  • Duration bounds are validated from 16 to 10000 ms (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 typecheck passed (0 errors, verified compile-time assertions in sdk-types.ts).
  • Unit Tests:
    • pnpm --filter e2e exec vitest run tests/unit/fixture-runtime.test.ts passed (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.ts passed (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 (verifies swipe vs pan dispatch).
  • Linter: npx oxlint passed (0 warnings, 0 errors across 943 files).
  • Error Codes: node --experimental-strip-types scripts/check-error-codes.ts passed (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/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.