Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E improvements #6369

Merged
merged 8 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/macstadium-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ jobs:
run: |
rm -rf /Users/administrator/.cocoapods/repos/cocoapods/.git/index.lock
yarn install-bundle && yarn install-pods

- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1

- uses: irgaly/xcode-cache@v1
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const getOnchainBalance = async (address, tokenContractAddress) => {
};

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

describe.skip('Hardhat Transaction Flow', () => {
describe.skip('Anvil Transaction Flow', () => {
it('Should show the welcome screen', async () => {
await Helpers.checkIfVisible('welcome-screen');
});
Expand Down Expand Up @@ -85,9 +85,9 @@ describe.skip('Hardhat Transaction Flow', () => {
await Helpers.sendETHtoTestWallet();
});

it('Should show Hardhat Toast after pressing Connect To Hardhat', async () => {
await Helpers.waitAndTap('dev-button-hardhat');
await Helpers.checkIfVisible('testnet-toast-Hardhat');
it('Should show Anvil Toast after pressing Connect To Anvil', async () => {
await Helpers.waitAndTap('dev-button-anvil');
await Helpers.checkIfVisible('testnet-toast-Anvil');
});

it('Should open send sheet after tapping send fab', async () => {
Expand Down Expand Up @@ -392,6 +392,6 @@ describe.skip('Hardhat Transaction Flow', () => {
await connector?.killSession();
connector = null;
await device.clearKeychain();
await Helpers.killHardhat();
await Helpers.killAnvil();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const ios = device.getPlatform() === 'ios';
const android = device.getPlatform() === 'android';

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

Expand All @@ -29,11 +29,11 @@ const checkIfSwapCompleted = async (assetName, amount) => {
};

// FIXME: Mainnet DAI doesn't show up in the swap search results
// This might be related to @Jin's latest work on changes to hardhat as
// This might be related to @Jin's latest work on changes to anvil as
// part of the addy's REST API migration
//
// marking the test as SKIP for now
describe.skip('Hardhat Transaction Flow', () => {
describe.skip('Anvil Transaction Flow', () => {
it('Should show the welcome screen', async () => {
await Helpers.checkIfVisible('welcome-screen');
});
Expand Down Expand Up @@ -74,9 +74,9 @@ describe.skip('Hardhat Transaction Flow', () => {
await Helpers.sendETHtoTestWallet();
});

it('Should show Hardhat Toast after pressing Connect To Hardhat', async () => {
await Helpers.waitAndTap('dev-button-hardhat');
await Helpers.checkIfVisible('testnet-toast-Hardhat');
it('Should show Anvil Toast after pressing Connect To Anvil', async () => {
await Helpers.waitAndTap('dev-button-anvil');
await Helpers.checkIfVisible('testnet-toast-Anvil');
});

it.skip('Should deposit DAI (via Compound)', async () => {
Expand Down Expand Up @@ -414,6 +414,6 @@ describe.skip('Hardhat Transaction Flow', () => {
await connector?.killSession();
connector = null;
await device.clearKeychain();
await Helpers.killHardhat();
await Helpers.killAnvil();
});
});
10 changes: 5 additions & 5 deletions e2e/Disabled/registerENSFlow.disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const validatePrimaryName = async name => {
};

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

Expand Down Expand Up @@ -155,9 +155,9 @@ describe.skip('Register ENS Flow', () => {
await Helpers.sendETHtoTestWallet();
});

it('Should show Hardhat Toast after pressing Connect To Hardhat', async () => {
await Helpers.waitAndTap('dev-button-hardhat');
await Helpers.checkIfVisible('testnet-toast-Hardhat');
it('Should show Anvil Toast after pressing Connect To Anvil', async () => {
await Helpers.waitAndTap('dev-button-anvil');
await Helpers.checkIfVisible('testnet-toast-Anvil');
});

it('Should navigate to the Discover sheet screen after swiping left', async () => {
Expand Down Expand Up @@ -637,6 +637,6 @@ describe.skip('Register ENS Flow', () => {
afterAll(async () => {
// Reset the app state
await device.clearKeychain();
await Helpers.killHardhat();
await Helpers.killAnvil();
});
});
14 changes: 7 additions & 7 deletions e2e/Disabled/sendSheetFlow.disabled.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { device } from 'detox';
import {
startHardhat,
killHardhat,
startAnvil,
killAnvil,
importWalletFlow,
sendETHtoTestWallet,
waitAndTap,
Expand All @@ -16,11 +16,11 @@ import {
describe.skip('Send Sheet Interaction Flow', () => {
beforeAll(async () => {
await device.reloadReactNative();
await startHardhat();
await startAnvil();
});
afterAll(async () => {
await device.clearKeychain();
await killHardhat();
await killAnvil();
});

it('Import a wallet and go to welcome', async () => {
Expand All @@ -31,9 +31,9 @@ describe.skip('Send Sheet Interaction Flow', () => {
await sendETHtoTestWallet();
});

it('Should show Hardhat Toast after pressing Connect To Hardhat', async () => {
await waitAndTap('dev-button-hardhat');
await checkIfVisible('testnet-toast-Hardhat');
it('Should show Anvil Toast after pressing Connect To Anvil', async () => {
await waitAndTap('dev-button-anvil');
await checkIfVisible('testnet-toast-Anvil');
});

it('Should open send sheet after tapping send button', async () => {
Expand Down
12 changes: 6 additions & 6 deletions e2e/Disabled/swapSheetFlow1.disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const android = device.getPlatform() === 'android';

describe.skip('Swap Sheet Interaction Flow', () => {
beforeAll(async () => {
await Helpers.startHardhat();
await Helpers.startAnvil();
});
afterAll(async () => {
await device.clearKeychain();
await Helpers.killHardhat();
await Helpers.killAnvil();
});

it('Import a wallet and go to welcome', async () => {
Expand All @@ -24,14 +24,14 @@ describe.skip('Swap Sheet Interaction Flow', () => {
await Helpers.sendETHtoTestWallet();
});

it('Should show Hardhat Toast after pressing Connect To Hardhat', async () => {
it('Should show Anvil Toast after pressing Connect To Anvil', async () => {
await Helpers.delayTime('very-long');
await Helpers.waitAndTap('dev-button-hardhat');
await Helpers.checkIfVisible('testnet-toast-Hardhat');
await Helpers.waitAndTap('dev-button-anvil');
await Helpers.checkIfVisible('testnet-toast-Anvil');
});

// FIXME: Mainnet DAI doesn't show up in the swap search results
// This might be related to @Jin's latest work on changes to hardhat as
// This might be related to @Jin's latest work on changes to anvil as
// part of the addy's REST API migration
//
// marking the test as SKIP for now
Expand Down
18 changes: 9 additions & 9 deletions e2e/Disabled/swapSheetFlow2.disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as Helpers from '../helpers';
import { device } from 'detox';

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

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

// FIXME: Mainnet DAI doesn't show up in the swap search results
// This might be related to @Jin's latest work on changes to hardhat as
// This might be related to @Jin's latest work on changes to anvil as
// part of the addy's REST API migration
//
// marking the test as SKIP for now
Expand Down Expand Up @@ -54,23 +54,23 @@ describe.skip('Swap Sheet Interaction Flow', () => {
await Helpers.sendETHtoTestWallet();
});

it('Should show Hardhat Toast after pressing Connect To Hardhat', async () => {
it('Should show Anvil Toast after pressing Connect To Anvil', async () => {
// need to wait for balances to be fetched
await Helpers.delay(10000);
await Helpers.waitAndTap('dev-button-hardhat');
await Helpers.checkIfVisible('testnet-toast-Hardhat');
await Helpers.waitAndTap('dev-button-anvil');
await Helpers.checkIfVisible('testnet-toast-Anvil');
});

it('Should connect to hardhat', async () => {
it('Should connect to anvil', async () => {
await Helpers.swipe('wallet-screen', 'right', 'slow');
await Helpers.checkIfVisible('profile-screen');
await Helpers.waitAndTap('settings-button');
await Helpers.checkIfVisible('settings-sheet');
await Helpers.scrollTo('settings-menu-container', 'bottom');
await Helpers.waitAndTap('developer-section');
await Helpers.swipeUntilVisible('alert-section', 'developer-settings-sheet', 'up');
await Helpers.waitAndTap('hardhat-section');
await Helpers.checkIfVisible('testnet-toast-Hardhat');
await Helpers.waitAndTap('anvil-section');
await Helpers.checkIfVisible('testnet-toast-Anvil');
await Helpers.swipe('profile-screen', 'left', 'slow');
});

Expand Down Expand Up @@ -474,6 +474,6 @@ describe.skip('Swap Sheet Interaction Flow', () => {
afterAll(async () => {
// Reset the app state
await device.clearKeychain();
await Helpers.killHardhat();
await Helpers.killAnvil();
});
});
25 changes: 16 additions & 9 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { exec } from 'child_process';
import { JsonRpcProvider } from '@ethersproject/providers';
import { Wallet } from '@ethersproject/wallet';
import { expect, device, element, by, waitFor } from 'detox';
import { parseEther } from '@ethersproject/units';
import { formatEther, parseEther } from '@ethersproject/units';
import { IosElementAttributes, AndroidElementAttributes } from 'detox/detox';

const TESTING_WALLET = '0x3637f053D542E6D00Eee42D656dD7C59Fa33a62F';
Expand All @@ -20,12 +20,12 @@ interface ProviderFunction {
_instance?: JsonRpcProvider;
}

export async function startHardhat() {
export async function startAnvil() {
await delayTime('short');
exec('yarn hardhat');
exec('yarn anvil');
}

export async function killHardhat() {
export async function killAnvil() {
await delayTime('short');
exec('kill $(lsof -t -i:8545)');
}
Expand Down Expand Up @@ -53,14 +53,14 @@ export async function importWalletFlow(customSeed?: string) {
await checkIfVisible('wallet-screen');
}

export async function beforeAllcleanApp({ hardhat }: { hardhat?: boolean }) {
export async function beforeAllcleanApp({ anvil }: { anvil?: boolean }) {
jest.resetAllMocks();
hardhat && (await startHardhat());
anvil && (await startAnvil());
}

export async function afterAllcleanApp({ hardhat }: { hardhat?: boolean }) {
export async function afterAllcleanApp({ anvil }: { anvil?: boolean }) {
await device.clearKeychain();
hardhat && (await killHardhat());
anvil && (await killAnvil());
}

export async function tap(elementId: string | RegExp) {
Expand Down Expand Up @@ -467,16 +467,23 @@ export const getProvider: ProviderFunction = () => {
};

export async function sendETHtoTestWallet() {
console.log('getting provider');
const provider = getProvider();
// Hardhat account 0 that has 10000 ETH
console.log('got provider', provider);
// anvil account 0 that has 10000 ETH
const wallet = new Wallet('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', provider);
console.log('got wallet', wallet);
// Sending 20 ETH so we have enough to pay the tx fees even when the gas is too high
console.log('sending eth');
await wallet.sendTransaction({
to: TESTING_WALLET,
value: parseEther('20'),
});
console.log('sent eth');
await delayTime('long');
console.log('checking balance');
const balance = await provider.getBalance(TESTING_WALLET);
console.log('got balance', formatEther(balance));
Comment on lines +470 to +486
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep this log cause this part breaks often

if (balance.lt(parseEther('20'))) {
throw Error('Error sending ETH to test wallet');
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ beforeAll(async () => {
if (device.getPlatform() === 'android') {
// connecting to metro
await device.reverseTcpPort(8081);
// connecting to hardhat
// connecting to anvil
await device.reverseTcpPort(8545); // TODO: WIP for android connecting in dev

// make sure we don't have gesture navigation what might cause collisions
Expand Down
4 changes: 2 additions & 2 deletions e2e/parallel/1_importAndWatchWalletsFlow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const android = device.getPlatform() === 'android';

describe('Import from private key flow', () => {
beforeAll(async () => {
await beforeAllcleanApp({ hardhat: false });
await beforeAllcleanApp({ anvil: false });
});
afterAll(async () => {
await afterAllcleanApp({ hardhat: false });
await afterAllcleanApp({ anvil: false });
});
it('with 0x - Should show the welcome screen', async () => {
await checkIfVisible('welcome-screen');
Expand Down
4 changes: 2 additions & 2 deletions e2e/parallel/2_newWalletFlow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const android = device.getPlatform() === 'android';

describe('New Wallet flow', () => {
beforeAll(async () => {
await beforeAllcleanApp({ hardhat: false });
await beforeAllcleanApp({ anvil: false });
});
afterAll(async () => {
await afterAllcleanApp({ hardhat: false });
await afterAllcleanApp({ anvil: false });
});

it('should show the welcome screen', async () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/parallel/3_homeScreen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const RAINBOW_TEST_WALLET = 'rainbowtestwallet.eth';

describe('Home Screen', () => {
beforeAll(async () => {
await beforeAllcleanApp({ hardhat: false });
await beforeAllcleanApp({ anvil: false });
});
afterAll(async () => {
await afterAllcleanApp({ hardhat: false });
await afterAllcleanApp({ anvil: false });
});

it('imports wallet', async () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/parallel/4_discoverSheetFlow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const ios = device.getPlatform() === 'ios';

describe('Discover Screen Flow', () => {
beforeAll(async () => {
await beforeAllcleanApp({ hardhat: false });
await beforeAllcleanApp({ anvil: false });
});
afterAll(async () => {
await afterAllcleanApp({ hardhat: false });
await afterAllcleanApp({ anvil: false });
});
it('Should import wallet and go to wallet screen', async () => {
await importWalletFlow();
Expand Down
4 changes: 2 additions & 2 deletions e2e/parallel/5_watchedWalletCollectionActionsFlow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {

describe('Watched showcase and hidden actions flow', () => {
beforeAll(async () => {
await beforeAllcleanApp({ hardhat: false });
await beforeAllcleanApp({ anvil: false });
});
afterAll(async () => {
await afterAllcleanApp({ hardhat: false });
await afterAllcleanApp({ anvil: false });
});

it('watches a wallet and loads wallet screen', async () => {
Expand Down
Loading
Loading