Skip to content

Commit

Permalink
generalize a little e2e stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
walmat committed Aug 29, 2024
1 parent 69d8a4d commit 07fd741
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions e2e/9_swaps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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 () => {
Expand All @@ -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');
});

Expand Down
6 changes: 3 additions & 3 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 07fd741

Please sign in to comment.