Skip to content

Commit

Permalink
parent 47cbd3c
Browse files Browse the repository at this point in the history
author BrodyHughes <[email protected]> 1717436426 -0500
committer BrodyHughes <[email protected]> 1718422215 -0500

.

.

.

lots of fixes to hardhat assets

fix user assets and list out more tests

start mocking

add quote response mocks and fix testID tap

remove global fetch

okie

remove custom type and consume directly QuoteParams type

finish basic flow

.

.

.

comments

.

.

clean up

oop

clean

rm unused package bumps

prettier -_-

.

.

.

:/

.

.

.

.

.

.
  • Loading branch information
BrodyHughes committed Jun 15, 2024
1 parent 47cbd3c commit 6de8c40
Show file tree
Hide file tree
Showing 33 changed files with 234 additions and 2,913 deletions.
7 changes: 5 additions & 2 deletions e2e/1_importAndWatchWalletsFlow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
} from './helpers';
import { WALLET_VARS } from './testVariables';

// eslint-disable-next-line @typescript-eslint/no-var-requires
require('dotenv').config();

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

describe('Import from private key flow', () => {
Expand All @@ -36,7 +39,7 @@ describe('Import from private key flow', () => {
});

it('with 0x - Should show the "Add wallet modal" after tapping import with a valid private key"', async () => {
await typeText('import-sheet-input', process.env.DEV_PKEY);
await typeText('import-sheet-input', WALLET_VARS.PRIVATE_KEY_WALLET.SECRET);
await checkIfElementHasString('import-sheet-button-label', 'Continue');
await waitAndTap('import-sheet-button');
await checkIfVisible('wallet-info-modal');
Expand Down Expand Up @@ -66,7 +69,7 @@ describe('Import from private key flow', () => {
});

it('without 0x - Should show the "Add wallet modal" after tapping import with a valid private key"', async () => {
await typeText('import-sheet-input', WALLET_VARS.SEED_WALLET.PK.substring(2));
await typeText('import-sheet-input', WALLET_VARS.EMPTY_WALLET.PK.substring(2));
await checkIfElementHasString('import-sheet-button-label', 'Continue');
await waitAndTap('import-sheet-button');
await checkIfVisible('wallet-info-modal');
Expand Down
16 changes: 9 additions & 7 deletions e2e/3_homeScreen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import {
checkIfExists,
checkIfExistsByText,
swipe,
waitAndTap,
afterAllcleanApp,
tap,
delayTime,
} from './helpers';

const RAINBOW_TEST_WALLET = 'rainbowtestwallet.eth';
Expand Down Expand Up @@ -41,19 +42,20 @@ describe('Home Screen', () => {
});

it('tapping "Swap" opens the swap screen', async () => {
await waitAndTap('swap-button');
await checkIfExists('exchange-modal-input-selection-button');
await swipe('exchange-modal-notch', 'down', 'slow');
await tap('swap-button');
await delayTime('long');
await checkIfExists('swap-screen');
await swipe('swap-screen', 'down', 'fast');
});

it('tapping "Send" opens the send screen', async () => {
await waitAndTap('send-button');
await tap('send-button');
await checkIfVisible('send-asset-form-field');
await swipe('send-asset-form-field', 'down');
await swipe('send-asset-form-field', 'down', 'fast');
});

it('tapping "Copy" shows copy address toast', async () => {
await waitAndTap('receive-button');
await tap('receive-button');
await checkIfVisible('address-copied-toast');
});
});
3 changes: 2 additions & 1 deletion e2e/4_discoverSheetFlow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
importWalletFlow,
afterAllcleanApp,
} from './helpers';
import { WALLET_VARS } from './testVariables';

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

Expand All @@ -23,7 +24,7 @@ describe('Discover Screen Flow', () => {
await afterAllcleanApp({ hardhat: false });
});
it('Should import wallet and go to wallet screen', async () => {
await importWalletFlow();
await importWalletFlow(WALLET_VARS.EMPTY_WALLET.PK);
});

it('Should navigate to Discover screen after swiping left', async () => {
Expand Down
3 changes: 2 additions & 1 deletion e2e/5_sendSheetFlowContacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
delayTime,
afterAllcleanApp,
} from './helpers';
import { WALLET_VARS } from './testVariables';

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

Expand All @@ -25,7 +26,7 @@ describe('Send Sheet Interaction Flow Contacts', () => {
});

it('Import a wallet and go to welcome', async () => {
await importWalletFlow();
await importWalletFlow(WALLET_VARS.EMPTY_WALLET.PK);
});

it('Should send ETH to test wallet"', async () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/7_maliciousDappConnection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Check malicious dapp warning', () => {
});

it('Should be able to watch a wallet and load the wallet screen', async () => {
await importWalletFlow(WALLET_VARS.SEED_WALLET.PK);
await importWalletFlow(WALLET_VARS.EMPTY_WALLET.PK);
});

it('Should be able to navigate to the dapp browser', async () => {
Expand Down
135 changes: 135 additions & 0 deletions e2e/8_swapSheetFlow1.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* // TODO:
* - fix getNonceAndPerformSwap mocking
* - fix swap input auto fill validation (cannot import worklet `findNiceIncrement`)
*
* // Other tests to consider:
* - Flip assets
* - exchange button onPress
* - disable button states once https://github.com/rainbow-me/rainbow/pull/5785 gets merged
* - swap execution
* - token search (both from userAssets and output token list)
* - custom gas panel
* - flashbots
* - slippage
* - explainer sheets
* - switching wallets inside of swap screen
*/

import {
importWalletFlow,
sendETHtoTestWallet,
checkIfVisible,
beforeAllcleanApp,
afterAllcleanApp,
fetchElementAttributes,
tap,
delayTime,
tapByText,
} from './helpers';

import { expect } from '@jest/globals';
import { WALLET_VARS } from './testVariables';

describe('Swap Sheet Interaction Flow', () => {
beforeAll(async () => {
await beforeAllcleanApp({ hardhat: true });
});
afterAll(async () => {
await afterAllcleanApp({ hardhat: true });
});

it('Import a wallet and go to welcome', async () => {
await importWalletFlow(WALLET_VARS.EMPTY_WALLET.PK);
});

it('Should send ETH to test wallet', async () => {
// send 20 eth
await sendETHtoTestWallet();
});

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

// 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');
});

it('Should open swap screen with 50% inputAmount for inputAsset', async () => {
await tap('swap-button');

// currently needed due to detox hanging on swap quotes
await device.disableSynchronization();
await tap('token-to-buy-dai-1');
const swapInput = await fetchElementAttributes('swap-asset-input');

// expect inputAsset === .5 * eth balance
expect(swapInput.elements[0].label).toContain('Ethereum');
expect(swapInput.elements[0].label).toContain('10');
});

it('Should be able to go to review and execute a swap', async () => {
await tapByText('Review');
await delayTime('long');
const reviewActionElements = await fetchElementAttributes('swap-action-button');
expect(reviewActionElements.elements[0].label).toContain('ETH');
expect(reviewActionElements.elements[1].label).toContain('DAI');
expect(reviewActionElements.elements[2].label).toContain('Tap to Swap');
await tapByText('Tap to Swap');
});

it('Should be able to see pending swap in activity', async () => {
// allow swap to execute
await delayTime('long');
const activityListElements = await fetchElementAttributes('wallet-activity-list');
expect(activityListElements.label).toContain('ETH');
expect(activityListElements.label).toContain('DAI');
await tapByText('Swapping');
await delayTime('long');
const transactionSheet = await checkIfVisible('transaction-details-sheet');
expect(transactionSheet).toBeTruthy();
});

it('Should open swap screen from ProfileActionRowButton with largest user asset', async () => {
/**
* tap swap button
* wait for Swap header to be visible
* grab highest user asset balance from userAssetsStore
* expect inputAsset.uniqueId === highest user asset uniqueId
*/
});

it('Should open swap screen from asset chart with that asset selected', async () => {
/**
* tap any user asset (store const uniqueId here)
* wait for Swap header to be visible
* expect inputAsset.uniqueId === const uniqueId ^^
*/
});

it('Should open swap screen from dapp browser control panel with largest user asset', async () => {
/**
* tap swap button
* wait for Swap header to be visible
* grab highest user asset balance from userAssetsStore
* expect inputAsset.uniqueId === highest user asset uniqueId
*/
});

it('Should not be able to type in output amount if cross-chain quote', async () => {
/**
* tap swap button
* wait for Swap header to be visible
* select different chain in output list chain selector
* select any asset in output token list
* focus output amount
* attempt to type any number in the SwapNumberPad
* attempt to remove a character as well
*
* ^^ expect both of those to not change the outputAmount
*/
});
});
Loading

0 comments on commit 6de8c40

Please sign in to comment.