From 07fd741af1ce35d25b9c39abed42a38405a10add Mon Sep 17 00:00:00 2001 From: Matthew Wall Date: Thu, 29 Aug 2024 16:01:45 -0400 Subject: [PATCH] generalize a little e2e stuff --- e2e/9_swaps.spec.ts | 14 +++++++------- e2e/helpers.ts | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/e2e/9_swaps.spec.ts b/e2e/9_swaps.spec.ts index eb7c00a610a..d60dd78919c 100644 --- a/e2e/9_swaps.spec.ts +++ b/e2e/9_swaps.spec.ts @@ -31,6 +31,8 @@ import { import { expect } from '@jest/globals'; import { WALLET_VARS } from './testVariables'; +const amountOfEthToSend = 20; + describe('Swap Sheet Interaction Flow', () => { beforeAll(async () => { await beforeAllcleanApp({ hardhat: true }); @@ -45,18 +47,17 @@ describe('Swap Sheet Interaction Flow', () => { it('Should send ETH to test wallet', async () => { // send 20 eth - await sendETHtoTestWallet(); + await sendETHtoTestWallet(amountOfEthToSend); }); it('Should show Hardhat Toast after pressing Connect To Hardhat', async () => { await tap('dev-button-hardhat'); await checkIfVisible('testnet-toast-Hardhat'); - // doesn't work atm // validate it has the expected funds of 20 eth - // const attributes = await fetchElementAttributes('fast-coin-info'); - // expect(attributes.label).toContain('Ethereum'); - // expect(attributes.label).toContain('20'); + const attributes = await fetchElementAttributes('fast-coin-info'); + expect(attributes.label).toContain('Ethereum'); + expect(attributes.label).toContain(amountOfEthToSend.toString()); }); it('Should open swap screen with 50% inputAmount for inputAsset', async () => { @@ -70,8 +71,7 @@ describe('Swap Sheet Interaction Flow', () => { await delayTime('medium'); const swapInput = await fetchElementAttributes('swap-asset-input'); - - expect(swapInput.label).toContain('10'); + expect(swapInput.label).toContain((amountOfEthToSend / 2).toString()); expect(swapInput.label).toContain('ETH'); }); diff --git a/e2e/helpers.ts b/e2e/helpers.ts index 7ecb9811fc3..bb5d2c8352a 100644 --- a/e2e/helpers.ts +++ b/e2e/helpers.ts @@ -463,18 +463,18 @@ export const getProvider: ProviderFunction = () => { return getProvider._instance; }; -export async function sendETHtoTestWallet() { +export async function sendETHtoTestWallet(amount = 20) { const provider = getProvider(); // Hardhat account 0 that has 10000 ETH const wallet = new Wallet('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', provider); // Sending 20 ETH so we have enough to pay the tx fees even when the gas is too high await wallet.sendTransaction({ to: TESTING_WALLET, - value: parseEther('20'), + value: parseEther(amount.toString()), }); await delayTime('long'); const balance = await provider.getBalance(TESTING_WALLET); - if (balance.lt(parseEther('20'))) { + if (balance.lt(parseEther(amount.toString()))) { throw Error('Error sending ETH to test wallet'); } return true;