diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a85e800629..8ef128e49a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -495,8 +495,6 @@ jobs: - uses: geekyeggo/delete-artifact@v2 with: name: node_modules.tar.gz - - name: Anvil Cleanup - run: yarn anvil:kill - uses: geekyeggo/delete-artifact@v2 with: name: screenshots diff --git a/e2e/helpers.ts b/e2e/helpers.ts index 1135349746..3bab067b90 100644 --- a/e2e/helpers.ts +++ b/e2e/helpers.ts @@ -7,7 +7,6 @@ import * as fs from 'node:fs'; import { Contract } from '@ethersproject/contracts'; import { getDefaultProvider } from '@ethersproject/providers'; -import { ethers } from 'ethers'; import { Builder, By, @@ -737,84 +736,13 @@ export async function getOnchainBalance(addy: string, contract: string) { } } -async function fetchLatestTransactionHash( - provider: ethers.providers.JsonRpcProvider, -): Promise { - const latestBlock = await provider.getBlockWithTransactions('latest'); - if (latestBlock.transactions.length === 0) return null; - return latestBlock.transactions[latestBlock.transactions.length - 1].hash; -} - -async function validateTransactionGasSettings( - transactionHash: string, - provider: ethers.providers.JsonRpcProvider, - expectedMaxPriorityFeePerGasInGwei: number, - expectedBaseFeeInGwei: number, -): Promise { - if (!transactionHash) throw new Error('No transaction hash provided.'); - const transaction = await provider.getTransaction(transactionHash); - if (!transaction) throw new Error('Transaction not found.'); - - const expectedTotalMaxFeePerGasInGwei = - expectedMaxPriorityFeePerGasInGwei + expectedBaseFeeInGwei; - const expectedMaxPriorityFeePerGasWei = ethers.utils.parseUnits( - expectedMaxPriorityFeePerGasInGwei.toString(), - 'gwei', - ); - const expectedTotalMaxFeePerGasWei = ethers.utils.parseUnits( - expectedTotalMaxFeePerGasInGwei.toString(), - 'gwei', - ); - - const actualMaxPriorityFeePerGas = transaction.maxPriorityFeePerGas; - const actualMaxFeePerGas = transaction.maxFeePerGas; - - if ( - !actualMaxPriorityFeePerGas || - !actualMaxFeePerGas || - !actualMaxPriorityFeePerGas.eq(expectedMaxPriorityFeePerGasWei) || - !actualMaxFeePerGas.eq(expectedTotalMaxFeePerGasWei) - ) { - throw new Error( - `Gas settings mismatch. Expected maxPriorityFeePerGas: ${expectedMaxPriorityFeePerGasInGwei} gwei, expected total maxFeePerGas (Max Base Fee + Miner Tip): ${expectedTotalMaxFeePerGasInGwei} gwei, but got maxPriorityFeePerGas: ${ - actualMaxPriorityFeePerGas - ? ethers.utils.formatUnits(actualMaxPriorityFeePerGas, 'gwei') - : 'none' - } gwei, maxFeePerGas: ${ - actualMaxFeePerGas - ? ethers.utils.formatUnits(actualMaxFeePerGas, 'gwei') - : 'none' - } gwei.`, - ); - } -} - -export async function verifyCustomGasSettings( - maxBaseFee: number, - minerTip: number, -): Promise { - const provider = new ethers.providers.JsonRpcProvider( - 'http://127.0.0.1:8545', - ); - const transactionHash = await fetchLatestTransactionHash(provider); - if (transactionHash) { - await validateTransactionGasSettings( - transactionHash, - provider, - maxBaseFee, - minerTip, - ); - } -} - export async function transactionStatus() { const provider = getDefaultProvider('http://127.0.0.1:8545'); const blockData = await provider.getBlock('latest'); const txnReceipt = await provider.getTransactionReceipt( - blockData.transactions[blockData.transactions.length - 1], + blockData.transactions[0], ); const txnStatus = txnReceipt.status === 1 ? 'success' : 'failure'; - return txnStatus; } diff --git a/e2e/serial/optimismTransactions/1_sendFlow.test.ts b/e2e/serial/optimismTransactions/1_sendFlow.test.ts index 3d8ec31992..be1dcc3d0e 100644 --- a/e2e/serial/optimismTransactions/1_sendFlow.test.ts +++ b/e2e/serial/optimismTransactions/1_sendFlow.test.ts @@ -16,7 +16,6 @@ import { checkWalletName, delay, delayTime, - doNotFindElementByTestId, executePerformShortcut, findElementByTestId, findElementByText, @@ -122,15 +121,6 @@ describe('Complete Hardhat Optimism send flow', () => { expect(Number(valueNum)).toBe(0); }); - it('should not be able to open up either of the gas menu options', async () => { - await doNotFindElementByTestId({ id: 'gas-menu', driver }); - await doNotFindElementByTestId({ id: 'custom-gas-menu', driver }); - await executePerformShortcut({ driver, key: 'C' }); - await doNotFindElementByTestId({ id: 'custom-gas-sheet', driver }); - await executePerformShortcut({ driver, key: 'G' }); - await doNotFindElementByTestId({ id: 'transaction-speed-title', driver }); - }); - it('should be able to initiate Optimisim ETH transaction', async () => { await driver.actions().sendKeys('1').perform(); const value = await findElementByTestId({ id: 'send-input-mask', driver }); diff --git a/e2e/serial/send/1_sendFlow.test.ts b/e2e/serial/send/1_sendFlow.test.ts index 3b9c2e3939..2261f1993e 100644 --- a/e2e/serial/send/1_sendFlow.test.ts +++ b/e2e/serial/send/1_sendFlow.test.ts @@ -5,7 +5,6 @@ import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from 'vitest'; import { delayTime, - executePerformShortcut, findElementById, findElementByIdAndClick, findElementByTestId, @@ -22,7 +21,6 @@ import { takeScreenshotOnFailure, transactionStatus, typeOnTextInput, - verifyCustomGasSettings, waitAndClick, } from '../../helpers'; import { TEST_VARIABLES } from '../../walletVariables'; @@ -208,95 +206,6 @@ it('should be able to click max and switch on send flow', async () => { await inputMask.sendKeys('0.01'); }); -it('should be able to open gas dropdown via shortcut', async () => { - await delayTime('long'); - await executePerformShortcut({ driver, key: 'g' }); - const txnSpeed1 = await findElementByText(driver, 'Transaction Speed'); - expect(txnSpeed1).toBeTruthy(); - await executePerformShortcut({ driver, key: 'ESCAPE' }); -}); - -it('should be able to switch gas prices via dropdown on send flow', async () => { - await findElementByTestIdAndClick({ id: 'gas-menu', driver }); - const txnSpeed2 = await findElementByText(driver, 'Transaction Speed'); - expect(txnSpeed2).toBeTruthy(); - await findElementByTextAndClick(driver, 'Urgent'); - await delayTime('medium'); - const urgent = await findElementByText(driver, 'Urgent'); - expect(urgent).toBeTruthy(); -}); - -it('should be able to open custom gas sheet via shortcut', async () => { - await delayTime('long'); - await executePerformShortcut({ driver, key: 'c' }); - const gasSettings1 = await findElementByText(driver, 'Gas Settings'); - expect(gasSettings1).toBeTruthy(); - await executePerformShortcut({ driver, key: 'ESCAPE' }); -}); - -it('should be able to open up the custom gas menu on the send flow', async () => { - await findElementByTestIdAndClick({ id: 'custom-gas-menu', driver }); - const gasSettings = await findElementByText(driver, 'Gas Settings'); - expect(gasSettings).toBeTruthy(); -}); - -it('should be able to open up the explainers on the custom gas menu', async () => { - // explainer 1 - await findElementByTestIdAndClick({ - id: 'current-base-fee-explainer', - driver, - }); - await delayTime('short'); - const current = await findElementByText(driver, 'The base fee is'); - expect(current).toBeTruthy(); - await findElementByTestIdAndClick({ id: 'explainer-action-button', driver }); - - // explainer 2 - await findElementByTestIdAndClick({ id: 'max-base-fee-explainer', driver }); - await delayTime('short'); - const max = await findElementByText(driver, 'This is the maximum'); - expect(max).toBeTruthy(); - await findElementByTestIdAndClick({ id: 'explainer-action-button', driver }); - - // explainer 3 - await findElementByTestIdAndClick({ - id: 'max-priority-fee-explainer', - driver, - }); - await delayTime('short'); - const miner = await findElementByText(driver, 'The miner tip goes'); - expect(miner).toBeTruthy(); - await findElementByTestIdAndClick({ id: 'explainer-action-button', driver }); -}); - -it('should be able to customize gas', async () => { - await delayTime('short'); - await executePerformShortcut({ driver, key: 'TAB' }); - await executePerformShortcut({ driver, key: 'BACK_SPACE', timesToPress: 5 }); - await driver.actions().sendKeys('400').perform(); - await delayTime('short'); - await executePerformShortcut({ driver, key: 'TAB' }); - await executePerformShortcut({ driver, key: 'BACK_SPACE', timesToPress: 5 }); - await driver.actions().sendKeys('400').perform(); - const baseFeeGweiInputMask = await querySelector( - driver, - "[data-testid='max-base-fee-input'] [data-testid='gwei-input-mask']", - ); - - expect(await baseFeeGweiInputMask.getAttribute('value')).toContain('400'); - - const minerTipGweiInputMask = await querySelector( - driver, - "[data-testid='miner-tip-input'] [data-testid='gwei-input-mask']", - ); - - expect(await minerTipGweiInputMask.getAttribute('value')).toContain('400'); - await findElementByTestIdAndClick({ id: 'set-gas-button', driver }); - - const gasMenu = await findElementByTestId({ id: 'gas-menu', driver }); - expect(await gasMenu.getText()).toContain('Custom'); -}); - it('should be able to go to review on send flow', async () => { await findElementByTestIdAndClick({ id: 'send-review-button', driver }); }); @@ -327,8 +236,7 @@ it('should be able to interact with destination menu on review on send flow', as it('should be able to send transaction on review on send flow', async () => { await findElementByTestIdAndClick({ id: 'review-confirm-button', driver }); const sendTransaction = await transactionStatus(); - expect(sendTransaction).toBe('success'); - await verifyCustomGasSettings(400, 400); + expect(await sendTransaction).toBe('success'); }); it('should be able to rename a wallet from the wallet switcher', async () => { diff --git a/e2e/serial/send/2_shortcuts-sendFlow.test.ts b/e2e/serial/send/2_shortcuts-sendFlow.test.ts index a81a25a59a..be32662d27 100644 --- a/e2e/serial/send/2_shortcuts-sendFlow.test.ts +++ b/e2e/serial/send/2_shortcuts-sendFlow.test.ts @@ -35,6 +35,7 @@ let driver: WebDriver; const browser = process.env.BROWSER || 'chrome'; const os = process.env.OS || 'mac'; +const isFirefox = browser === 'firefox'; describe('Complete send flow via shortcuts and keyboard navigation', () => { beforeAll(async () => { @@ -210,12 +211,14 @@ describe('Complete send flow via shortcuts and keyboard navigation', () => { }); it('should be able to select asset to send from home using keyboard ', async () => { - await executePerformShortcut({ driver, key: 'ESCAPE' }); - await executePerformShortcut({ driver, key: 'ARROW_LEFT' }); - await executePerformShortcut({ driver, key: 'TAB', timesToPress: 8 }); - await executePerformShortcut({ driver, key: 'SPACE' }); - await executePerformShortcut({ driver, key: 'ARROW_DOWN' }); - await executePerformShortcut({ driver, key: 'ENTER' }); - await checkExtensionURL(driver, 'send'); + if (!isFirefox) { + await executePerformShortcut({ driver, key: 'ESCAPE' }); + await executePerformShortcut({ driver, key: 'ARROW_LEFT' }); + await executePerformShortcut({ driver, key: 'TAB', timesToPress: 8 }); + await executePerformShortcut({ driver, key: 'SPACE' }); + await executePerformShortcut({ driver, key: 'ARROW_DOWN' }); + await executePerformShortcut({ driver, key: 'ENTER' }); + await checkExtensionURL(driver, 'send'); + } }); }); diff --git a/e2e/serial/send/3_nft-sendFlow.test.ts b/e2e/serial/send/3_nft-sendFlow.test.ts deleted file mode 100644 index e0cf6443d6..0000000000 --- a/e2e/serial/send/3_nft-sendFlow.test.ts +++ /dev/null @@ -1,130 +0,0 @@ -import 'chromedriver'; -import 'geckodriver'; -import { WebDriver } from 'selenium-webdriver'; -import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from 'vitest'; - -import { - delayTime, - doNotFindElementByTestId, - findElementById, - findElementByIdAndClick, - findElementByTestId, - findElementByTestIdAndClick, - findElementByText, - findElementByTextAndClick, - getExtensionIdByName, - getRootUrl, - goToPopup, - importWalletFlow, - initDriverWithOptions, - querySelector, - shortenAddress, - takeScreenshotOnFailure, - transactionStatus, - waitAndClick, -} from '../../helpers'; -import { TEST_VARIABLES } from '../../walletVariables'; - -let rootURL = getRootUrl(); -let driver: WebDriver; - -const browser = process.env.BROWSER || 'chrome'; -const os = process.env.OS || 'mac'; - -beforeAll(async () => { - driver = await initDriverWithOptions({ - browser, - os, - }); - const extensionId = await getExtensionIdByName(driver, 'Rainbow'); - if (!extensionId) throw new Error('Extension not found'); - rootURL += extensionId; -}); - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -beforeEach(async (context: any) => { - context.driver = driver; -}); - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -afterEach(async (context: any) => { - await takeScreenshotOnFailure(context); -}); - -afterAll(() => driver.quit()); - -it('should be able import a wallet via pk', async () => { - await importWalletFlow(driver, rootURL, TEST_VARIABLES.SEED_WALLET.PK); -}); - -it('should be able import a second wallet via pk then switch back to wallet 1', async () => { - await importWalletFlow( - driver, - rootURL, - TEST_VARIABLES.PRIVATE_KEY_WALLET.SECRET, - true, - ); - await findElementByIdAndClick({ id: 'header-account-name-shuffle', driver }); - await findElementByTestIdAndClick({ id: 'wallet-account-1', driver }); - const accountName = await findElementById({ - id: 'header-account-name-shuffle', - driver, - }); - expect(await accountName.getText()).toBe( - shortenAddress(TEST_VARIABLES.SEED_WALLET.ADDRESS), - ); -}); - -it('should be able to go to setings', async () => { - await goToPopup(driver, rootURL); - await findElementByTestIdAndClick({ id: 'home-page-header-right', driver }); - await findElementByTestIdAndClick({ id: 'settings-link', driver }); -}); - -it('should be able to connect to hardhat and go to send flow', async () => { - const btn = await querySelector(driver, '[data-testid="connect-to-hardhat"]'); - await waitAndClick(btn, driver); - const button = await findElementByText(driver, 'Disconnect from Hardhat'); - expect(button).toBeTruthy(); - await findElementByTestIdAndClick({ id: 'navbar-button-with-back', driver }); -}); - -it('should be able to filter nfts and make selection on send flow', async () => { - await findElementByTestIdAndClick({ id: 'bottom-tab-nfts', driver }); - await delayTime('very-long'); - await delayTime('very-long'); - await findElementByTestIdAndClick({ id: 'header-link-send', driver }); - const input = await findElementByTestId({ id: 'to-address-input', driver }); - await input.sendKeys('rainbowwallet.eth'); - - await findElementByTestIdAndClick({ - id: 'input-wrapper-dropdown-token-input', - driver, - }); - const assetInput = await findElementByTestId({ id: 'token-input', driver }); - await assetInput.click(); - await assetInput.sendKeys('uni'); - const uniswapV3PositionsSection = await findElementByTestId({ - id: 'nfts-collection-section-Uniswap V3 Positions', - driver, - }); - const learnWeb3Badges = await doNotFindElementByTestId({ - id: 'nfts-collection-section-LearnWeb3 Badges', - driver, - }); - expect(uniswapV3PositionsSection).toBeTruthy(); - expect(learnWeb3Badges).toBeFalsy(); - - await uniswapV3PositionsSection.click(); - await findElementByTextAndClick(driver, '#521552'); -}); - -it('should be able to go to review on send flow', async () => { - await findElementByTestIdAndClick({ id: 'send-review-button', driver }); -}); - -it('should be able to send transaction on review on send flow', async () => { - await findElementByTestIdAndClick({ id: 'review-confirm-button', driver }); - const sendTransaction = await transactionStatus(); - expect(await sendTransaction).toBe('success'); -}); diff --git a/e2e/serial/send/4_nft-sendFlow.test.ts b/e2e/serial/send/4_nft-sendFlow.test.ts new file mode 100644 index 0000000000..e2a4ee83d3 --- /dev/null +++ b/e2e/serial/send/4_nft-sendFlow.test.ts @@ -0,0 +1,164 @@ +import 'chromedriver'; +import 'geckodriver'; +import { WebDriver } from 'selenium-webdriver'; +import { + afterAll, + afterEach, + beforeAll, + beforeEach, + describe, + expect, + it, +} from 'vitest'; + +import { + delayTime, + doNotFindElementByTestId, + findElementById, + findElementByIdAndClick, + findElementByTestId, + findElementByTestIdAndClick, + findElementByText, + findElementByTextAndClick, + getExtensionIdByName, + getRootUrl, + goToPopup, + importWalletFlow, + initDriverWithOptions, + querySelector, + shortenAddress, + takeScreenshotOnFailure, + transactionStatus, + waitAndClick, +} from '../../helpers'; +import { TEST_VARIABLES } from '../../walletVariables'; + +let rootURL = getRootUrl(); +let driver: WebDriver; + +const browser = process.env.BROWSER || 'chrome'; +const os = process.env.OS || 'mac'; + +describe.runIf(browser !== 'firefox')( + 'should be able to perform the nft send flow', + () => { + beforeAll(async () => { + driver = await initDriverWithOptions({ + browser, + os, + }); + const extensionId = await getExtensionIdByName(driver, 'Rainbow'); + if (!extensionId) throw new Error('Extension not found'); + rootURL += extensionId; + }); + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + beforeEach(async (context: any) => { + context.driver = driver; + }); + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + afterEach(async (context: any) => { + await takeScreenshotOnFailure(context); + }); + + afterAll(() => driver.quit()); + + it('should be able import a wallet via pk', async () => { + await importWalletFlow(driver, rootURL, TEST_VARIABLES.SEED_WALLET.PK); + }); + + it('should be able import a second wallet via pk then switch back to wallet 1', async () => { + await importWalletFlow( + driver, + rootURL, + TEST_VARIABLES.PRIVATE_KEY_WALLET.SECRET, + true, + ); + await findElementByIdAndClick({ + id: 'header-account-name-shuffle', + driver, + }); + await findElementByTestIdAndClick({ id: 'wallet-account-1', driver }); + const accountName = await findElementById({ + id: 'header-account-name-shuffle', + driver, + }); + expect(await accountName.getText()).toBe( + shortenAddress(TEST_VARIABLES.SEED_WALLET.ADDRESS), + ); + }); + + it('should be able to go to setings', async () => { + await goToPopup(driver, rootURL); + await findElementByTestIdAndClick({ + id: 'home-page-header-right', + driver, + }); + await findElementByTestIdAndClick({ id: 'settings-link', driver }); + }); + + it('should be able to connect to hardhat and go to send flow', async () => { + const btn = await querySelector( + driver, + '[data-testid="connect-to-hardhat"]', + ); + await waitAndClick(btn, driver); + const button = await findElementByText(driver, 'Disconnect from Hardhat'); + expect(button).toBeTruthy(); + await findElementByTestIdAndClick({ + id: 'navbar-button-with-back', + driver, + }); + }); + + it('should be able to filter nfts and make selection on send flow', async () => { + await findElementByTestIdAndClick({ id: 'bottom-tab-nfts', driver }); + await delayTime('very-long'); + await delayTime('very-long'); + await findElementByTestIdAndClick({ id: 'header-link-send', driver }); + const input = await findElementByTestId({ + id: 'to-address-input', + driver, + }); + await input.sendKeys('rainbowwallet.eth'); + + await findElementByTestIdAndClick({ + id: 'input-wrapper-dropdown-token-input', + driver, + }); + const assetInput = await findElementByTestId({ + id: 'token-input', + driver, + }); + await assetInput.click(); + await assetInput.sendKeys('uni'); + const uniswapV3PositionsSection = await findElementByTestId({ + id: 'nfts-collection-section-Uniswap V3 Positions', + driver, + }); + const learnWeb3Badges = await doNotFindElementByTestId({ + id: 'nfts-collection-section-LearnWeb3 Badges', + driver, + }); + expect(uniswapV3PositionsSection).toBeTruthy(); + expect(learnWeb3Badges).toBeFalsy(); + + await uniswapV3PositionsSection.click(); + await findElementByTextAndClick(driver, '#521552'); + }); + + it('should be able to go to review on send flow', async () => { + await findElementByTestIdAndClick({ id: 'send-review-button', driver }); + }); + + it('should be able to send transaction on review on send flow', async () => { + await findElementByTestIdAndClick({ + id: 'review-confirm-button', + driver, + }); + const sendTransaction = await transactionStatus(); + expect(await sendTransaction).toBe('success'); + }); + }, +); diff --git a/e2e/serial/send/4_sendNft.ts b/e2e/serial/send/4_sendNft.ts deleted file mode 100644 index e0cf6443d6..0000000000 --- a/e2e/serial/send/4_sendNft.ts +++ /dev/null @@ -1,130 +0,0 @@ -import 'chromedriver'; -import 'geckodriver'; -import { WebDriver } from 'selenium-webdriver'; -import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from 'vitest'; - -import { - delayTime, - doNotFindElementByTestId, - findElementById, - findElementByIdAndClick, - findElementByTestId, - findElementByTestIdAndClick, - findElementByText, - findElementByTextAndClick, - getExtensionIdByName, - getRootUrl, - goToPopup, - importWalletFlow, - initDriverWithOptions, - querySelector, - shortenAddress, - takeScreenshotOnFailure, - transactionStatus, - waitAndClick, -} from '../../helpers'; -import { TEST_VARIABLES } from '../../walletVariables'; - -let rootURL = getRootUrl(); -let driver: WebDriver; - -const browser = process.env.BROWSER || 'chrome'; -const os = process.env.OS || 'mac'; - -beforeAll(async () => { - driver = await initDriverWithOptions({ - browser, - os, - }); - const extensionId = await getExtensionIdByName(driver, 'Rainbow'); - if (!extensionId) throw new Error('Extension not found'); - rootURL += extensionId; -}); - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -beforeEach(async (context: any) => { - context.driver = driver; -}); - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -afterEach(async (context: any) => { - await takeScreenshotOnFailure(context); -}); - -afterAll(() => driver.quit()); - -it('should be able import a wallet via pk', async () => { - await importWalletFlow(driver, rootURL, TEST_VARIABLES.SEED_WALLET.PK); -}); - -it('should be able import a second wallet via pk then switch back to wallet 1', async () => { - await importWalletFlow( - driver, - rootURL, - TEST_VARIABLES.PRIVATE_KEY_WALLET.SECRET, - true, - ); - await findElementByIdAndClick({ id: 'header-account-name-shuffle', driver }); - await findElementByTestIdAndClick({ id: 'wallet-account-1', driver }); - const accountName = await findElementById({ - id: 'header-account-name-shuffle', - driver, - }); - expect(await accountName.getText()).toBe( - shortenAddress(TEST_VARIABLES.SEED_WALLET.ADDRESS), - ); -}); - -it('should be able to go to setings', async () => { - await goToPopup(driver, rootURL); - await findElementByTestIdAndClick({ id: 'home-page-header-right', driver }); - await findElementByTestIdAndClick({ id: 'settings-link', driver }); -}); - -it('should be able to connect to hardhat and go to send flow', async () => { - const btn = await querySelector(driver, '[data-testid="connect-to-hardhat"]'); - await waitAndClick(btn, driver); - const button = await findElementByText(driver, 'Disconnect from Hardhat'); - expect(button).toBeTruthy(); - await findElementByTestIdAndClick({ id: 'navbar-button-with-back', driver }); -}); - -it('should be able to filter nfts and make selection on send flow', async () => { - await findElementByTestIdAndClick({ id: 'bottom-tab-nfts', driver }); - await delayTime('very-long'); - await delayTime('very-long'); - await findElementByTestIdAndClick({ id: 'header-link-send', driver }); - const input = await findElementByTestId({ id: 'to-address-input', driver }); - await input.sendKeys('rainbowwallet.eth'); - - await findElementByTestIdAndClick({ - id: 'input-wrapper-dropdown-token-input', - driver, - }); - const assetInput = await findElementByTestId({ id: 'token-input', driver }); - await assetInput.click(); - await assetInput.sendKeys('uni'); - const uniswapV3PositionsSection = await findElementByTestId({ - id: 'nfts-collection-section-Uniswap V3 Positions', - driver, - }); - const learnWeb3Badges = await doNotFindElementByTestId({ - id: 'nfts-collection-section-LearnWeb3 Badges', - driver, - }); - expect(uniswapV3PositionsSection).toBeTruthy(); - expect(learnWeb3Badges).toBeFalsy(); - - await uniswapV3PositionsSection.click(); - await findElementByTextAndClick(driver, '#521552'); -}); - -it('should be able to go to review on send flow', async () => { - await findElementByTestIdAndClick({ id: 'send-review-button', driver }); -}); - -it('should be able to send transaction on review on send flow', async () => { - await findElementByTestIdAndClick({ id: 'review-confirm-button', driver }); - const sendTransaction = await transactionStatus(); - expect(await sendTransaction).toBe('success'); -}); diff --git a/e2e/serial/swap/2_swapFlow2.test.ts b/e2e/serial/swap/2_swapFlow2.test.ts index e0d593a484..11684c468c 100644 --- a/e2e/serial/swap/2_swapFlow2.test.ts +++ b/e2e/serial/swap/2_swapFlow2.test.ts @@ -1,7 +1,10 @@ import 'chromedriver'; import 'geckodriver'; +import { Contract } from '@ethersproject/contracts'; +import { StaticJsonRpcProvider } from '@ethersproject/providers'; import { WebDriver } from 'selenium-webdriver'; import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from 'vitest'; +import { erc20ABI } from 'wagmi'; import { ChainId } from '~/core/types/chains'; @@ -14,7 +17,6 @@ import { findElementByTestIdAndClick, findElementByText, getExtensionIdByName, - getOnchainBalance, getRootUrl, getTextFromText, goToPopup, @@ -22,7 +24,6 @@ import { initDriverWithOptions, querySelector, takeScreenshotOnFailure, - transactionStatus, typeOnTextInput, waitAndClick, waitUntilElementByTestIdIsPresent, @@ -142,11 +143,17 @@ it('should be able to go to review a unlock and swap', async () => { }); it('should be able to execute unlock and swap', async () => { - const balanceBefore = await getOnchainBalance( - WALLET_TO_USE_ADDRESS, + const provider = new StaticJsonRpcProvider('http://127.0.0.1:8545'); + await provider.ready; + await delayTime('short'); + const tokenContract = new Contract( SWAP_VARIABLES.USDC_MAINNET_ADDRESS, + erc20ABI, + provider, + ); + const usdcBalanceBeforeSwap = await tokenContract.balanceOf( + WALLET_TO_USE_ADDRESS, ); - console.log(`Balance before swap: ${balanceBefore}`); await findElementByTestIdAndClick({ id: 'swap-settings-navbar-button', @@ -177,25 +184,20 @@ it('should be able to execute unlock and swap', async () => { }); await delayTime('long'); await findElementByTestIdAndClick({ id: 'swap-review-execute', driver }); - const txnStatus = await transactionStatus(); - console.log(txnStatus); - expect(txnStatus).toBe('success'); - const balanceAfter = await getOnchainBalance( + await delayTime('very-long'); + await delayTime('very-long'); + const usdcBalanceAfterSwap = await tokenContract.balanceOf( WALLET_TO_USE_ADDRESS, - SWAP_VARIABLES.USDC_MAINNET_ADDRESS, ); - console.log('bal after: ', balanceAfter); const balanceDifference = subtract( - balanceBefore.toString(), - balanceAfter.toString(), + usdcBalanceBeforeSwap.toString(), + usdcBalanceAfterSwap.toString(), ); const usdcBalanceDifference = convertRawAmountToDecimalFormat( balanceDifference.toString(), 6, ); - console.log('usdc DIFF: ', usdcBalanceDifference); - expect(Number(usdcBalanceDifference)).toBe(50); }); diff --git a/package.json b/package.json index 5aa74a07c6..d5b6d6de19 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "// Build and zip": "", "bundle": "yarn build && yarn zip", "// Runs tests": "", - "anvil": "ETH_MAINNET_RPC=$(grep ETH_MAINNET_RPC .env | cut -d '=' -f2) && anvil --fork-url $ETH_MAINNET_RPC --fork-block-number 19000000", + "anvil": "ETH_MAINNET_RPC=$(grep ETH_MAINNET_RPC .env | cut -d '=' -f2) && anvil --fork-url $ETH_MAINNET_RPC", "anvil:optimism": "OPTIMISM_MAINNET_RPC=$(grep OPTIMISM_MAINNET_RPC .env | cut -d '=' -f2) && anvil --fork-url $OPTIMISM_MAINNET_RPC", "anvil:kill": "lsof -i :8545|tail -n +2|awk '{print $2}'|xargs -r kill -s SIGINT", "test": "./scripts/unit-tests.sh", @@ -185,7 +185,7 @@ "audit-ci": "6.3.0", "browserify": "17.0.0", "chalk": "5.3.0", - "chromedriver": "120.0.1", + "chromedriver": "121.0.2", "circular-dependency-plugin": "5.2.2", "copy-webpack-plugin": "11.0.0", "css-loader": "6.7.1", diff --git a/scripts/e2e-serial-tests.sh b/scripts/e2e-serial-tests.sh index 0b03b78344..7e50e82dc3 100755 --- a/scripts/e2e-serial-tests.sh +++ b/scripts/e2e-serial-tests.sh @@ -1,33 +1,18 @@ #!/bin/bash ANVIL_PORT=8545 -# Function to check if Anvil is running -is_anvil_running() { - if nc -z localhost $ANVIL_PORT; then - echo "Anvil is already running." - return 0 - else - echo "Anvil is not running." - return 1 - fi -} +# Launch anvil in the bg +yarn anvil:kill +yarn anvil --chain-id 1337 & +echo "Launching Anvil..." -# Launch Anvil if it's not already running -if ! is_anvil_running; then - yarn anvil:kill - yarn anvil --chain-id 1337 & - echo "Launching Anvil..." - - # Give it some time to boot - interval=5 - until nc -z localhost $ANVIL_PORT; do - sleep $interval - interval=$((interval * 2)) - done - echo "Anvil Launched..." -else - echo "Using existing Anvil instance." -fi +# Give it some time to boot +interval=5 +until nc -z localhost $ANVIL_PORT; do + sleep $interval + interval=$((interval * 2)) +done +echo "Anvil Launched..." # Run the tests and store the result echo "Running Tests..." @@ -36,5 +21,9 @@ yarn vitest e2e/serial/$1 --config ./e2e/serial/vitest.config.ts --reporter=verb # Store exit code TEST_RESULT=$? +# kill anvil +echo "Cleaning Up..." +yarn anvil:kill + # return the result of the tests exit "$TEST_RESULT" diff --git a/src/entries/popup/components/DropdownMenu/DropdownMenu.tsx b/src/entries/popup/components/DropdownMenu/DropdownMenu.tsx index 15b1859437..5444c537db 100644 --- a/src/entries/popup/components/DropdownMenu/DropdownMenu.tsx +++ b/src/entries/popup/components/DropdownMenu/DropdownMenu.tsx @@ -184,18 +184,12 @@ export const DropdownMenuContentBody = React.forwardRef< interface DropdownMenuLabelProps { children: ReactNode; align?: TextStyles['textAlign']; - testId?: string; } export const DropdownMenuLabel = (props: DropdownMenuLabelProps) => { - const { children, align = 'center', testId } = props; + const { children, align = 'center' } = props; return ( - + {children} diff --git a/src/entries/popup/components/InputMask/GweiInputMask/GweiInputMask.tsx b/src/entries/popup/components/InputMask/GweiInputMask/GweiInputMask.tsx index cdd04442e7..ce3479fef9 100644 --- a/src/entries/popup/components/InputMask/GweiInputMask/GweiInputMask.tsx +++ b/src/entries/popup/components/InputMask/GweiInputMask/GweiInputMask.tsx @@ -17,13 +17,11 @@ export const GweiInputMask = ({ variant, onChange, inputRef, - testId, }: { value: string; variant: 'surface' | 'bordered' | 'transparent'; onChange: (value: string) => void; inputRef: RefObject; - testId?: string; }) => { const [isFocused, setIsFocused] = useState(false); @@ -61,7 +59,6 @@ export const GweiInputMask = ({ } transition={transitions.bounce} onClick={onMaskClick} - testId={testId} > void; - testId?: string; }) => ( @@ -87,7 +85,6 @@ const GasLabel = ({ height="28px" variant="tinted" onClick={onClick} - testId={testId} /> )} @@ -428,7 +425,7 @@ export const CustomGasSheet = ({ zIndex={zIndexes.CUSTOM_GAS_SHEET} > - + {i18n.t('custom_gas.title')} @@ -482,7 +479,6 @@ export const CustomGasSheet = ({ height="28px" variant="transparent" onClick={showCurrentBaseFeeExplainer} - testId={'current-base-fee-explainer'} /> @@ -512,7 +508,6 @@ export const CustomGasSheet = ({ label={i18n.t('custom_gas.max_base_fee')} warning={maxBaseFeeWarning} onClick={showMaxBaseFeeExplainer} - testId={'max-base-fee-explainer'} /> @@ -522,7 +517,6 @@ export const CustomGasSheet = ({ value={maxBaseFee} variant="surface" onChange={updateCustomMaxBaseFee} - testId={'max-base-fee-input'} /> @@ -538,7 +532,6 @@ export const CustomGasSheet = ({ label={i18n.t('custom_gas.miner_tip')} warning={maxPriorityFeeWarning} onClick={showMaxPriorityFeeExplainer} - testId={'max-priority-fee-explainer'} /> @@ -547,7 +540,6 @@ export const CustomGasSheet = ({ value={maxPriorityFee} variant="surface" onChange={updateCustomMaxPriorityFee} - testId={'miner-tip-input'} /> @@ -775,7 +767,6 @@ export const CustomGasSheet = ({ variant="flat" onClick={setCustomGas} tabIndex={0} - testId={'set-gas-button'} > {i18n.t('custom_gas.set')} diff --git a/src/entries/popup/components/TransactionFee/TransactionFee.tsx b/src/entries/popup/components/TransactionFee/TransactionFee.tsx index 4e9f272461..cd2463afd6 100644 --- a/src/entries/popup/components/TransactionFee/TransactionFee.tsx +++ b/src/entries/popup/components/TransactionFee/TransactionFee.tsx @@ -236,7 +236,6 @@ function Fee({ borderColor="fillSecondary" style={{ height: 28, width: 28 }} onClick={openCustomGasSheet} - testId={'custom-gas-menu'} > - - - {menuTrigger} - - + + {menuTrigger} + + + {i18n.t('transaction_fee.title')} + + onSpeedChanged(speed as GasSpeed)} > - - {i18n.t('transaction_fee.title')} - - - onSpeedChanged(speed as GasSpeed)} - > - - - - - + + + + ); }); diff --git a/yarn.lock b/yarn.lock index 6c3d28d735..6f5c846c17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5723,7 +5723,7 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.12.0.tgz#ce1c9d143389679e253b314241ea9aa5cec980d3" integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== -axios@0.26.1, axios@1.6.1, axios@^1.3.4, axios@^1.6.0: +axios@0.26.1, axios@1.6.1, axios@^1.3.4, axios@^1.6.0, axios@^1.6.5: version "1.6.1" resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.1.tgz#76550d644bf0a2d469a01f9244db6753208397d7" integrity sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g== @@ -6468,13 +6468,13 @@ chrome-trace-event@^1.0.2: resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== -chromedriver@120.0.1: - version "120.0.1" - resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-120.0.1.tgz#71604e46a463ab133c3b8b7269dba8ac8fd82b43" - integrity sha512-ETTJlkibcAmvoKsaEoq2TFqEsJw18N0O9gOQZX6Uv/XoEiOV8p+IZdidMeIRYELWJIgCZESvlOx5d1QVnB4v0w== +chromedriver@121.0.2: + version "121.0.2" + resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-121.0.2.tgz#208909a61e9d510913107ea6faf34bcdd72cdced" + integrity sha512-58MUSCEE3oB3G3Y/Jo3URJ2Oa1VLHcVBufyYt7vNfGrABSJm7ienQLF9IQ8LPDlPVgLUXt2OBfggK3p2/SlEBg== dependencies: "@testim/chrome-version" "^1.1.4" - axios "^1.6.0" + axios "^1.6.5" compare-versions "^6.1.0" extract-zip "^2.0.1" https-proxy-agent "^5.0.1"