(params: {
device: DeviceInfo;
interactor: Interactor;
context: DispatchContext | undefined;
x1: number;
y1: number;
x2: number;
y2: number;
requestedDurationMs: number;
preset?: SwipePreset;
})
| 605 | |
| 606 | // fallow-ignore-next-line complexity |
| 607 | async function runSwipeCoordinates(params: { |
| 608 | device: DeviceInfo; |
| 609 | interactor: Interactor; |
| 610 | context: DispatchContext | undefined; |
| 611 | x1: number; |
| 612 | y1: number; |
| 613 | x2: number; |
| 614 | y2: number; |
| 615 | requestedDurationMs: number; |
| 616 | preset?: SwipePreset; |
| 617 | }): Promise<Record<string, unknown>> { |
| 618 | const { device, interactor, context, x1, y1, x2, y2, requestedDurationMs, preset } = params; |
| 619 | const durationMs = requireIntInRange(requestedDurationMs, 'durationMs', 16, 10_000); |
| 620 | const effectiveDurationMs = durationMs; |
| 621 | const count = requireIntInRange(context?.count ?? 1, 'count', 1, 200); |
| 622 | const pauseMs = requireIntInRange(context?.pauseMs ?? 0, 'pause-ms', 0, 10_000); |
| 623 | const pattern = context?.pattern ?? 'one-way'; |
| 624 | if (!isStringMember(SWIPE_PATTERNS, pattern)) { |
| 625 | throw new AppError('INVALID_ARGS', `Invalid pattern: ${pattern}`); |
| 626 | } |
| 627 | |
| 628 | if (shouldUseIosDragSeries(device, count)) { |
| 629 | const aggregated = await runIosSequenceChunks( |
| 630 | device, |
| 631 | buildSwipeSequenceSteps({ |
| 632 | device, |
| 633 | x1, |
| 634 | y1, |
| 635 | x2, |
| 636 | y2, |
| 637 | count, |
| 638 | pauseMs, |
| 639 | pattern, |
| 640 | effectiveDurationMs, |
| 641 | }), |
| 642 | context, |
| 643 | ); |
| 644 | return { |
| 645 | x1, |
| 646 | y1, |
| 647 | x2, |
| 648 | y2, |
| 649 | ...(preset ? { preset } : {}), |
| 650 | durationMs, |
| 651 | effectiveDurationMs, |
| 652 | timingMode: 'runner-sequence', |
| 653 | count, |
| 654 | pauseMs, |
| 655 | pattern, |
| 656 | ...aggregated, |
| 657 | ...successText(formatSwipeMessage(count, pattern)), |
| 658 | }; |
| 659 | } |
| 660 | |
| 661 | await runRepeatedSeries(count, pauseMs, async (index) => { |
| 662 | const reverse = pattern === 'ping-pong' && index % 2 === 1; |
| 663 | if (reverse) await interactor.swipe(x2, y2, x1, y1, effectiveDurationMs); |
| 664 | else await interactor.swipe(x1, y1, x2, y2, effectiveDurationMs); |
no test coverage detected