Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrodyHughes committed Mar 19, 2024
1 parent 01938d8 commit 990d5e6
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 321 deletions.
6 changes: 3 additions & 3 deletions e2e/deeplinks.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-undef */
/* eslint-disable jest/expect-expect */
import { exec } from 'child_process';
import * as Helpers from './helpers';
import { device } from 'detox';

const RAINBOW_WALLET_ADDRESS = '0x7a3d05c70581bD345fe117c06e45f9669205384f';

Expand Down Expand Up @@ -37,10 +36,11 @@ beforeAll(async () => {
// Chrome or the app. Detox is only able to control tapping within the app,
// so this blocks our tests. The only way we found to bypass this is to
// uninstall Chrome before.
await exec('yarn adb-all shell pm disable-user com.android.chrome');
exec('yarn adb-all shell pm disable-user com.android.chrome');
}
});

// eslint-disable-next-line jest/no-disabled-tests
describe.skip('Deeplinks spec', () => {
it('Should show the welcome screen', async () => {
await Helpers.checkIfVisible('welcome-screen');
Expand Down
File renamed without changes.
44 changes: 40 additions & 4 deletions e2e/helpers.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
import { exec } from 'child_process';
import { JsonRpcProvider } from '@ethersproject/providers';
import { Wallet } from '@ethersproject/wallet';
import { expect } from 'detox';
import { expect, device } from 'detox';
import { parseEther } from '@ethersproject/units';

const TESTING_WALLET = '0x3Cb462CDC5F809aeD0558FBEe151eD5dC3D3f608';

const DEFAULT_TIMEOUT = 8000;
const DEFAULT_TIMEOUT = 20_000;
const android = device.getPlatform() === 'android';

export async function startHardhat() {
await exec('yarn hardhat');
exec('yarn hardhat');
}

export async function killHardhat() {
await exec('kill $(lsof -t -i:8545)');
exec('kill $(lsof -t -i:8545)');
}

export async function importWalletFlow() {
await checkIfVisible('welcome-screen');
await waitAndTap('already-have-wallet-button');
await checkIfExists('add-wallet-sheet');
await waitAndTap('restore-with-key-button');
await checkIfExists('import-sheet');
await clearField('import-sheet-input');
await typeText('import-sheet-input', process.env.TEST_SEEDS, false);
await checkIfElementHasString('import-sheet-button-label', 'Continue');
await waitAndTap('import-sheet-button');
await checkIfVisible('wallet-info-modal');
await disableSynchronization();
await waitAndTap('wallet-info-submit-button');
if (android) {
await checkIfVisible('pin-authentication-screen');
await authenticatePin('1234');
await authenticatePin('1234');
}
await checkIfVisible('wallet-screen', 40000);
await enableSynchronization();
}

// eslint-disable-next-line eslint-comments/disable-enable-pair
Expand Down Expand Up @@ -235,6 +258,19 @@ export function delay(ms) {
});
}

export async function delayTime(time) {
switch (time) {
case 'short':
return await delay(500);
case 'medium':
return await delay(100);
case 'long':
return await delay(5_000);
case 'very-long':
return await delay(10_000);
}
}

export function getProvider() {
if (!getProvider._instance) {
getProvider._instance = new JsonRpcProvider('http://127.0.0.1:8545', 'any');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as Helpers from './helpers';

const android = device.getPlatform() === 'android';

// eslint-disable-next-line jest/no-disabled-tests
describe.skip('Hidden tokens flow', () => {
it('boots and loads wallet screen', async () => {
await Helpers.waitAndTap('already-have-wallet-button');
Expand Down
31 changes: 5 additions & 26 deletions e2e/homeScreen.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,12 @@ import * as Helpers from './helpers';
const RAINBOW_TEST_WALLET = 'rainbowtestwallet.eth';

describe('Home Screen', () => {
afterAll(async () => {
await device.clearKeychain();
});

it('imports wallet', async () => {
await Helpers.checkIfVisible('welcome-screen');
await Helpers.waitAndTap('already-have-wallet-button');
await Helpers.checkIfExists('add-wallet-sheet');
await Helpers.waitAndTap('restore-with-key-button');
await Helpers.checkIfExists('import-sheet');
await Helpers.clearField('import-sheet-input');
await Helpers.typeText('import-sheet-input', process.env.TEST_SEEDS, false);
await Helpers.checkIfElementHasString('import-sheet-button-label', 'Continue');
await Helpers.waitAndTap('import-sheet-button');
await Helpers.checkIfVisible('wallet-info-modal');
await Helpers.disableSynchronization();
await Helpers.waitAndTap('wallet-info-submit-button');
if (device.getPlatform() === 'android') {
await Helpers.checkIfVisible('pin-authentication-screen');
// Set the pin
await Helpers.authenticatePin('1234');
// Confirm it
await Helpers.authenticatePin('1234');
}
await Helpers.checkIfVisible('wallet-screen', 80000);
await Helpers.enableSynchronization();
await Helpers.importWalletFlow();
});

it('show profile header', async () => {
Expand Down Expand Up @@ -62,9 +46,4 @@ describe('Home Screen', () => {
await Helpers.waitAndTap('receive-button');
await Helpers.checkIfVisible('address-copied-toast');
});

afterAll(async () => {
// Reset the app state
await device.clearKeychain();
});
});
16 changes: 3 additions & 13 deletions e2e/importPrivateKeyFlow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import * as Helpers from './helpers';
const android = device.getPlatform() === 'android';

describe('Import from private key flow', () => {
afterAll(async () => {
await device.clearKeychain();
});
it('without 0x - Should show the welcome screen', async () => {
await Helpers.checkIfVisible('welcome-screen');
});
Expand Down Expand Up @@ -33,23 +36,10 @@ describe('Import from private key flow', () => {
await Helpers.waitAndTap('wallet-info-submit-button');
if (android) {
await Helpers.checkIfVisible('pin-authentication-screen');
// Set the pin
await Helpers.authenticatePin('1234');
// Confirm it
await Helpers.authenticatePin('1234');
}
await Helpers.checkIfVisible('wallet-screen', 40000);
await Helpers.enableSynchronization();
});

// Saving for now in case we want to test iCloud back up sheet
// it('Should show the backup sheet', async () => {
// await Helpers.checkIfVisible('backup-sheet');
// await Helpers.waitAndTap('backup-sheet-imported-cancel-button');
// });

afterAll(async () => {
// Reset the app state
await device.clearKeychain();
});
});
17 changes: 3 additions & 14 deletions e2e/importPrivateKeyFlow0x.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import * as Helpers from './helpers';
const android = device.getPlatform() === 'android';

describe('Import from private key flow', () => {
afterAll(async () => {
await device.clearKeychain();
});
it('with 0x - Should show the welcome screen', async () => {
await Helpers.checkIfVisible('welcome-screen');
});
Expand Down Expand Up @@ -33,24 +36,10 @@ describe('Import from private key flow', () => {
await Helpers.waitAndTap('wallet-info-submit-button');
if (android) {
await Helpers.checkIfVisible('pin-authentication-screen');
// Set the pin
await Helpers.authenticatePin('1234');
// Confirm it
await Helpers.authenticatePin('1234');
}
await Helpers.checkIfVisible('wallet-screen', 40000);
await Helpers.enableSynchronization();
});

// Saving for now in case we want to test iCloud back up sheet
// it('Should show the backup sheet', async () => {
// await Helpers.delay(3000);
// await Helpers.checkIfVisible('backup-sheet');
// await Helpers.waitAndTap('backup-sheet-imported-cancel-button');
// });

afterAll(async () => {
// Reset the app state
await device.clearKeychain();
});
});
39 changes: 8 additions & 31 deletions e2e/newWalletFlow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,31 @@ import * as Helpers from './helpers';
const android = device.getPlatform() === 'android';

describe('New Wallet flow', () => {
afterAll(async () => {
await device.clearKeychain();
});

it('should show the welcome screen', async () => {
await Helpers.checkIfVisible('welcome-screen');
});

it('go to the wallet screen after pressing "Get a new wallet" button', async () => {
await Helpers.disableSynchronization();
await Helpers.waitAndTap('new-wallet-button');
if (android) {
await Helpers.checkIfVisible('pin-authentication-screen');
// Set the pin
await Helpers.authenticatePin('1234');
// Confirm it
await Helpers.authenticatePin('1234');
}
await Helpers.checkIfVisible('wallet-screen', 200000);
await Helpers.enableSynchronization();
await Helpers.checkIfVisible('wallet-screen');
await Helpers.delayTime('long');
});

// Saving for now in case we want to test iCloud back up sheet
// it('Should show the backup sheet', async () => {
// await Helpers.delay(5000);
// await Helpers.checkIfVisible('backup-sheet');
// await Helpers.swipe('backup-sheet', 'down');
// });

// FIXME: empty wallet state does not show up and gets stuck in the loading
// assets state - not always, this needs to be investigated
it.skip('should show the receive card and its contents', async () => {
it('should show the receive card and its contents', async () => {
await Helpers.checkIfVisible('receive-card');
await Helpers.checkIfVisible('copy-address-button');
});

it.skip('should show eth asset card with a buy button', async () => {
it('should show eth asset card with a buy button', async () => {
await Helpers.checkIfVisible('eth-card');
await Helpers.checkIfVisible('buy-eth-button');
});

it.skip('should show the "Add funds" button', async () => {
await Helpers.checkIfVisible('copy-address-button');
});

it.skip('should show "No transactions yet" in the activity list', async () => {
await Helpers.waitAndTap('activity-button');
await Helpers.checkIfElementByTextIsVisible('No transactions yet');
});

afterAll(async () => {
// Reset the app state
await device.clearKeychain();
});
});
86 changes: 7 additions & 79 deletions e2e/sendSheetFlow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,17 @@
/* eslint-disable jest/expect-expect */
import * as Helpers from './helpers';

const android = device.getPlatform() === 'android';

beforeAll(async () => {
await Helpers.startHardhat();
});

describe('Send Sheet Interaction Flow', () => {
it('Should show the welcome screen', async () => {
await Helpers.checkIfVisible('welcome-screen');
});

it('Should show the "Add Wallet Sheet" after tapping on "I already have a wallet"', async () => {
await Helpers.waitAndTap('already-have-wallet-button');
await Helpers.checkIfExists('add-wallet-sheet');
beforeAll(async () => {
await Helpers.startHardhat();
});

it('show the "Import Sheet" when tapping on "Restore with a recovery phrase or private key"', async () => {
await Helpers.waitAndTap('restore-with-key-button');
await Helpers.checkIfExists('import-sheet');
});

it('Should show the "Add wallet modal" after tapping import with a valid seed"', async () => {
await Helpers.clearField('import-sheet-input');
await Helpers.typeText('import-sheet-input', process.env.TEST_SEEDS, false);
await Helpers.checkIfElementHasString('import-sheet-button-label', 'Continue');
await Helpers.waitAndTap('import-sheet-button');
await Helpers.checkIfVisible('wallet-info-modal');
afterAll(async () => {
await device.clearKeychain();
await Helpers.killHardhat();
});

it('Should navigate to the Wallet screen after tapping on "Import Wallet"', async () => {
await Helpers.disableSynchronization();
await Helpers.waitAndTap('wallet-info-submit-button');
if (android) {
await Helpers.checkIfVisible('pin-authentication-screen');
// Set the pin
await Helpers.authenticatePin('1234');
// Confirm it
await Helpers.authenticatePin('1234');
}
await Helpers.checkIfVisible('wallet-screen', 40000);
await Helpers.enableSynchronization();
it('Import a wallet and go to welcome', async () => {
await Helpers.importWalletFlow();
});

it('Should send ETH to test wallet"', async () => {
Expand All @@ -54,29 +24,6 @@ describe('Send Sheet Interaction Flow', () => {
await Helpers.checkIfVisible('testnet-toast-Hardhat');
});

// Saving for now in case we want to test iCloud back up sheet
// it('Should show the backup sheet', async () => {
// await Helpers.checkIfVisible('backup-sheet');
// await Helpers.waitAndTap('backup-sheet-imported-cancel-button');
// });
/*
it('Should open expanded state', async () => {
await Helpers.waitAndTap('balance-coin-row-Ethereum');
;
it('Should tap through chart timeseries', async () => {
await Helpers.waitAndTap('chart-timespan-h');
await Helpers.waitAndTap('chart-timespan-d');
await Helpers.waitAndTap('chart-timespan-w');
await Helpers.waitAndTap('chart-timespan-m');
await Helpers.waitAndTap('chart-timespan-y');
;
it('Should close Expanded State and navigate to wallet screen', async () => {
await Helpers.swipe('expanded-state-header', 'down');
await Helpers.checkIfVisible('wallet-screen');
});
*/
it.skip('Should show all wallet sections', async () => {
await Helpers.swipe('wallet-screen', 'up');
await Helpers.checkIfElementByTextIsVisible('Collectibles');
Expand All @@ -101,7 +48,6 @@ describe('Send Sheet Interaction Flow', () => {
await Helpers.clearField('send-asset-form-field');
await Helpers.checkIfVisible('send-asset-form-field');
await Helpers.replaceTextInField('send-asset-form-field', '0xF0f21ab2012731542731df194cfF6c77d29cB31A');
// await Helpers.checkIfVisible('add-contact-button');
await Helpers.checkIfVisible('send-asset-list', 20000);
});

Expand All @@ -114,22 +60,9 @@ describe('Send Sheet Interaction Flow', () => {
await device.disableSynchronization();
await Helpers.typeText('send-asset-form-field', 'rainbowwallet.eth\n', false);
await device.enableSynchronization();
// await Helpers.checkIfVisible('add-contact-button')
await Helpers.checkIfVisible('send-asset-list');
});

/*
it('Should display Asset Form after tapping on savings asset', async () => {
await Helpers.checkIfVisible('send-savings-cDAI');
await Helpers.waitAndTap('send-savings-cDAI');
await Helpers.checkIfVisible('selected-asset-field-input');
});
it('Should go back to Asset List after tapping on savings asset', async () => {
await Helpers.waitAndTap('send-asset-form-cDAI-mainnet');
await Helpers.checkIfVisible('send-asset-list');
});*/

it.skip('Should display Asset Form after tapping on asset', async () => {
await Helpers.checkIfVisible('send-asset-DAI-mainnet');
await Helpers.waitAndTap('send-asset-DAI-mainnet');
Expand Down Expand Up @@ -217,9 +150,4 @@ describe('Send Sheet Interaction Flow', () => {
await Helpers.checkIfElementByTextIsVisible('8.12');
await Helpers.waitAndTap('send-asset-form-ETH-mainnet');
});
afterAll(async () => {
// Reset the app state
await device.clearKeychain();
await Helpers.killHardhat();
});
});
Loading

0 comments on commit 990d5e6

Please sign in to comment.