Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrodyHughes committed Mar 20, 2024
1 parent 4f7736d commit ce6fc23
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions e2e/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { exec } from 'child_process';
import { JsonRpcProvider } from '@ethersproject/providers';
import { Wallet } from '@ethersproject/wallet';
import { expect, device } from 'detox';
import { expect, device, element, by, waitFor, timeout, testID } from 'detox';
import { parseEther } from '@ethersproject/units';

const TESTING_WALLET = '0x3Cb462CDC5F809aeD0558FBEe151eD5dC3D3f608';
Expand Down Expand Up @@ -39,21 +39,29 @@ export async function importWalletFlow() {
await enableSynchronization();
}

// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable no-undef */
export function tap(elementId) {
return element(by.id(elementId)).tap();
}

export async function waitAndTap(elementId, timeout) {
await waitFor(element(by.id(elementId)))
.toBeVisible()
.withTimeout(timeout || DEFAULT_TIMEOUT);
await waitFor(element(by.id(testID)))
.toBeEnabled()
.withTimeout(timeout || DEFAULT_TIMEOUT);

return element(by.id(elementId)).tap();
return tap(elementId);
}

export function tap(elementId) {
return element(by.id(elementId)).tap();
}
export async function tapByText(text, index) {
await waitFor(element(by.text(text)))
.toBeVisible()
.withTimeout(timeout || DEFAULT_TIMEOUT);
await waitFor(element(by.text(text)))
.toBeEnabled()
.withTimeout(timeout || DEFAULT_TIMEOUT);

export function tapByText(text, index) {
return element(by.text(text))
.atIndex(index || 0)
.tap();
Expand All @@ -71,15 +79,14 @@ export function tapItemAtIndex(elementID, index) {

export async function startIosSimulator() {
if (device.getPlatform() === 'ios') {
await exec('open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/');
exec('open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/');
}
}

export async function typeText(elementId, text, focus = true, syncOnAndroid = false) {
if (focus) {
await tap(elementId);
}
// this is way faster now
if (device.getPlatform() === 'android' && !syncOnAndroid) {
await device.disableSynchronization();
}
Expand Down Expand Up @@ -135,6 +142,7 @@ export async function waitAndSwipe(elementId, direction, speed = 'fast', percent
await waitFor(element(by.id(elementId)))
.toBeVisible()
.withTimeout(timeout || DEFAULT_TIMEOUT);

await element(by.id(elementId))?.swipe(direction, speed, percentage);
}

Expand Down

0 comments on commit ce6fc23

Please sign in to comment.