From 821b49d53eb4e157dd8fabf93c6049b28bdc30dc Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Wed, 6 Nov 2024 12:14:00 +0000 Subject: [PATCH 01/19] feat: Enable redesigned transaction confirmations for all users --- app/scripts/migrations/132.test.ts | 54 ++++++++++++++++++++++++++++++ app/scripts/migrations/132.ts | 49 +++++++++++++++++++++++++++ app/scripts/migrations/index.js | 1 + 3 files changed, 104 insertions(+) create mode 100644 app/scripts/migrations/132.test.ts create mode 100644 app/scripts/migrations/132.ts diff --git a/app/scripts/migrations/132.test.ts b/app/scripts/migrations/132.test.ts new file mode 100644 index 000000000000..56cf100139ef --- /dev/null +++ b/app/scripts/migrations/132.test.ts @@ -0,0 +1,54 @@ +import { migrate, version } from './132'; + +const oldVersion = 131; + +describe('migration #132', () => { + it('updates the version metadata', async () => { + const oldStorage = { + meta: { version: oldVersion }, + data: {}, + }; + + const newStorage = await migrate(oldStorage); + + expect(newStorage.meta).toStrictEqual({ version }); + }); + + it('does nothing if no preferences controller state is set', async () => { + const oldState = { + OtherController: {}, + }; + + const transformedState = await migrate({ + meta: { version: oldVersion }, + data: oldState, + }); + + expect(transformedState.data).toEqual(oldState); + }); + + it('changes property to true if migration runs', async () => { + const oldState = { + PreferencesController: { + preferences: { + redesignedTransactionsEnabled: false, + }, + }, + }; + + const expectedState = { + PreferencesController: { + preferences: { + redesignedTransactionsEnabled: true, + }, + }, + }; + + const transformedState = await migrate({ + meta: { version: oldVersion }, + data: oldState, + }); + + expect(transformedState.data).toEqual(expectedState); + }); +}); diff --git a/app/scripts/migrations/132.ts b/app/scripts/migrations/132.ts new file mode 100644 index 000000000000..428517351738 --- /dev/null +++ b/app/scripts/migrations/132.ts @@ -0,0 +1,49 @@ +import { isObject } from '@metamask/utils'; +import { cloneDeep } from 'lodash'; + +type VersionedData = { + meta: { version: number }; + data: Record; +}; + +export const version = 132; + +/** + * This migration sets `redesignedTransactionsEnabled` as true by default in preferences in PreferencesController. + * + * @param originalVersionedData - Versioned MetaMask extension state, exactly what we persist to dist. + * @param originalVersionedData.meta - State metadata. + * @param originalVersionedData.meta.version - The current state version. + * @param originalVersionedData.data - The persisted MetaMask state, keyed by controller. + * @returns Updated versioned MetaMask extension state. + */ +export async function migrate( + originalVersionedData: VersionedData, +): Promise { + const versionedData = cloneDeep(originalVersionedData); + versionedData.meta.version = version; + transformState(versionedData.data); + return versionedData; +} + +function transformState( + state: Record, +): Record { + const preferencesControllerState = state?.PreferencesController as + | Record + | undefined; + + const preferences = preferencesControllerState?.preferences as + | Record + | undefined; + + if (isObject(preferencesControllerState) && isObject(preferences)) { + // `redesignedTransactionsEnabled` was previously set to `false` by default + // in `124.ts` + if (preferences.redesignedTransactionsEnabled === false) { + preferences.redesignedTransactionsEnabled = true; + } + } + + return state; +} diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index d2c63eb2e35c..6cde292ba55d 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -152,6 +152,7 @@ const migrations = [ require('./129'), require('./130'), require('./131'), + require('./132'), ]; export default migrations; From 16bd2ea0feea00ead5d935a96f6ac1f2e2705b50 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Wed, 6 Nov 2024 14:50:36 +0000 Subject: [PATCH 02/19] fix: e2e tests --- test/e2e/helpers.js | 36 ++++++++++++++++++ test/e2e/json-rpc/eth_sendTransaction.spec.js | 3 ++ test/e2e/json-rpc/switchEthereumChain.spec.js | 10 +++++ .../e2e/snaps/test-snap-txinsights-v2.spec.js | 5 +++ test/e2e/snaps/test-snap-txinsights.spec.js | 5 +++ .../account/snap-account-transfers.spec.ts | 21 ++++++++++- .../contract-interactions.spec.js | 8 +++- .../dapp-interactions/dapp-tx-edit.spec.js | 12 ++++++ .../failing-contract.spec.js | 12 ++++++ test/e2e/tests/network/network-error.spec.js | 5 +++ .../petnames/petnames-transactions.spec.js | 9 +++++ .../ppom-blockaid-alert-simple-send.spec.js | 8 +++- .../batch-txs-per-dapp-diff-network.spec.js | 3 ++ .../batch-txs-per-dapp-extra-tx.spec.js | 3 ++ .../batch-txs-per-dapp-same-network.spec.js | 3 ++ .../dapp1-send-dapp2-signTypedData.spec.js | 10 +++++ ...-switch-dapp2-eth-request-accounts.spec.js | 6 ++- .../dapp1-switch-dapp2-send.spec.js | 12 ++++++ ...multi-dapp-sendTx-revokePermission.spec.js | 3 ++ .../multiple-networks-dapps-txs.spec.js | 3 ++ .../request-queuing/switch-network.spec.js | 6 +++ test/e2e/tests/request-queuing/ui.spec.js | 16 ++++++++ .../metamask-responsive-ui.spec.js | 8 ++++ .../tests/settings/4byte-directory.spec.js | 12 ++++++ test/e2e/tests/settings/show-hex-data.spec.js | 6 +++ .../tokens/custom-token-add-approve.spec.js | 23 +++++++++++- .../tokens/custom-token-send-transfer.spec.js | 17 +++++++++ .../tokens/increase-token-allowance.spec.js | 5 +++ .../tokens/nft/erc1155-interaction.spec.js | 22 +++++++++++ .../tokens/nft/erc721-interaction.spec.js | 37 +++++++++++++++++++ test/e2e/tests/tokens/nft/send-nft.spec.js | 7 ++++ .../tests/transaction/change-assets.spec.js | 22 +++++++++++ .../tests/transaction/edit-gas-fee.spec.js | 18 +++++++++ .../tests/transaction/gas-estimates.spec.js | 32 ++++++++++++++++ .../transaction/multiple-transactions.spec.js | 12 ++++++ .../transaction/navigate-transactions.spec.js | 33 ++++++++++++++++- test/e2e/tests/transaction/send-edit.spec.js | 7 ++++ test/e2e/tests/transaction/send-eth.spec.js | 22 +++++++++++ .../transaction/send-hex-address.spec.js | 13 +++++++ .../e2e/tests/transaction/simple-send.spec.ts | 12 +++++- .../experimental-tab.component.tsx | 1 + 41 files changed, 500 insertions(+), 8 deletions(-) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 19c9aeecd6c7..444caa3130e1 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -860,6 +860,41 @@ async function tempToggleSettingRedesignedConfirmations(driver) { ); } +/** + * Rather than using the FixtureBuilder#withPreferencesController to set the setting + * we need to manually set the setting because the migration #132 overrides this. + * We should be able to remove this when we delete the redesignedTransactionsEnabled setting. + * + * @param driver + */ +async function tempToggleSettingRedesignedTransactionConfirmations(driver) { + // Ensure we are on the extension window + await driver.switchToWindowWithTitle(WINDOW_TITLES.ExtensionInFullScreenView); + + // Open settings menu button + await driver.clickElement('[data-testid="account-options-menu-button"]'); + + // fix race condition with mmi build + if (process.env.MMI) { + await driver.waitForSelector('[data-testid="global-menu-mmi-portfolio"]'); + } + + // Click settings from dropdown menu + await driver.clickElement('[data-testid="global-menu-settings"]'); + + // Click Experimental tab + const experimentalTabRawLocator = { + text: 'Experimental', + tag: 'div', + }; + await driver.clickElement(experimentalTabRawLocator); + + // Click redesigned transactions toggle + await driver.clickElement( + '[data-testid="toggle-redesigned-transactions-container"]', + ); +} + /** * Opens the account options menu safely, handling potential race conditions * with the MMI build. @@ -928,6 +963,7 @@ module.exports = { editGasFeeForm, clickNestedButton, tempToggleSettingRedesignedConfirmations, + tempToggleSettingRedesignedTransactionConfirmations, openMenuSafe, sentryRegEx, }; diff --git a/test/e2e/json-rpc/eth_sendTransaction.spec.js b/test/e2e/json-rpc/eth_sendTransaction.spec.js index c17421cca042..ed740d17bfc1 100644 --- a/test/e2e/json-rpc/eth_sendTransaction.spec.js +++ b/test/e2e/json-rpc/eth_sendTransaction.spec.js @@ -4,6 +4,7 @@ const { unlockWallet, WINDOW_TITLES, generateGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); @@ -68,6 +69,8 @@ describe('eth_sendTransaction', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // eth_sendTransaction await driver.openNewPage(`http://127.0.0.1:8080`); const request = JSON.stringify({ diff --git a/test/e2e/json-rpc/switchEthereumChain.spec.js b/test/e2e/json-rpc/switchEthereumChain.spec.js index 60ba4eb9aacb..b0cdb941d023 100644 --- a/test/e2e/json-rpc/switchEthereumChain.spec.js +++ b/test/e2e/json-rpc/switchEthereumChain.spec.js @@ -8,8 +8,10 @@ const { unlockWallet, switchToNotificationWindow, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); +const { PAGES } = require('../webdriver/driver'); const { isManifestV3 } = require('../../../shared/modules/mv3.utils'); describe('Switch Ethereum Chain for two dapps', function () { @@ -253,6 +255,10 @@ describe('Switch Ethereum Chain for two dapps', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + await driver.navigate(PAGES.HOME); + // Open settings menu button const accountOptionsMenuSelector = '[data-testid="account-options-menu-button"]'; @@ -385,6 +391,10 @@ describe('Switch Ethereum Chain for two dapps', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + await driver.navigate(PAGES.HOME); + // Open settings menu button const accountOptionsMenuSelector = '[data-testid="account-options-menu-button"]'; diff --git a/test/e2e/snaps/test-snap-txinsights-v2.spec.js b/test/e2e/snaps/test-snap-txinsights-v2.spec.js index a249e9daa79b..27188b2c9c9d 100644 --- a/test/e2e/snaps/test-snap-txinsights-v2.spec.js +++ b/test/e2e/snaps/test-snap-txinsights-v2.spec.js @@ -3,8 +3,10 @@ const { withFixtures, unlockWallet, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); +const { PAGES } = require('../webdriver/driver'); const { TEST_SNAPS_WEBSITE_URL } = require('./enums'); describe('Test Snap TxInsights-v2', function () { @@ -18,6 +20,9 @@ describe('Test Snap TxInsights-v2', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + // navigate to test snaps page and connect await driver.openNewPage(TEST_SNAPS_WEBSITE_URL); diff --git a/test/e2e/snaps/test-snap-txinsights.spec.js b/test/e2e/snaps/test-snap-txinsights.spec.js index 21feafd06cb9..f64a5660ccfc 100644 --- a/test/e2e/snaps/test-snap-txinsights.spec.js +++ b/test/e2e/snaps/test-snap-txinsights.spec.js @@ -3,8 +3,10 @@ const { withFixtures, unlockWallet, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); +const { PAGES } = require('../webdriver/driver'); const { TEST_SNAPS_WEBSITE_URL } = require('./enums'); describe('Test Snap TxInsights', function () { @@ -18,6 +20,9 @@ describe('Test Snap TxInsights', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + // navigate to test snaps page and connect await driver.driver.get(TEST_SNAPS_WEBSITE_URL); diff --git a/test/e2e/tests/account/snap-account-transfers.spec.ts b/test/e2e/tests/account/snap-account-transfers.spec.ts index ee2466cf28e1..82b19f90817e 100644 --- a/test/e2e/tests/account/snap-account-transfers.spec.ts +++ b/test/e2e/tests/account/snap-account-transfers.spec.ts @@ -2,11 +2,12 @@ import { Suite } from 'mocha'; import { multipleGanacheOptions, PRIVATE_KEY_TWO, + tempToggleSettingRedesignedTransactionConfirmations, WINDOW_TITLES, withFixtures, } from '../../helpers'; import { DEFAULT_FIXTURE_ACCOUNT } from '../../constants'; -import { Driver } from '../../webdriver/driver'; +import { Driver, PAGES } from '../../webdriver/driver'; import { Ganache } from '../../seeder/ganache'; import AccountListPage from '../../page-objects/pages/account-list-page'; import FixtureBuilder from '../../fixture-builder'; @@ -33,6 +34,12 @@ describe('Snap Account Transfers @no-mmi', function (this: Suite) { ganacheServer?: Ganache; }) => { await loginWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await installSnapSimpleKeyring(driver); const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); @@ -81,6 +88,12 @@ describe('Snap Account Transfers @no-mmi', function (this: Suite) { ganacheServer?: Ganache; }) => { await loginWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await installSnapSimpleKeyring(driver, false); const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); @@ -131,6 +144,12 @@ describe('Snap Account Transfers @no-mmi', function (this: Suite) { ganacheServer?: Ganache; }) => { await loginWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await installSnapSimpleKeyring(driver, false); const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); diff --git a/test/e2e/tests/dapp-interactions/contract-interactions.spec.js b/test/e2e/tests/dapp-interactions/contract-interactions.spec.js index e7de105e0112..2c6bc07be695 100644 --- a/test/e2e/tests/dapp-interactions/contract-interactions.spec.js +++ b/test/e2e/tests/dapp-interactions/contract-interactions.spec.js @@ -7,8 +7,9 @@ const { WINDOW_TITLES, locateAccountBalanceDOM, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); - +const { PAGES } = require('../../webdriver/driver'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); @@ -32,6 +33,11 @@ describe('Deploy contract and call contract methods', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // deploy contract await openDapp(driver, contractAddress); diff --git a/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js b/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js index 131ebdf4ee73..2ff6fc525358 100644 --- a/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js +++ b/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js @@ -1,9 +1,11 @@ +const { PAGES } = require('../../webdriver/driver'); const { defaultGanacheOptions, logInWithBalanceValidation, openDapp, WINDOW_TITLES, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); @@ -27,6 +29,11 @@ describe('Editing confirmations of dapp initiated contract interactions', functi ); await logInWithBalanceValidation(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // deploy contract await openDapp(driver, contractAddress); // wait for deployed contract, calls and confirms a contract method where ETH is sent @@ -59,6 +66,11 @@ describe('Editing confirmations of dapp initiated contract interactions', functi async ({ driver }) => { await logInWithBalanceValidation(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openDapp(driver); await driver.clickElement('#sendButton'); diff --git a/test/e2e/tests/dapp-interactions/failing-contract.spec.js b/test/e2e/tests/dapp-interactions/failing-contract.spec.js index 5770adb1a3b9..90419ba6d0be 100644 --- a/test/e2e/tests/dapp-interactions/failing-contract.spec.js +++ b/test/e2e/tests/dapp-interactions/failing-contract.spec.js @@ -6,9 +6,11 @@ const { WINDOW_TITLES, generateGanacheOptions, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); +const { PAGES } = require('../../webdriver/driver'); describe('Failing contract interaction ', function () { const smartContract = SMART_CONTRACTS.FAILING; @@ -29,6 +31,11 @@ describe('Failing contract interaction ', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openDapp(driver, contractAddress); let windowHandles = await driver.getAllWindowHandles(); const extension = windowHandles[0]; @@ -93,6 +100,11 @@ describe('Failing contract interaction on non-EIP1559 network', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openDapp(driver, contractAddress); let windowHandles = await driver.getAllWindowHandles(); const extension = windowHandles[0]; diff --git a/test/e2e/tests/network/network-error.spec.js b/test/e2e/tests/network/network-error.spec.js index 4d45734edf77..b85430420d1a 100644 --- a/test/e2e/tests/network/network-error.spec.js +++ b/test/e2e/tests/network/network-error.spec.js @@ -4,8 +4,10 @@ const { logInWithBalanceValidation, openActionMenuAndStartSendFlow, generateGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); +const { PAGES } = require('../../webdriver/driver'); const { GAS_API_BASE_URL } = require('../../../../shared/constants/swaps'); describe('Gas API fallback', function () { @@ -58,6 +60,9 @@ describe('Gas API fallback', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + await openActionMenuAndStartSendFlow(driver); await driver.fill( 'input[placeholder="Enter public address (0x) or domain name"]', diff --git a/test/e2e/tests/petnames/petnames-transactions.spec.js b/test/e2e/tests/petnames/petnames-transactions.spec.js index cc19e44a55eb..b2249feb1d66 100644 --- a/test/e2e/tests/petnames/petnames-transactions.spec.js +++ b/test/e2e/tests/petnames/petnames-transactions.spec.js @@ -5,8 +5,10 @@ const { unlockWallet, defaultGanacheOptions, openActionMenuAndStartSendFlow, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); +const { PAGES } = require('../../webdriver/driver'); const { expectName, focusTestDapp, @@ -49,6 +51,10 @@ describe('Petnames - Transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + await openDapp(driver); await createDappSendTransaction(driver); await switchToNotificationWindow(driver, 3); @@ -94,6 +100,9 @@ describe('Petnames - Transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + await createWalletSendTransaction(driver, ADDRESS_MOCK); await expectName(driver, ABBREVIATED_ADDRESS_MOCK, false); diff --git a/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js b/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js index 9e904af6513e..cad3c9aadafa 100644 --- a/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js +++ b/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js @@ -1,12 +1,13 @@ const { strict: assert } = require('assert'); const FixtureBuilder = require('../../fixture-builder'); - +const { PAGES } = require('../../webdriver/driver'); const { defaultGanacheOptions, withFixtures, sendScreenToConfirmScreen, logInWithBalanceValidation, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { mockMultiNetworkBalancePolling, @@ -209,6 +210,11 @@ describe('Simple Send Security Alert - Blockaid @no-mmi', function () { async ({ driver }) => { await logInWithBalanceValidation(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await sendScreenToConfirmScreen( driver, '0xB8c77482e45F1F44dE1745F52C74426C631bDD52', diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js index deb189404fa8..23c1c27ea222 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js @@ -9,6 +9,7 @@ const { WINDOW_TITLES, defaultGanacheOptions, largeDelayMs, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { PAGES } = require('../../webdriver/driver'); @@ -40,6 +41,8 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks', fun async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Navigate to extension home screen await driver.navigate(PAGES.HOME); diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js index 265b28d0f56d..ea163ae6c9cd 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js @@ -9,6 +9,7 @@ const { unlockWallet, WINDOW_TITLES, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { PAGES } = require('../../webdriver/driver'); @@ -40,6 +41,8 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks', fun async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Navigate to extension home screen await driver.navigate(PAGES.HOME); diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js index c30d6a73c063..98b125cc1116 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js @@ -10,6 +10,7 @@ const { WINDOW_TITLES, defaultGanacheOptions, largeDelayMs, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { PAGES } = require('../../webdriver/driver'); @@ -46,6 +47,8 @@ describe('Request Queuing for Multiple Dapps and Txs on same networks', function async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Navigate to extension home screen await driver.navigate(PAGES.HOME); diff --git a/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js b/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js index 5814d8a60a2b..e2e53e4f51ca 100644 --- a/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js @@ -10,7 +10,9 @@ const { tempToggleSettingRedesignedConfirmations, WINDOW_TITLES, largeDelayMs, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); +const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { it('should queue signTypedData tx after eth_sendTransaction confirmation and signTypedData confirmation should target the correct network after eth_sendTransaction is confirmed @no-mmi', async function () { @@ -46,6 +48,14 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { await unlockWallet(driver); await tempToggleSettingRedesignedConfirmations(driver); + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open and connect Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js index 7a212533de4b..d37be3d483ac 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js @@ -1,5 +1,4 @@ const { strict: assert } = require('assert'); - const FixtureBuilder = require('../../fixture-builder'); const { withFixtures, @@ -10,7 +9,9 @@ const { regularDelayMs, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); +const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing Dapp 1 Send Tx -> Dapp 2 Request Accounts Tx', function () { it('should queue `eth_requestAccounts` requests when the requesting dapp does not already have connected accounts', async function () { @@ -40,6 +41,9 @@ describe('Request Queuing Dapp 1 Send Tx -> Dapp 2 Request Accounts Tx', functio async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + // Open Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js index c98e0eb229c6..650d39089d3a 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js @@ -7,7 +7,9 @@ const { unlockWallet, WINDOW_TITLES, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); +const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { it('should queue send tx after switch network confirmation and transaction should target the correct network after switch is confirmed', async function () { @@ -42,6 +44,11 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp One await openDapp(driver, undefined, DAPP_URL); @@ -195,6 +202,11 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js index 06d232635131..d75c9c2ca1ff 100644 --- a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js +++ b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js @@ -7,6 +7,7 @@ const { DAPP_ONE_URL, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { PAGES } = require('../../webdriver/driver'); @@ -38,6 +39,8 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks revok async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Navigate to extension home screen await driver.navigate(PAGES.HOME); diff --git a/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js b/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js index 38fe1d7204d2..b2df1a954d83 100644 --- a/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js +++ b/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js @@ -8,6 +8,7 @@ const { WINDOW_TITLES, defaultGanacheOptions, largeDelayMs, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { PAGES } = require('../../webdriver/driver'); @@ -39,6 +40,8 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks.', fu async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Navigate to extension home screen await driver.navigate(PAGES.HOME); diff --git a/test/e2e/tests/request-queuing/switch-network.spec.js b/test/e2e/tests/request-queuing/switch-network.spec.js index 5949800f9840..315f80df08f9 100644 --- a/test/e2e/tests/request-queuing/switch-network.spec.js +++ b/test/e2e/tests/request-queuing/switch-network.spec.js @@ -7,6 +7,7 @@ const { regularDelayMs, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { PAGES } = require('../../webdriver/driver'); @@ -37,6 +38,11 @@ describe('Request Queuing Switch Network on Dapp Send Tx while on different netw async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open dapp await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/ui.spec.js b/test/e2e/tests/request-queuing/ui.spec.js index b857d4307d5b..3b0ad9929cd8 100644 --- a/test/e2e/tests/request-queuing/ui.spec.js +++ b/test/e2e/tests/request-queuing/ui.spec.js @@ -14,6 +14,7 @@ const { tempToggleSettingRedesignedConfirmations, veryLargeDelayMs, DAPP_TWO_URL, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { PAGES } = require('../../webdriver/driver'); const { @@ -216,6 +217,8 @@ describe('Request-queue UI changes', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Navigate to extension home screen await driver.navigate(PAGES.HOME); @@ -288,6 +291,8 @@ describe('Request-queue UI changes', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Navigate to extension home screen await driver.navigate(PAGES.HOME); @@ -408,6 +413,8 @@ describe('Request-queue UI changes', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Navigate to extension home screen await driver.navigate(PAGES.HOME); @@ -579,6 +586,8 @@ describe('Request-queue UI changes', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Open the first dapp which starts on chain '0x539 await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); @@ -656,6 +665,11 @@ describe('Request-queue UI changes', function () { // Navigate to extension home screen await driver.navigate(PAGES.HOME); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open the first dapp await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); @@ -722,6 +736,8 @@ describe('Request-queue UI changes', function () { async ({ driver, ganacheServer, secondaryGanacheServer }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Navigate to extension home screen await driver.navigate(PAGES.HOME); diff --git a/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js b/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js index 958854a5252c..33f1915f300f 100644 --- a/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js +++ b/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js @@ -6,8 +6,10 @@ const { logInWithBalanceValidation, openActionMenuAndStartSendFlow, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); +const { PAGES } = require('../../webdriver/driver'); describe('MetaMask Responsive UI', function () { it('Creating a new wallet @no-mmi', async function () { @@ -21,6 +23,7 @@ describe('MetaMask Responsive UI', function () { }, async ({ driver }) => { await driver.navigate(); + // agree to terms of use await driver.clickElement('[data-testid="onboarding-terms-checkbox"]'); @@ -129,6 +132,11 @@ describe('MetaMask Responsive UI', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Send ETH from inside MetaMask // starts to send a transaction await openActionMenuAndStartSendFlow(driver); diff --git a/test/e2e/tests/settings/4byte-directory.spec.js b/test/e2e/tests/settings/4byte-directory.spec.js index 483ff1e0149a..a9d1916d692f 100644 --- a/test/e2e/tests/settings/4byte-directory.spec.js +++ b/test/e2e/tests/settings/4byte-directory.spec.js @@ -6,8 +6,10 @@ const { unlockWallet, withFixtures, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); +const { PAGES } = require('../../webdriver/driver'); describe('4byte setting', function () { it('makes a call to 4byte when the setting is on', async function () { @@ -27,6 +29,11 @@ describe('4byte setting', function () { ); await logInWithBalanceValidation(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // deploy contract await openDapp(driver, contractAddress); @@ -63,6 +70,11 @@ describe('4byte setting', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // goes to the settings screen await openMenuSafe(driver); await driver.clickElement({ text: 'Settings', tag: 'div' }); diff --git a/test/e2e/tests/settings/show-hex-data.spec.js b/test/e2e/tests/settings/show-hex-data.spec.js index 4bef79ca0a3b..767c55decfb9 100644 --- a/test/e2e/tests/settings/show-hex-data.spec.js +++ b/test/e2e/tests/settings/show-hex-data.spec.js @@ -2,8 +2,10 @@ const { defaultGanacheOptions, withFixtures, logInWithBalanceValidation, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); +const { PAGES } = require('../../webdriver/driver'); const selectors = { accountOptionsMenu: '[data-testid="account-options-menu-button"]', @@ -78,6 +80,10 @@ describe('Check the toggle for hex data', function () { }, async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + await toggleHexData(driver); await clickOnLogo(driver); await sendTransactionAndVerifyHexData(driver); diff --git a/test/e2e/tests/tokens/custom-token-add-approve.spec.js b/test/e2e/tests/tokens/custom-token-add-approve.spec.js index 4e85aae76fd6..a01a96692ec9 100644 --- a/test/e2e/tests/tokens/custom-token-add-approve.spec.js +++ b/test/e2e/tests/tokens/custom-token-add-approve.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); - +const { PAGES } = require('../../webdriver/driver'); const { clickNestedButton, defaultGanacheOptions, @@ -8,6 +8,7 @@ const { openDapp, WINDOW_TITLES, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); @@ -84,6 +85,11 @@ describe('Create token, approve token and approve token without gas', function ( ); await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // create token await openDapp(driver, contractAddress); @@ -182,6 +188,11 @@ describe('Create token, approve token and approve token without gas', function ( ); await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // create token await openDapp(driver, contractAddress); @@ -317,6 +328,11 @@ describe('Create token, approve token and approve token without gas', function ( ); await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // create token await openDapp(driver, contractAddress); const windowHandles = await driver.getAllWindowHandles(); @@ -398,6 +414,11 @@ describe('Create token, approve token and approve token without gas', function ( ); await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openDapp(driver, contractAddress); const windowHandles = await driver.getAllWindowHandles(); const extension = windowHandles[0]; diff --git a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js index 40b1872011bd..248dd10e1bdd 100644 --- a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js +++ b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js @@ -8,9 +8,11 @@ const { editGasFeeForm, WINDOW_TITLES, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); +const { PAGES } = require('../../webdriver/driver'); const recipientAddress = '0x2f318C334780961FB129D2a6c30D0763d9a5C970'; @@ -28,6 +30,11 @@ describe('Transfer custom tokens @no-mmi', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // go to custom tokens view on extension, perform send tokens await driver.clickElement({ css: '[data-testid="multichain-token-list-item-value"]', @@ -115,6 +122,11 @@ describe('Transfer custom tokens @no-mmi', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // transfer token from dapp await openDapp(driver, contractAddress); await driver.clickElement({ text: 'Transfer Tokens', tag: 'button' }); @@ -174,6 +186,11 @@ describe('Transfer custom tokens @no-mmi', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // transfer token from dapp await openDapp(driver, contractAddress); await driver.clickElement({ diff --git a/test/e2e/tests/tokens/increase-token-allowance.spec.js b/test/e2e/tests/tokens/increase-token-allowance.spec.js index 7df956e9df43..218e55aa1db9 100644 --- a/test/e2e/tests/tokens/increase-token-allowance.spec.js +++ b/test/e2e/tests/tokens/increase-token-allowance.spec.js @@ -10,8 +10,10 @@ const { ACCOUNT_2, WINDOW_TITLES, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); +const { PAGES } = require('../../webdriver/driver'); const DEFAULT_TEST_DAPP_INCREASE_ALLOWANCE_SPENDING_CAP = '1'; @@ -38,6 +40,9 @@ describe('Increase Token Allowance', function () { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + const contractAddress = await contractRegistry.getContractAddress( smartContract, ); diff --git a/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js b/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js index c635d465353a..b690492ac49d 100644 --- a/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js +++ b/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js @@ -7,9 +7,11 @@ const { unlockWallet, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); +const { PAGES } = require('../../../webdriver/driver'); describe('ERC1155 NFTs testdapp interaction', function () { const smartContract = SMART_CONTRACTS.ERC1155; @@ -38,6 +40,11 @@ describe('ERC1155 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -118,6 +125,11 @@ describe('ERC1155 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openDapp(driver, contract); await driver.fill('#batchTransferTokenIds', '1, 2, 3'); @@ -170,6 +182,11 @@ describe('ERC1155 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Create a set approval for all erc1155 token request in test dapp await openDapp(driver, contract); await driver.clickElement('#setApprovalForAllERC1155Button'); @@ -254,6 +271,11 @@ describe('ERC1155 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Create a revoke approval for all erc1155 token request in test dapp await openDapp(driver, contract); await driver.clickElement('#revokeERC1155Button'); diff --git a/test/e2e/tests/tokens/nft/erc721-interaction.spec.js b/test/e2e/tests/tokens/nft/erc721-interaction.spec.js index 35750bae6d2c..35c2e9b86685 100644 --- a/test/e2e/tests/tokens/nft/erc721-interaction.spec.js +++ b/test/e2e/tests/tokens/nft/erc721-interaction.spec.js @@ -6,9 +6,11 @@ const { WINDOW_TITLES, defaultGanacheOptions, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); +const { PAGES } = require('../../../webdriver/driver'); describe('ERC721 NFTs testdapp interaction', function () { const smartContract = SMART_CONTRACTS.NFTS; @@ -28,6 +30,11 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -91,6 +98,11 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -212,6 +224,11 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -310,6 +327,11 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -357,6 +379,11 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -424,6 +451,11 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -490,6 +522,11 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); diff --git a/test/e2e/tests/tokens/nft/send-nft.spec.js b/test/e2e/tests/tokens/nft/send-nft.spec.js index 35585bbaf2ea..eb44466d20ef 100644 --- a/test/e2e/tests/tokens/nft/send-nft.spec.js +++ b/test/e2e/tests/tokens/nft/send-nft.spec.js @@ -4,9 +4,11 @@ const { logInWithBalanceValidation, unlockWallet, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); +const { PAGES } = require('../../../webdriver/driver'); describe('Send NFT', function () { const smartContract = SMART_CONTRACTS.NFTS; @@ -24,6 +26,11 @@ describe('Send NFT', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Fill the send NFT form and confirm the transaction await driver.clickElement('[data-testid="account-overview__nfts-tab"]'); await driver.clickElement('.nft-item__container'); diff --git a/test/e2e/tests/transaction/change-assets.spec.js b/test/e2e/tests/transaction/change-assets.spec.js index 7ce971fd8d80..59209054d28d 100644 --- a/test/e2e/tests/transaction/change-assets.spec.js +++ b/test/e2e/tests/transaction/change-assets.spec.js @@ -3,9 +3,11 @@ const { defaultGanacheOptions, withFixtures, logInWithBalanceValidation, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); +const { PAGES } = require('../../webdriver/driver'); const { tEn } = require('../../../lib/i18n-helpers'); describe('Change assets', function () { @@ -22,6 +24,11 @@ describe('Change assets', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Wait for balance to load await driver.delay(500); @@ -100,6 +107,11 @@ describe('Change assets', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Click the Send button await driver.clickElement({ css: '[data-testid="multichain-token-list-button"] span', @@ -179,6 +191,11 @@ describe('Change assets', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Choose the nft await driver.clickElement('[data-testid="account-overview__nfts-tab"]'); await driver.clickElement('[data-testid="nft-default-image"]'); @@ -266,6 +283,11 @@ describe('Change assets', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Create second account await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement( diff --git a/test/e2e/tests/transaction/edit-gas-fee.spec.js b/test/e2e/tests/transaction/edit-gas-fee.spec.js index 918831f8f3ad..8db05aa19375 100644 --- a/test/e2e/tests/transaction/edit-gas-fee.spec.js +++ b/test/e2e/tests/transaction/edit-gas-fee.spec.js @@ -3,12 +3,14 @@ const { createInternalTransaction, createDappTransaction, } = require('../../page-objects/flows/transaction'); +const { PAGES } = require('../../webdriver/driver'); const { withFixtures, unlockWallet, generateGanacheOptions, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -22,6 +24,12 @@ describe('Editing Confirm Transaction', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await createInternalTransaction(driver); await driver.findElement({ @@ -95,6 +103,11 @@ describe('Editing Confirm Transaction', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); await createInternalTransaction(driver); await driver.findElement({ @@ -172,6 +185,11 @@ describe('Editing Confirm Transaction', function () { // login to extension await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await createDappTransaction(driver, { maxFeePerGas: '0x2000000000', maxPriorityFeePerGas: '0x1000000000', diff --git a/test/e2e/tests/transaction/gas-estimates.spec.js b/test/e2e/tests/transaction/gas-estimates.spec.js index 263dfc85d904..83c16f59a25b 100644 --- a/test/e2e/tests/transaction/gas-estimates.spec.js +++ b/test/e2e/tests/transaction/gas-estimates.spec.js @@ -3,8 +3,10 @@ const { logInWithBalanceValidation, openActionMenuAndStartSendFlow, generateGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); +const { PAGES } = require('../../webdriver/driver'); const { CHAIN_IDS } = require('../../../../shared/constants/network'); const { GAS_API_BASE_URL } = require('../../../../shared/constants/swaps'); @@ -27,6 +29,11 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openActionMenuAndStartSendFlow(driver); await driver.fill( @@ -69,6 +76,11 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openActionMenuAndStartSendFlow(driver); await driver.fill( @@ -108,6 +120,11 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openActionMenuAndStartSendFlow(driver); await driver.fill( @@ -143,6 +160,11 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openActionMenuAndStartSendFlow(driver); await driver.fill( 'input[placeholder="Enter public address (0x) or domain name"]', @@ -189,6 +211,11 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openActionMenuAndStartSendFlow(driver); await driver.fill( 'input[placeholder="Enter public address (0x) or domain name"]', @@ -218,6 +245,11 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await openActionMenuAndStartSendFlow(driver); await driver.fill( 'input[placeholder="Enter public address (0x) or domain name"]', diff --git a/test/e2e/tests/transaction/multiple-transactions.spec.js b/test/e2e/tests/transaction/multiple-transactions.spec.js index 4d913cb07edb..915f877a0ef3 100644 --- a/test/e2e/tests/transaction/multiple-transactions.spec.js +++ b/test/e2e/tests/transaction/multiple-transactions.spec.js @@ -6,8 +6,10 @@ const { unlockWallet, generateGanacheOptions, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); +const { PAGES } = require('../../webdriver/driver'); describe('Multiple transactions', function () { it('creates multiple queued transactions, then confirms', async function () { @@ -23,6 +25,11 @@ describe('Multiple transactions', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // initiates a transaction from the dapp await openDapp(driver); // creates first transaction @@ -85,6 +92,11 @@ describe('Multiple transactions', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // initiates a transaction from the dapp await openDapp(driver); // creates first transaction diff --git a/test/e2e/tests/transaction/navigate-transactions.spec.js b/test/e2e/tests/transaction/navigate-transactions.spec.js index 63170d027874..f80445e03784 100644 --- a/test/e2e/tests/transaction/navigate-transactions.spec.js +++ b/test/e2e/tests/transaction/navigate-transactions.spec.js @@ -1,10 +1,10 @@ const { createDappTransaction, } = require('../../page-objects/flows/transaction'); - const { default: ConfirmationNavigation, } = require('../../page-objects/pages/confirmations/legacy/navigation'); +const { PAGES } = require('../../webdriver/driver'); const { withFixtures, @@ -13,6 +13,7 @@ const { unlockWallet, generateGanacheOptions, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -32,6 +33,12 @@ describe('Navigate transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await createMultipleTransactions(driver, TRANSACTION_COUNT); const navigation = new ConfirmationNavigation(driver); @@ -73,6 +80,12 @@ describe('Navigate transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await createMultipleTransactions(driver, TRANSACTION_COUNT); const navigation = new ConfirmationNavigation(driver); @@ -107,6 +120,12 @@ describe('Navigate transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await createMultipleTransactions(driver, TRANSACTION_COUNT); // reject transaction @@ -131,6 +150,12 @@ describe('Navigate transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await createMultipleTransactions(driver, TRANSACTION_COUNT); // confirm transaction @@ -155,6 +180,12 @@ describe('Navigate transactions', function () { }, async ({ driver, ganacheServer }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await createMultipleTransactions(driver, TRANSACTION_COUNT); // reject transactions diff --git a/test/e2e/tests/transaction/send-edit.spec.js b/test/e2e/tests/transaction/send-edit.spec.js index 953f2ebf3569..942035d5e705 100644 --- a/test/e2e/tests/transaction/send-edit.spec.js +++ b/test/e2e/tests/transaction/send-edit.spec.js @@ -2,12 +2,14 @@ const { strict: assert } = require('assert'); const { createInternalTransaction, } = require('../../page-objects/flows/transaction'); +const { PAGES } = require('../../webdriver/driver'); const { defaultGanacheOptions, withFixtures, unlockWallet, generateGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -21,6 +23,8 @@ describe('Editing Confirm Transaction', function () { }, async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); await createInternalTransaction(driver); await driver.findElement({ @@ -96,6 +100,9 @@ describe('Editing Confirm Transaction', function () { }, async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + await createInternalTransaction(driver); await driver.findElement({ diff --git a/test/e2e/tests/transaction/send-eth.spec.js b/test/e2e/tests/transaction/send-eth.spec.js index 5cbcb8309a18..dbdbcbfecf39 100644 --- a/test/e2e/tests/transaction/send-eth.spec.js +++ b/test/e2e/tests/transaction/send-eth.spec.js @@ -9,8 +9,10 @@ const { editGasFeeForm, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); +const { PAGES } = require('../../webdriver/driver'); describe('Send ETH', function () { describe('from inside MetaMask', function () { @@ -106,6 +108,11 @@ describe('Send ETH', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await driver.delay(1000); await openActionMenuAndStartSendFlow(driver); @@ -256,6 +263,11 @@ describe('Send ETH', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // initiates a send from the dapp await openDapp(driver); await driver.clickElement({ text: 'Send', tag: 'button' }); @@ -332,6 +344,11 @@ describe('Send ETH', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // initiates a transaction from the dapp await openDapp(driver); await driver.clickElement({ text: 'Create Token', tag: 'button' }); @@ -435,6 +452,11 @@ describe('Send ETH', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + await driver.assertElementNotPresent('.loading-overlay__spinner'); const balance = await driver.findElement( '[data-testid="eth-overview__primary-currency"]', diff --git a/test/e2e/tests/transaction/send-hex-address.spec.js b/test/e2e/tests/transaction/send-hex-address.spec.js index d93f1a0d5484..608ace11e7cd 100644 --- a/test/e2e/tests/transaction/send-hex-address.spec.js +++ b/test/e2e/tests/transaction/send-hex-address.spec.js @@ -3,9 +3,11 @@ const { withFixtures, logInWithBalanceValidation, openActionMenuAndStartSendFlow, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); +const { PAGES } = require('../../webdriver/driver'); const hexPrefixedAddress = '0x2f318C334780961FB129D2a6c30D0763d9a5C970'; const nonHexPrefixedAddress = hexPrefixedAddress.substring(2); @@ -120,6 +122,11 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Send TST await driver.clickElement( '[data-testid="account-overview__asset-tab"]', @@ -181,6 +188,12 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { }, async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + // Send TST await driver.clickElement( '[data-testid="account-overview__asset-tab"]', diff --git a/test/e2e/tests/transaction/simple-send.spec.ts b/test/e2e/tests/transaction/simple-send.spec.ts index 25f2368a9cfc..637ffcde474b 100644 --- a/test/e2e/tests/transaction/simple-send.spec.ts +++ b/test/e2e/tests/transaction/simple-send.spec.ts @@ -1,7 +1,11 @@ import { Suite } from 'mocha'; -import { Driver } from '../../webdriver/driver'; +import { Driver, PAGES } from '../../webdriver/driver'; import { Ganache } from '../../seeder/ganache'; -import { withFixtures, defaultGanacheOptions } from '../../helpers'; +import { + withFixtures, + defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, +} from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; import { sendTransactionToAddress } from '../../page-objects/flows/send-transaction.flow'; @@ -23,6 +27,10 @@ describe('Simple send eth', function (this: Suite) { ganacheServer?: Ganache; }) => { await loginWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + await sendTransactionToAddress({ driver, recipientAddress: '0x985c30949c92df7a0bd42e0f3e3d539ece98db24', diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index d81eb04966a9..5bea76d80dbe 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -178,6 +178,7 @@ export default class ExperimentalTab extends PureComponent description: t('redesignedTransactionsToggleDescription'), toggleValue: redesignedTransactionsEnabled, toggleCallback: (value) => setRedesignedTransactionsEnabled(!value), + toggleContainerDataTestId: 'toggle-redesigned-transactions-container', toggleDataTestId: 'toggle-redesigned-transactions', toggleOffLabel: t('off'), toggleOnLabel: t('on'), From c5528be98a27633d70f89a73bdf7d273fde09417 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Wed, 13 Nov 2024 16:34:49 +0000 Subject: [PATCH 03/19] fix e2e test --- test/e2e/tests/account/add-account.spec.ts | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/test/e2e/tests/account/add-account.spec.ts b/test/e2e/tests/account/add-account.spec.ts index 8824fcb70950..906e01f50b4d 100644 --- a/test/e2e/tests/account/add-account.spec.ts +++ b/test/e2e/tests/account/add-account.spec.ts @@ -1,18 +1,19 @@ +import { E2E_SRP } from '../../default-fixture'; +import FixtureBuilder from '../../fixture-builder'; import { - withFixtures, WALLET_PASSWORD, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, + withFixtures, } from '../../helpers'; -import { E2E_SRP } from '../../default-fixture'; -import FixtureBuilder from '../../fixture-builder'; +import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; +import { completeImportSRPOnboardingFlow } from '../../page-objects/flows/onboarding.flow'; +import { sendTransactionToAccount } from '../../page-objects/flows/send-transaction.flow'; import AccountListPage from '../../page-objects/pages/account-list-page'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; import HomePage from '../../page-objects/pages/homepage'; import LoginPage from '../../page-objects/pages/login-page'; import ResetPasswordPage from '../../page-objects/pages/reset-password-page'; -import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; -import { completeImportSRPOnboardingFlow } from '../../page-objects/flows/onboarding.flow'; -import { sendTransactionToAccount } from '../../page-objects/flows/send-transaction.flow'; describe('Add account', function () { it('should not affect public address when using secret recovery phrase to recover account with non-zero balance @no-mmi', async function () { @@ -24,17 +25,21 @@ describe('Add account', function () { }, async ({ driver, ganacheServer }) => { await completeImportSRPOnboardingFlow({ driver }); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_localBlockchainBalanceIsDisplayed(ganacheServer); const headerNavbar = new HeaderNavbar(driver); await headerNavbar.openAccountMenu(); - // Create new account with default name Account 2 + // Create new account with default name `newAccountName` + const newAccountName = 'Account 2'; const accountListPage = new AccountListPage(driver); await accountListPage.check_pageIsLoaded(); await accountListPage.addNewAccount(); - await headerNavbar.check_accountLabel('Account 2'); + await headerNavbar.check_accountLabel(newAccountName); await homePage.check_expectedBalanceIsDisplayed(); // Switch back to the first account and transfer some balance to 2nd account so they will not be removed after recovering SRP @@ -46,7 +51,7 @@ describe('Add account', function () { await homePage.check_localBlockchainBalanceIsDisplayed(ganacheServer); await sendTransactionToAccount({ driver, - recipientAccount: 'Account 2', + recipientAccount: newAccountName, amount: '2.8', gasFee: '0.000042', totalFee: '2.800042', @@ -67,9 +72,11 @@ describe('Add account', function () { await homePage.check_localBlockchainBalanceIsDisplayed(ganacheServer); await headerNavbar.openAccountMenu(); await accountListPage.check_pageIsLoaded(); - await accountListPage.check_accountDisplayedInAccountList('Account 2'); - await accountListPage.switchToAccount('Account 2'); - await headerNavbar.check_accountLabel('Account 2'); + await accountListPage.check_accountDisplayedInAccountList( + newAccountName, + ); + await accountListPage.switchToAccount(newAccountName); + await headerNavbar.check_accountLabel(newAccountName); await homePage.check_expectedBalanceIsDisplayed('2.8'); }, ); From 721e69b9ac62755742bb3d29f6b695acd924813b Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 15 Nov 2024 16:19:26 +0000 Subject: [PATCH 04/19] Add tests for redesigned flows --- test/e2e/json-rpc/switchEthereumChain.spec.js | 1155 +++++++----- .../e2e/snaps/test-snap-txinsights-v2.spec.js | 430 +++-- test/e2e/snaps/test-snap-txinsights.spec.js | 312 ++-- .../batch-txs-per-dapp-diff-network.spec.js | 308 +++- .../batch-txs-per-dapp-extra-tx.spec.js | 480 +++-- .../batch-txs-per-dapp-same-network.spec.js | 395 ++-- .../dapp1-send-dapp2-signTypedData.spec.js | 427 +++-- ...-switch-dapp2-eth-request-accounts.spec.js | 361 ++-- .../dapp1-switch-dapp2-send.spec.js | 788 +++++--- ...multi-dapp-sendTx-revokePermission.spec.js | 359 ++-- .../multiple-networks-dapps-txs.spec.js | 348 ++-- .../request-queuing/switch-network.spec.js | 221 ++- test/e2e/tests/request-queuing/ui.spec.js | 1624 +++++++++++------ 13 files changed, 4696 insertions(+), 2512 deletions(-) diff --git a/test/e2e/json-rpc/switchEthereumChain.spec.js b/test/e2e/json-rpc/switchEthereumChain.spec.js index b0cdb941d023..8841b7007a81 100644 --- a/test/e2e/json-rpc/switchEthereumChain.spec.js +++ b/test/e2e/json-rpc/switchEthereumChain.spec.js @@ -15,512 +15,665 @@ const { PAGES } = require('../webdriver/driver'); const { isManifestV3 } = require('../../../shared/modules/mv3.utils'); describe('Switch Ethereum Chain for two dapps', function () { - it('switches the chainId of two dapps when switchEthereumChain of one dapp is confirmed', async function () { - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .build(), - dappOptions: { numberOfDapps: 2 }, - - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [{ port: 8546, chainId: 1338 }], + describe('Old confirmation screens', function () { + it('queues send tx after switchEthereum request with a warning, if switchEthereum request is cancelled should show pending tx', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [{ port: 8546, chainId: 1338 }], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - // Open settings menu button - const accountOptionsMenuSelector = - '[data-testid="account-options-menu-button"]'; - await driver.waitForSelector(accountOptionsMenuSelector); - await driver.clickElement(accountOptionsMenuSelector); - - // Click settings from dropdown menu - const globalMenuSettingsSelector = - '[data-testid="global-menu-settings"]'; - await driver.waitForSelector(globalMenuSettingsSelector); - await driver.clickElement(globalMenuSettingsSelector); - - // Click Experimental tab - const experimentalTabRawLocator = { - text: 'Experimental', - tag: 'div', - }; - await driver.clickElement(experimentalTabRawLocator); - - // Toggle off request queue setting (on by default now) - await driver.clickElement( - '[data-testid="experimental-setting-toggle-request-queue"]', - ); - - // open two dapps - const dappOne = await openDapp(driver, undefined, DAPP_URL); - const dappTwo = await openDapp(driver, undefined, DAPP_ONE_URL); - - // switchEthereumChain request - const switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x53a' }], - }); - - // Initiate switchEthereumChain on Dapp Two - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); - - // Confirm switchEthereumChain - await switchToNotificationWindow(driver, 4); - await driver.findClickableElements({ - text: 'Confirm', - tag: 'button', - }); - await driver.clickElement({ text: 'Confirm', tag: 'button' }); - - // Switch to Dapp One - await driver.switchToWindow(dappOne); - assert.equal(await driver.getCurrentUrl(), `${DAPP_URL}/`); - - // Wait for chain id element to change, there's a page reload. - await driver.waitForSelector({ - css: '#chainId', - text: '0x53a', - }); - - // Dapp One ChainId assertion - await driver.findElement({ css: '#chainId', text: '0x53a' }); - - // Switch to Dapp Two - await driver.switchToWindow(dappTwo); - assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); - - // Dapp Two ChainId Assertion - await driver.findElement({ css: '#chainId', text: '0x53a' }); - }, - ); - }); - - it('queues switchEthereumChain request from second dapp after send tx request', async function () { - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [{ port: 8546, chainId: 1338 }], + async ({ driver }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + await driver.navigate(PAGES.HOME); + + // Open settings menu button + const accountOptionsMenuSelector = + '[data-testid="account-options-menu-button"]'; + await driver.waitForSelector(accountOptionsMenuSelector); + await driver.clickElement(accountOptionsMenuSelector); + + // Click settings from dropdown menu + const globalMenuSettingsSelector = + '[data-testid="global-menu-settings"]'; + await driver.waitForSelector(globalMenuSettingsSelector); + await driver.clickElement(globalMenuSettingsSelector); + + // Click Experimental tab + const experimentalTabRawLocator = { + text: 'Experimental', + tag: 'div', + }; + await driver.clickElement(experimentalTabRawLocator); + + // Toggle off request queue setting (on by default now) + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); + + // open two dapps + const dappTwo = await openDapp(driver, undefined, DAPP_ONE_URL); + const dappOne = await openDapp(driver, undefined, DAPP_URL); + + // Connect Dapp One + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Switch and connect Dapp Two + await driver.switchToWindow(dappTwo); + assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); + + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + const editButtons = await driver.findElements('[data-testid="edit"]'); + + // Click the edit button for networks + await editButtons[1].click(); + + // Disconnect Mainnet + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + + await driver.clickElement( + '[data-testid="connect-more-chains-button"]', + ); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + await driver.switchToWindow(dappTwo); + assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); + + // switchEthereumChain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x539' }], + }); + + // Initiate switchEthereumChain on Dapp Two + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + // Switch to notification of switchEthereumChain + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + + // Switch back to dapp one + await driver.switchToWindow(dappOne); + assert.equal(await driver.getCurrentUrl(), `${DAPP_URL}/`); + + // Initiate send tx on dapp one + await driver.clickElement('#sendButton'); + await driver.delay(2000); + + // Switch to notification that should still be switchEthereumChain request but with an warning. + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // THIS IS BROKEN + // await driver.findElement({ + // span: 'span', + // text: 'Switching networks will cancel all pending confirmations', + // }); + + // Cancel switchEthereumChain with queued pending tx + await driver.clickElement({ text: 'Cancel', tag: 'button' }); + + // Delay for second notification of the pending tx + await driver.delay(1000); + + // Switch to new pending tx notification + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.findElement({ + text: 'Sending ETH', + tag: 'span', + }); + + // Confirm pending tx + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - // Open settings menu button - const accountOptionsMenuSelector = - '[data-testid="account-options-menu-button"]'; - await driver.waitForSelector(accountOptionsMenuSelector); - await driver.clickElement(accountOptionsMenuSelector); - - // Click settings from dropdown menu - const globalMenuSettingsSelector = - '[data-testid="global-menu-settings"]'; - await driver.waitForSelector(globalMenuSettingsSelector); - await driver.clickElement(globalMenuSettingsSelector); - - // Click Experimental tab - const experimentalTabRawLocator = { - text: 'Experimental', - tag: 'div', - }; - await driver.clickElement(experimentalTabRawLocator); - - // Toggle off request queue setting (on by default now) - await driver.clickElement( - '[data-testid="experimental-setting-toggle-request-queue"]', - ); - - // open two dapps - await openDapp(driver, undefined, DAPP_URL); - await openDapp(driver, undefined, DAPP_ONE_URL); - - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - // Switch to Dapp One and connect it - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.findClickableElement({ - text: 'Connect', - tag: 'button', - }); - await driver.clickElement('#connectButton'); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - const editButtons = await driver.findElements('[data-testid="edit"]'); - - await editButtons[1].click(); - - // Disconnect Localhost 8545 - await driver.clickElement({ - text: 'Localhost 8545', - tag: 'p', - }); - - await driver.clickElement('[data-testid="connect-more-chains-button"]'); - - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - // Switch to Dapp Two - await driver.switchToWindowWithUrl(DAPP_ONE_URL); - // Initiate send transaction on Dapp two - await driver.clickElement('#sendButton'); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.findClickableElements({ - text: 'Confirm', - tag: 'button', - }); - - // Switch to Dapp One - await driver.switchToWindowWithUrl(DAPP_URL); - - // Switch Ethereum chain request - const switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x539' }], - }); - - // Initiate switchEthereumChain on Dapp One - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); - await switchToNotificationWindow(driver, 4); - await driver.findClickableElements({ - text: 'Confirm', - tag: 'button', - }); - await driver.clickElement({ - text: 'Confirm', - tag: 'button', - }); - // Delay here after notification for second notification popup for switchEthereumChain - await driver.delay(1000); - - // Switch and confirm to queued notification for switchEthereumChain - await switchToNotificationWindow(driver, 4); - - await driver.findClickableElements({ - text: 'Confirm', - tag: 'button', - }); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Confirm', - tag: 'button', - }); - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.findElement({ css: '#chainId', text: '0x539' }); - }, - ); + ); + }); }); - it('queues send tx after switchEthereum request with a warning, confirming removes pending tx', async function () { - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [{ port: 8546, chainId: 1338 }], + describe('Redesigned confirmation screens', function () { + it('switches the chainId of two dapps when switchEthereumChain of one dapp is confirmed', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .build(), + dappOptions: { numberOfDapps: 2 }, + + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [{ port: 8546, chainId: 1338 }], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - await driver.navigate(PAGES.HOME); - - // Open settings menu button - const accountOptionsMenuSelector = - '[data-testid="account-options-menu-button"]'; - await driver.waitForSelector(accountOptionsMenuSelector); - await driver.clickElement(accountOptionsMenuSelector); - - // Click settings from dropdown menu - const globalMenuSettingsSelector = - '[data-testid="global-menu-settings"]'; - await driver.waitForSelector(globalMenuSettingsSelector); - await driver.clickElement(globalMenuSettingsSelector); - - // Click Experimental tab - const experimentalTabRawLocator = { - text: 'Experimental', - tag: 'div', - }; - await driver.clickElement(experimentalTabRawLocator); - - // Toggle off request queue setting (on by default now) - await driver.clickElement( - '[data-testid="experimental-setting-toggle-request-queue"]', - ); - - // open two dapps - const dappTwo = await openDapp(driver, undefined, DAPP_ONE_URL); - const dappOne = await openDapp(driver, undefined, DAPP_URL); - - // Connect Dapp One - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - // Switch and connect Dapp Two - - await driver.switchToWindow(dappTwo); - assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); - - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - const editButtons = await driver.findElements('[data-testid="edit"]'); - - // Click the edit button for networks - await editButtons[1].click(); - - // Disconnect Mainnet - await driver.clickElement({ - text: 'Localhost 8545', - tag: 'p', - }); - - await driver.clickElement('[data-testid="connect-more-chains-button"]'); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - await driver.switchToWindow(dappTwo); - assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); - - // switchEthereumChain request - const switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x539' }], - }); - - // Initiate switchEthereumChain on Dapp Two - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.findClickableElements({ - text: 'Confirm', - tag: 'button', - }); - // Switch back to dapp one - await driver.switchToWindow(dappOne); - assert.equal(await driver.getCurrentUrl(), `${DAPP_URL}/`); - - // Initiate send tx on dapp one - await driver.clickElement('#sendButton'); - await driver.delay(2000); - - // Switch to notification that should still be switchEthereumChain request but with a warning. - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // THIS IS BROKEN - // await driver.findElement({ - // span: 'span', - // text: 'Switching networks will cancel all pending confirmations', - // }); - - // Confirm switchEthereumChain with queued pending tx - await driver.clickElement({ text: 'Confirm', tag: 'button' }); - - // Window handles should only be expanded mm, dapp one, dapp 2, and the offscreen document - // if this is an MV3 build(3 or 4 total) - await driver.wait(async () => { - const windowHandles = await driver.getAllWindowHandles(); - const numberOfWindowHandlesToExpect = isManifestV3 ? 4 : 3; - return windowHandles.length === numberOfWindowHandlesToExpect; - }); - }, - ); - }); - - it('queues send tx after switchEthereum request with a warning, if switchEthereum request is cancelled should show pending tx', async function () { - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [{ port: 8546, chainId: 1338 }], + async ({ driver }) => { + await unlockWallet(driver); + + // Open settings menu button + const accountOptionsMenuSelector = + '[data-testid="account-options-menu-button"]'; + await driver.waitForSelector(accountOptionsMenuSelector); + await driver.clickElement(accountOptionsMenuSelector); + + // Click settings from dropdown menu + const globalMenuSettingsSelector = + '[data-testid="global-menu-settings"]'; + await driver.waitForSelector(globalMenuSettingsSelector); + await driver.clickElement(globalMenuSettingsSelector); + + // Click Experimental tab + const experimentalTabRawLocator = { + text: 'Experimental', + tag: 'div', + }; + await driver.clickElement(experimentalTabRawLocator); + + // Toggle off request queue setting (on by default now) + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); + + // open two dapps + const dappOne = await openDapp(driver, undefined, DAPP_URL); + const dappTwo = await openDapp(driver, undefined, DAPP_ONE_URL); + + // switchEthereumChain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x53a' }], + }); + + // Initiate switchEthereumChain on Dapp Two + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + // Confirm switchEthereumChain + await switchToNotificationWindow(driver, 4); + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + + // Switch to Dapp One + await driver.switchToWindow(dappOne); + assert.equal(await driver.getCurrentUrl(), `${DAPP_URL}/`); + + // Wait for chain id element to change, there's a page reload. + await driver.waitForSelector({ + css: '#chainId', + text: '0x53a', + }); + + // Dapp One ChainId assertion + await driver.findElement({ css: '#chainId', text: '0x53a' }); + + // Switch to Dapp Two + await driver.switchToWindow(dappTwo); + assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); + + // Dapp Two ChainId Assertion + await driver.findElement({ css: '#chainId', text: '0x53a' }); + }, + ); + }); + + it('queues switchEthereumChain request from second dapp after send tx request', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [{ port: 8546, chainId: 1338 }], + }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open settings menu button + const accountOptionsMenuSelector = + '[data-testid="account-options-menu-button"]'; + await driver.waitForSelector(accountOptionsMenuSelector); + await driver.clickElement(accountOptionsMenuSelector); + + // Click settings from dropdown menu + const globalMenuSettingsSelector = + '[data-testid="global-menu-settings"]'; + await driver.waitForSelector(globalMenuSettingsSelector); + await driver.clickElement(globalMenuSettingsSelector); + + // Click Experimental tab + const experimentalTabRawLocator = { + text: 'Experimental', + tag: 'div', + }; + await driver.clickElement(experimentalTabRawLocator); + + // Toggle off request queue setting (on by default now) + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); + + // open two dapps + await openDapp(driver, undefined, DAPP_URL); + await openDapp(driver, undefined, DAPP_ONE_URL); + + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Switch to Dapp One and connect it + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findClickableElement({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + await editButtons[1].click(); + + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + + await driver.clickElement( + '[data-testid="connect-more-chains-button"]', + ); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Switch to Dapp Two + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + // Initiate send transaction on Dapp two + await driver.clickElement('#sendButton'); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + + // Switch to Dapp One + await driver.switchToWindowWithUrl(DAPP_URL); + + // Switch Ethereum chain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x539' }], + }); + + // Initiate switchEthereumChain on Dapp One + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + await switchToNotificationWindow(driver, 4); + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); + // Delay here after notification for second notification popup for switchEthereumChain + await driver.delay(1000); + + // Switch and confirm to queued notification for switchEthereumChain + await switchToNotificationWindow(driver, 4); + + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Confirm', + tag: 'button', + }); + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ css: '#chainId', text: '0x539' }); + }, + ); + }); + + it('queues send tx after switchEthereum request with a warning, confirming removes pending tx', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [{ port: 8546, chainId: 1338 }], + }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open settings menu button + const accountOptionsMenuSelector = + '[data-testid="account-options-menu-button"]'; + await driver.waitForSelector(accountOptionsMenuSelector); + await driver.clickElement(accountOptionsMenuSelector); + + // Click settings from dropdown menu + const globalMenuSettingsSelector = + '[data-testid="global-menu-settings"]'; + await driver.waitForSelector(globalMenuSettingsSelector); + await driver.clickElement(globalMenuSettingsSelector); + + // Click Experimental tab + const experimentalTabRawLocator = { + text: 'Experimental', + tag: 'div', + }; + await driver.clickElement(experimentalTabRawLocator); + + // Toggle off request queue setting (on by default now) + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); + + // open two dapps + const dappTwo = await openDapp(driver, undefined, DAPP_ONE_URL); + const dappOne = await openDapp(driver, undefined, DAPP_URL); + + // Connect Dapp One + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Switch and connect Dapp Two + + await driver.switchToWindow(dappTwo); + assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); + + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + // Click the edit button for networks + await editButtons[1].click(); + + // Disconnect Mainnet + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + + await driver.clickElement( + '[data-testid="connect-more-chains-button"]', + ); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindow(dappTwo); + assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); + + // switchEthereumChain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x539' }], + }); + + // Initiate switchEthereumChain on Dapp Two + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + // Switch back to dapp one + await driver.switchToWindow(dappOne); + assert.equal(await driver.getCurrentUrl(), `${DAPP_URL}/`); + + // Initiate send tx on dapp one + await driver.clickElement('#sendButton'); + await driver.delay(2000); + + // Switch to notification that should still be switchEthereumChain request but with a warning. + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // THIS IS BROKEN + // await driver.findElement({ + // span: 'span', + // text: 'Switching networks will cancel all pending confirmations', + // }); + + // Confirm switchEthereumChain with queued pending tx + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + + // Window handles should only be expanded mm, dapp one, dapp 2, and the offscreen document + // if this is an MV3 build(3 or 4 total) + await driver.wait(async () => { + const windowHandles = await driver.getAllWindowHandles(); + const numberOfWindowHandlesToExpect = isManifestV3 ? 4 : 3; + return windowHandles.length === numberOfWindowHandlesToExpect; + }); + }, + ); + }); + + it('queues send tx after switchEthereum request with a warning, if switchEthereum request is cancelled should show pending tx', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [{ port: 8546, chainId: 1338 }], + }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open settings menu button + const accountOptionsMenuSelector = + '[data-testid="account-options-menu-button"]'; + await driver.waitForSelector(accountOptionsMenuSelector); + await driver.clickElement(accountOptionsMenuSelector); + + // Click settings from dropdown menu + const globalMenuSettingsSelector = + '[data-testid="global-menu-settings"]'; + await driver.waitForSelector(globalMenuSettingsSelector); + await driver.clickElement(globalMenuSettingsSelector); + + // Click Experimental tab + const experimentalTabRawLocator = { + text: 'Experimental', + tag: 'div', + }; + await driver.clickElement(experimentalTabRawLocator); + + // Toggle off request queue setting (on by default now) + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); + + // open two dapps + const dappTwo = await openDapp(driver, undefined, DAPP_ONE_URL); + const dappOne = await openDapp(driver, undefined, DAPP_URL); + + // Connect Dapp One + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Switch and connect Dapp Two + await driver.switchToWindow(dappTwo); + assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); + + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + const editButtons = await driver.findElements('[data-testid="edit"]'); + + // Click the edit button for networks + await editButtons[1].click(); + + // Disconnect Mainnet + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + + await driver.clickElement( + '[data-testid="connect-more-chains-button"]', + ); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + await driver.switchToWindow(dappTwo); + assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); + + // switchEthereumChain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x539' }], + }); + + // Initiate switchEthereumChain on Dapp Two + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + // Switch to notification of switchEthereumChain + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + + // Switch back to dapp one + await driver.switchToWindow(dappOne); + assert.equal(await driver.getCurrentUrl(), `${DAPP_URL}/`); + + // Initiate send tx on dapp one + await driver.clickElement('#sendButton'); + await driver.delay(2000); + + // Switch to notification that should still be switchEthereumChain request but with an warning. + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Cancel switchEthereumChain with queued pending tx + await driver.clickElement({ text: 'Cancel', tag: 'button' }); + + // Delay for second notification of the pending tx + await driver.delay(1000); + + // Switch to new pending tx notification + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.findElement({ + text: 'Transfer request', + tag: 'h3', + }); + + await driver.findElement({ + text: '0 ETH', + tag: 'h2', + }); + + // Confirm pending tx + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - await driver.navigate(PAGES.HOME); - - // Open settings menu button - const accountOptionsMenuSelector = - '[data-testid="account-options-menu-button"]'; - await driver.waitForSelector(accountOptionsMenuSelector); - await driver.clickElement(accountOptionsMenuSelector); - - // Click settings from dropdown menu - const globalMenuSettingsSelector = - '[data-testid="global-menu-settings"]'; - await driver.waitForSelector(globalMenuSettingsSelector); - await driver.clickElement(globalMenuSettingsSelector); - - // Click Experimental tab - const experimentalTabRawLocator = { - text: 'Experimental', - tag: 'div', - }; - await driver.clickElement(experimentalTabRawLocator); - - // Toggle off request queue setting (on by default now) - await driver.clickElement( - '[data-testid="experimental-setting-toggle-request-queue"]', - ); - - // open two dapps - const dappTwo = await openDapp(driver, undefined, DAPP_ONE_URL); - const dappOne = await openDapp(driver, undefined, DAPP_URL); - - // Connect Dapp One - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - // Switch and connect Dapp Two - await driver.switchToWindow(dappTwo); - assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); - - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - const editButtons = await driver.findElements('[data-testid="edit"]'); - - // Click the edit button for networks - await editButtons[1].click(); - - // Disconnect Mainnet - await driver.clickElement({ - text: 'Localhost 8545', - tag: 'p', - }); - - await driver.clickElement('[data-testid="connect-more-chains-button"]'); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - await driver.switchToWindow(dappTwo); - assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); - - // switchEthereumChain request - const switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x539' }], - }); - - // Initiate switchEthereumChain on Dapp Two - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); - - // Switch to notification of switchEthereumChain - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.findClickableElements({ - text: 'Confirm', - tag: 'button', - }); - - // Switch back to dapp one - await driver.switchToWindow(dappOne); - assert.equal(await driver.getCurrentUrl(), `${DAPP_URL}/`); - - // Initiate send tx on dapp one - await driver.clickElement('#sendButton'); - await driver.delay(2000); - - // Switch to notification that should still be switchEthereumChain request but with an warning. - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // THIS IS BROKEN - // await driver.findElement({ - // span: 'span', - // text: 'Switching networks will cancel all pending confirmations', - // }); - - // Cancel switchEthereumChain with queued pending tx - await driver.clickElement({ text: 'Cancel', tag: 'button' }); - - // Delay for second notification of the pending tx - await driver.delay(1000); - - // Switch to new pending tx notification - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.findElement({ - text: 'Sending ETH', - tag: 'span', - }); - - // Confirm pending tx - await driver.findClickableElements({ - text: 'Confirm', - tag: 'button', - }); - await driver.clickElement({ - text: 'Confirm', - tag: 'button', - }); - }, - ); + ); + }); }); }); diff --git a/test/e2e/snaps/test-snap-txinsights-v2.spec.js b/test/e2e/snaps/test-snap-txinsights-v2.spec.js index 27188b2c9c9d..857c04d601f7 100644 --- a/test/e2e/snaps/test-snap-txinsights-v2.spec.js +++ b/test/e2e/snaps/test-snap-txinsights-v2.spec.js @@ -10,164 +10,276 @@ const { PAGES } = require('../webdriver/driver'); const { TEST_SNAPS_WEBSITE_URL } = require('./enums'); describe('Test Snap TxInsights-v2', function () { - it('tests tx insights v2 functionality', async function () { - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); - - // navigate to test snaps page and connect - await driver.openNewPage(TEST_SNAPS_WEBSITE_URL); - - // wait for page to load - await driver.waitForSelector({ - text: 'Installed Snaps', - tag: 'h2', - }); - - // find and scroll to the transaction-insights test snap - const snapButton1 = await driver.findElement( - '#connecttransaction-insights', - ); - await driver.scrollToElement(snapButton1); - - // added delay for firefox (deflake) - await driver.delayFirefox(1000); - - // wait for and click connect - await driver.waitForSelector('#connecttransaction-insights'); - await driver.clickElement('#connecttransaction-insights'); - - // switch to metamask extension - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // wait for and click connect - await driver.waitForSelector({ - text: 'Connect', - tag: 'button', - }); - await driver.clickElement({ - text: 'Connect', - tag: 'button', - }); - - // wait for and click connect - await driver.waitForSelector({ text: 'Confirm' }); - await driver.clickElement({ - text: 'Confirm', - tag: 'button', - }); - - // wait for and click ok and wait for window to close - await driver.waitForSelector({ text: 'OK' }); - await driver.clickElementAndWaitForWindowToClose({ - text: 'OK', - tag: 'button', - }); - - // switch to test-snaps page - await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); - - // wait for and click get accounts - await driver.waitForSelector('#getAccounts'); - await driver.clickElement('#getAccounts'); - - // switch back to MetaMask window - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // wait for and click confirm and wait for window to close - await driver.waitForSelector({ - text: 'Connect', - tag: 'button', - }); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - // switch to test-snaps page and send tx - await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); - await driver.clickElement('#sendInsights'); - - // delay added for rendering (deflake) - await driver.delay(2000); - - // switch back to MetaMask window and switch to tx insights pane - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // find confirm button - await driver.findClickableElement({ - text: 'Confirm', - tag: 'button', - }); - - // wait for and click insights snap tab - await driver.waitForSelector({ - text: 'Insights Example Snap', - tag: 'button', - }); - await driver.clickElement({ - text: 'Insights Example Snap', - tag: 'button', - }); - - // check that txinsightstest tab contains the right info - await driver.waitForSelector({ - css: '.snap-ui-renderer__content', - text: 'ERC-20', - }); - - // click confirm to continue - await driver.clickElement({ - text: 'Confirm', - tag: 'button', - }); - - // check for warning from txinsights - await driver.waitForSelector({ - css: '.snap-delineator__header__text', - text: 'Warning from Insights Example Snap', - }); - - // check info in warning - await driver.waitForSelector({ - css: '.snap-ui-renderer__text', - text: 'ERC-20', - }); - - // click the warning confirm checkbox - await driver.clickElement('.mm-checkbox__input'); - - // click confirm button to send transaction - await driver.clickElement({ - css: '.mm-box--color-error-inverse', - text: 'Confirm', - tag: 'button', - }); - - // switch back to MetaMask tab - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - - // switch to activity pane - await driver.clickElement({ - tag: 'button', - text: 'Activity', - }); - // wait for transaction confirmation - await driver.waitForSelector({ - css: '.transaction-status-label', - text: 'Confirmed', - }); - }, - ); + describe('Old confirmation screens', function () { + it('tests tx insights v2 functionality', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + + // navigate to test snaps page and connect + await driver.openNewPage(TEST_SNAPS_WEBSITE_URL); + + // wait for page to load + await driver.waitForSelector({ + text: 'Installed Snaps', + tag: 'h2', + }); + // find and scroll to the transaction-insights test snap + const snapButton1 = await driver.findElement( + '#connecttransaction-insights', + ); + await driver.scrollToElement(snapButton1); + // added delay for firefox (deflake) + await driver.delayFirefox(1000); + // wait for and click connect + await driver.waitForSelector('#connecttransaction-insights'); + await driver.clickElement('#connecttransaction-insights'); + // switch to metamask extension + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and click connect + await driver.waitForSelector({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + // wait for and click connect + await driver.waitForSelector({ text: 'Confirm' }); + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); + // wait for and click ok and wait for window to close + await driver.waitForSelector({ text: 'OK' }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'OK', + tag: 'button', + }); + // switch to test-snaps page + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + // wait for and click get accounts + await driver.waitForSelector('#getAccounts'); + await driver.clickElement('#getAccounts'); + // switch back to MetaMask window + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and click confirm and wait for window to close + await driver.waitForSelector({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + // switch to test-snaps page and send tx + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + await driver.clickElement('#sendInsights'); + // delay added for rendering (deflake) + await driver.delay(2000); + // switch back to MetaMask window and switch to tx insights pane + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // find confirm button + await driver.findClickableElement({ + text: 'Confirm', + tag: 'button', + }); + // wait for and click insights snap tab + await driver.waitForSelector({ + text: 'Insights Example Snap', + tag: 'button', + }); + await driver.clickElement({ + text: 'Insights Example Snap', + tag: 'button', + }); + // check that txinsightstest tab contains the right info + await driver.waitForSelector({ + css: '.snap-ui-renderer__content', + text: 'ERC-20', + }); + // click confirm to continue + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); + // check for warning from txinsights + await driver.waitForSelector({ + css: '.snap-delineator__header__text', + text: 'Warning from Insights Example Snap', + }); + // check info in warning + await driver.waitForSelector({ + css: '.snap-ui-renderer__text', + text: 'ERC-20', + }); + // click the warning confirm checkbox + await driver.clickElement('.mm-checkbox__input'); + // click confirm button to send transaction + await driver.clickElement({ + css: '.mm-box--color-error-inverse', + text: 'Confirm', + tag: 'button', + }); + // switch back to MetaMask tab + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + // switch to activity pane + await driver.clickElement({ + tag: 'button', + text: 'Activity', + }); + // wait for transaction confirmation + await driver.waitForSelector({ + css: '.transaction-status-label', + text: 'Confirmed', + }); + }, + ); + }); + }); + + describe('Redesigned confirmation screens', function () { + it('tests tx insights v2 functionality', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // navigate to test snaps page and connect + await driver.openNewPage(TEST_SNAPS_WEBSITE_URL); + + // wait for page to load + await driver.waitForSelector({ + text: 'Installed Snaps', + tag: 'h2', + }); + + // find and scroll to the transaction-insights test snap + const snapButton1 = await driver.findElement( + '#connecttransaction-insights', + ); + await driver.scrollToElement(snapButton1); + + // added delay for firefox (deflake) + await driver.delayFirefox(1000); + + // wait for and click connect + await driver.waitForSelector('#connecttransaction-insights'); + await driver.clickElement('#connecttransaction-insights'); + + // switch to metamask extension + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // wait for and click connect + await driver.waitForSelector({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + // wait for and click connect + await driver.waitForSelector({ text: 'Confirm' }); + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); + + // wait for and click ok and wait for window to close + await driver.waitForSelector({ text: 'OK' }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'OK', + tag: 'button', + }); + + // switch to test-snaps page + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + + // wait for and click get accounts + await driver.waitForSelector('#getAccounts'); + await driver.clickElement('#getAccounts'); + + // switch back to MetaMask window + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // wait for and click confirm and wait for window to close + await driver.waitForSelector({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // switch to test-snaps page and send tx + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + await driver.clickElement('#sendInsights'); + + // delay added for rendering (deflake) + await driver.delay(2000); + + // switch back to MetaMask window and switch to tx insights pane + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // find confirm button + await driver.findClickableElement({ + text: 'Confirm', + tag: 'button', + }); + + // wait for and click insights snap tab + await driver.waitForSelector({ + text: 'Insights Example Snap', + tag: 'span', + }); + + // check that tx insight accordion contains the right info + await driver.waitForSelector({ + css: 'p', + text: 'ERC-20', + }); + + // click confirm to continue + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); + + // switch back to MetaMask tab + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // switch to activity pane + await driver.clickElement({ + tag: 'button', + text: 'Activity', + }); + // wait for transaction confirmation + await driver.waitForSelector({ + css: '.transaction-status-label', + text: 'Confirmed', + }); + }, + ); + }); }); }); diff --git a/test/e2e/snaps/test-snap-txinsights.spec.js b/test/e2e/snaps/test-snap-txinsights.spec.js index f64a5660ccfc..c5b2076b897e 100644 --- a/test/e2e/snaps/test-snap-txinsights.spec.js +++ b/test/e2e/snaps/test-snap-txinsights.spec.js @@ -10,115 +10,207 @@ const { PAGES } = require('../webdriver/driver'); const { TEST_SNAPS_WEBSITE_URL } = require('./enums'); describe('Test Snap TxInsights', function () { - it('tests tx insights functionality', async function () { - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); - - // navigate to test snaps page and connect - await driver.driver.get(TEST_SNAPS_WEBSITE_URL); - - // wait for page to load - await driver.waitForSelector({ - text: 'Installed Snaps', - tag: 'h2', - }); - - // find and scroll to the transaction-insights test snap - const snapButton1 = await driver.findElement( - '#connecttransaction-insights', - ); - await driver.scrollToElement(snapButton1); - - // added delay for firefox (deflake) - await driver.delayFirefox(1000); - - // wait for and click connect - await driver.waitForSelector('#connecttransaction-insights'); - await driver.clickElement('#connecttransaction-insights'); - - // switch to metamask extension - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // wait for and click connect - await driver.waitForSelector({ - text: 'Connect', - tag: 'button', - }); - await driver.clickElement({ - text: 'Connect', - tag: 'button', - }); - - // wait for and click confirm - await driver.waitForSelector({ text: 'Confirm' }); - await driver.clickElement({ - text: 'Confirm', - tag: 'button', - }); - - // wait for and click ok and wait for window to close - await driver.waitForSelector({ text: 'OK' }); - await driver.clickElementAndWaitForWindowToClose({ - text: 'OK', - tag: 'button', - }); - - // switch to test-snaps page and get accounts - await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); - - // click get accounts - await driver.clickElement('#getAccounts'); - - // switch back to MetaMask window - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // wait for and click next and wait for window to close - await driver.waitForSelector({ - text: 'Connect', - tag: 'button', - }); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - // switch to test-snaps page - await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); - - // click send tx - await driver.clickElement('#sendInsights'); - - // delay added for rendering (deflake) - await driver.delay(2000); - - // switch back to MetaMask window - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // wait for and switch to insight snap pane - await driver.waitForSelector({ - text: 'Insights Example Snap', - tag: 'button', - }); - await driver.clickElement({ - text: 'Insights Example Snap', - tag: 'button', - }); - - // check that txinsightstest tab contains the right info - await driver.waitForSelector({ - css: '.snap-ui-renderer__content', - text: 'ERC-20', - }); - }, - ); + describe('Old confirmation screens', function () { + it('tests tx insights functionality', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + + // navigate to test snaps page and connect + await driver.driver.get(TEST_SNAPS_WEBSITE_URL); + + // wait for page to load + await driver.waitForSelector({ + text: 'Installed Snaps', + tag: 'h2', + }); + // find and scroll to the transaction-insights test snap + const snapButton1 = await driver.findElement( + '#connecttransaction-insights', + ); + await driver.scrollToElement(snapButton1); + // added delay for firefox (deflake) + await driver.delayFirefox(1000); + // wait for and click connect + await driver.waitForSelector('#connecttransaction-insights'); + await driver.clickElement('#connecttransaction-insights'); + // switch to metamask extension + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and click connect + await driver.waitForSelector({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + // wait for and click confirm + await driver.waitForSelector({ text: 'Confirm' }); + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); + // wait for and click ok and wait for window to close + await driver.waitForSelector({ text: 'OK' }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'OK', + tag: 'button', + }); + // switch to test-snaps page and get accounts + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + // click get accounts + await driver.clickElement('#getAccounts'); + // switch back to MetaMask window + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and click next and wait for window to close + await driver.waitForSelector({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + // switch to test-snaps page + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + // click send tx + await driver.clickElement('#sendInsights'); + // delay added for rendering (deflake) + await driver.delay(2000); + // switch back to MetaMask window + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and switch to insight snap pane + await driver.waitForSelector({ + text: 'Insights Example Snap', + tag: 'button', + }); + await driver.clickElement({ + text: 'Insights Example Snap', + tag: 'button', + }); + // check that txinsightstest tab contains the right info + await driver.waitForSelector({ + css: '.snap-ui-renderer__content', + text: 'ERC-20', + }); + }, + ); + }); + }); + + describe('Redesigned confirmation screens', function () { + it('tests tx insights functionality', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // navigate to test snaps page and connect + await driver.driver.get(TEST_SNAPS_WEBSITE_URL); + + // wait for page to load + await driver.waitForSelector({ + text: 'Installed Snaps', + tag: 'h2', + }); + + // find and scroll to the transaction-insights test snap + const snapButton1 = await driver.findElement( + '#connecttransaction-insights', + ); + await driver.scrollToElement(snapButton1); + + // added delay for firefox (deflake) + await driver.delayFirefox(1000); + + // wait for and click connect + await driver.waitForSelector('#connecttransaction-insights'); + await driver.clickElement('#connecttransaction-insights'); + + // switch to metamask extension + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // wait for and click connect + await driver.waitForSelector({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + // wait for and click confirm + await driver.waitForSelector({ text: 'Confirm' }); + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); + + // wait for and click ok and wait for window to close + await driver.waitForSelector({ text: 'OK' }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'OK', + tag: 'button', + }); + + // switch to test-snaps page and get accounts + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + + // click get accounts + await driver.clickElement('#getAccounts'); + + // switch back to MetaMask window + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // wait for and click next and wait for window to close + await driver.waitForSelector({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // switch to test-snaps page + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + + // click send tx + await driver.clickElement('#sendInsights'); + + // delay added for rendering (deflake) + await driver.delay(2000); + + // switch back to MetaMask window + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // wait for and switch to insight snap pane + await driver.waitForSelector({ + text: 'Insights Example Snap', + tag: 'span', + }); + + // check that txinsightstest tab contains the right info + await driver.waitForSelector({ + css: 'p', + text: 'ERC-20', + }); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js index 23c1c27ea222..8dba11b86646 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js @@ -14,127 +14,245 @@ const { const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on different networks', function () { - it('should batch confirmation txs for different dapps on different networks.', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation screens', function () { + it('should batch confirmation txs for different dapps on different networks.', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); + async ({ driver }) => { + await unlockWallet(driver); - await tempToggleSettingRedesignedTransactionConfirmations(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); - // Connect to dapp 1 - await driver.clickElement({ text: 'Connect', tag: 'button' }); + // Connect to dapp 1 + await driver.clickElement({ text: 'Connect', tag: 'button' }); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); - // Network Selector - await driver.clickElement('[data-testid="network-display"]'); + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); - // Switch to second network - await driver.clickElement({ - text: 'Localhost 8546', - css: 'p', - }); + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); - // Wait for the first dapp's connect confirmation to disappear - await driver.waitUntilXWindowHandles(2); + // Wait for the first dapp's connect confirmation to disappear + await driver.waitUntilXWindowHandles(2); - // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. - // Open Dapp Two - await openDapp(driver, undefined, DAPP_ONE_URL); + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); - // Connect to dapp 2 - await driver.clickElement({ text: 'Connect', tag: 'button' }); + // Connect to dapp 2 + await driver.clickElement({ text: 'Connect', tag: 'button' }); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); - // Dapp one send tx - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.delay(largeDelayMs); - await driver.clickElement('#sendButton'); - await driver.clickElement('#sendButton'); + // Dapp one send tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); - await driver.delay(largeDelayMs); + await driver.delay(largeDelayMs); - // Dapp two send tx - await driver.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.delay(largeDelayMs); - await driver.clickElement('#sendButton'); - await driver.clickElement('#sendButton'); + // Dapp two send tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.waitForSelector( - By.xpath("//div[normalize-space(.)='1 of 2']"), - ); + await driver.waitForSelector( + By.xpath("//div[normalize-space(.)='1 of 2']"), + ); - // Reject All Transactions - await driver.clickElement('.page-container__footer-secondary a'); + // Reject All Transactions + await driver.clickElement('.page-container__footer-secondary a'); - // TODO: Do we want to confirm here? - await driver.clickElementAndWaitForWindowToClose({ - text: 'Reject all', - tag: 'button', - }); + // TODO: Do we want to confirm here? + await driver.clickElementAndWaitForWindowToClose({ + text: 'Reject all', + tag: 'button', + }); - // Wait for confirmation to close - // TODO: find a better way to handle different dialog ids - await driver.delay(2000); + // Wait for confirmation to close + // TODO: find a better way to handle different dialog ids + await driver.delay(2000); - // Wait for new confirmations queued from second dapp to open - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // Wait for new confirmations queued from second dapp to open + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.waitForSelector( - By.xpath("//div[normalize-space(.)='1 of 2']"), - ); + await driver.waitForSelector( + By.xpath("//div[normalize-space(.)='1 of 2']"), + ); - // Check correct network on confirm tx. - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 8546', - }); - }, - ); + // Check correct network on confirm tx. + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8546', + }); + }, + ); + }); + }); + + describe('Redesigned confirmation screens', function () { + it('should batch confirmation txs for different dapps on different networks.', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + + async ({ driver }) => { + await unlockWallet(driver); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Connect to dapp 1 + await driver.clickElement({ text: 'Connect', tag: 'button' }); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); + + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); + + // Wait for the first dapp's connect confirmation to disappear + await driver.waitUntilXWindowHandles(2); + + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + // Connect to dapp 2 + await driver.clickElement({ text: 'Connect', tag: 'button' }); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Dapp one send tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); + + await driver.delay(largeDelayMs); + + // Dapp two send tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.waitForSelector( + By.xpath("//p[normalize-space(.)='1 of 2']"), + ); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Reject all', + tag: 'button', + }); + + // Wait for confirmation to close + await driver.delay(2000); + + // Wait for new confirmations queued from second dapp to open + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.waitForSelector( + By.xpath("//p[normalize-space(.)='1 of 2']"), + ); + + // Check correct network on confirm tx. + await driver.findElement({ + css: 'p', + text: 'Localhost 8546', + }); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js index ea163ae6c9cd..bdbceed0be58 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js @@ -14,167 +14,325 @@ const { const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on different networks', function () { - it('should batch confirmation txs for different dapps on different networks adds extra tx after.', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation flows', function () { + it('should batch confirmation txs for different dapps on different networks adds extra tx after.', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); - - // Connect to dapp 1 - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElement({ - text: 'Connect', - tag: 'button', - }); - - await driver.switchToWindowWithUrl(DAPP_URL); - - const switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x53a' }], - }); - - // Ensure Dapp One is on Localhost 8546 - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); - - // Should auto switch without prompt since already approved via connect - - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - - // Wait for the first dapp's connect confirmation to disappear - await driver.waitUntilXWindowHandles(2); - - // Open Dapp Two - await openDapp(driver, undefined, DAPP_ONE_URL); - - // Connect to dapp 2 - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElement({ - text: 'Connect', - tag: 'button', - }); - - // Dapp 1 send 2 tx - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.findElement({ - css: '[id="chainId"]', - text: '0x53a', - }); - await driver.clickElement('#sendButton'); - await driver.clickElement('#sendButton'); - - await driver.waitUntilXWindowHandles(4); - - // Dapp 2 send 2 tx - await driver.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.findElement({ - css: '[id="chainId"]', - text: '0x53a', - }); - await driver.clickElement('#sendButton'); - await driver.clickElement('#sendButton'); - // We cannot wait for the dialog, since it is already opened from before - await driver.delay(largeDelayMs); - - // Dapp 1 send 1 tx - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.findElement({ - css: '[id="chainId"]', - text: '0x53a', - }); - await driver.clickElement('#sendButton'); - // We cannot switch directly, as the dialog is sometimes closed and re-opened - await driver.delay(largeDelayMs); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.waitForSelector( - By.xpath("//div[normalize-space(.)='1 of 2']"), - ); - - // Reject All Transactions - await driver.clickElement('.page-container__footer-secondary a'); - - // TODO: Do we want to confirm here? - await driver.clickElementAndWaitForWindowToClose({ - text: 'Reject all', - tag: 'button', - }); - - await driver.switchToWindowWithUrl(DAPP_URL); - - // Wait for new confirmations queued from second dapp to open - // We need a big delay to make sure dialog is not invalidated - // TODO: find a better way to handle different dialog ids - await driver.delay(2000); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.waitForSelector( - By.xpath("//div[normalize-space(.)='1 of 2']"), - ); - - // Check correct network on confirm tx. - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 8546', - }); - - // Reject All Transactions - await driver.clickElement('.page-container__footer-secondary a'); - - await driver.clickElementAndWaitForWindowToClose({ - text: 'Reject all', - tag: 'button', - }); - - // Wait for new confirmations queued from second dapp to open - // We need a big delay to make sure dialog is not invalidated - // TODO: find a better way to handle different dialog ids - await driver.delay(2000); - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - }, - ); + + async ({ driver }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Connect to dapp 1 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_URL); + + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x53a' }], + }); + + // Ensure Dapp One is on Localhost 8546 + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + // Should auto switch without prompt since already approved via connect + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Wait for the first dapp's connect confirmation to disappear + await driver.waitUntilXWindowHandles(2); + + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + // Connect to dapp 2 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + // Dapp 1 send 2 tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x53a', + }); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); + + await driver.waitUntilXWindowHandles(4); + + // Dapp 2 send 2 tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x53a', + }); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); + // We cannot wait for the dialog, since it is already opened from before + await driver.delay(largeDelayMs); + + // Dapp 1 send 1 tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x53a', + }); + await driver.clickElement('#sendButton'); + // We cannot switch directly, as the dialog is sometimes closed and re-opened + await driver.delay(largeDelayMs); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.waitForSelector( + By.xpath("//div[normalize-space(.)='1 of 2']"), + ); + + // Reject All Transactions + await driver.clickElement('.page-container__footer-secondary a'); + + // TODO: Do we want to confirm here? + await driver.clickElementAndWaitForWindowToClose({ + text: 'Reject all', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_URL); + + // Wait for new confirmations queued from second dapp to open + // We need a big delay to make sure dialog is not invalidated + // TODO: find a better way to handle different dialog ids + await driver.delay(2000); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.waitForSelector( + By.xpath("//div[normalize-space(.)='1 of 2']"), + ); + + // Check correct network on confirm tx. + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8546', + }); + + // Reject All Transactions + await driver.clickElement('.page-container__footer-secondary a'); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Reject all', + tag: 'button', + }); + + // Wait for new confirmations queued from second dapp to open + // We need a big delay to make sure dialog is not invalidated + // TODO: find a better way to handle different dialog ids + await driver.delay(2000); + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + }, + ); + }); + }); + + describe('Redesigned confirmation flows', function () { + it('should batch confirmation txs for different dapps on different networks adds extra tx after.', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + + async ({ driver }) => { + await unlockWallet(driver); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Connect to dapp 1 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_URL); + + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x53a' }], + }); + + // Ensure Dapp One is on Localhost 8546 + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + // Should auto switch without prompt since already approved via connect + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Wait for the first dapp's connect confirmation to disappear + await driver.waitUntilXWindowHandles(2); + + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + // Connect to dapp 2 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + // Dapp 1 send 2 tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x53a', + }); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); + + await driver.waitUntilXWindowHandles(4); + + // Dapp 2 send 2 tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x53a', + }); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); + // We cannot wait for the dialog, since it is already opened from before + await driver.delay(largeDelayMs); + + // Dapp 1 send 1 tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x53a', + }); + await driver.clickElement('#sendButton'); + // We cannot switch directly, as the dialog is sometimes closed and re-opened + await driver.delay(largeDelayMs); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.waitForSelector( + By.xpath("//p[normalize-space(.)='1 of 2']"), + ); + + // Reject All Transactions + await driver.clickElementAndWaitForWindowToClose({ + text: 'Reject all', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_URL); + + // Wait for new confirmations queued from second dapp to open + // We need a big delay to make sure dialog is not invalidated + // TODO: find a better way to handle different dialog ids + await driver.delay(2000); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.waitForSelector( + By.xpath("//p[normalize-space(.)='1 of 2']"), + ); + + // Check correct network on confirm tx. + await driver.findElement({ + css: 'p', + text: 'Localhost 8546', + }); + + // Reject All Transactions + await driver.clickElementAndWaitForWindowToClose({ + text: 'Reject all', + tag: 'button', + }); + + // Wait for new confirmations queued from second dapp to open + // We need a big delay to make sure dialog is not invalidated + // TODO: find a better way to handle different dialog ids + await driver.delay(2000); + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js index 98b125cc1116..991e497354d8 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js @@ -15,161 +15,316 @@ const { const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on same networks', function () { - it('should batch confirmation txs for different dapps on same networks ', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerTripleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - dappOptions: { numberOfDapps: 3 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - { - port: 7777, - chainId: 1000, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation screens', function () { + it('should batch confirmation txs for different dapps on same networks ', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + dappOptions: { numberOfDapps: 3 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); + async ({ driver }) => { + await unlockWallet(driver); - await tempToggleSettingRedesignedTransactionConfirmations(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); - // Connect to dapp 1 - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); + // Connect to dapp 1 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - await driver.delay(regularDelayMs); + await driver.delay(regularDelayMs); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.clickElement({ - text: 'Connect', - tag: 'button', - }); + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); - await driver.switchToWindowWithUrl(DAPP_URL); + await driver.switchToWindowWithUrl(DAPP_URL); - let switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x3e8' }], - }); + let switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x3e8' }], + }); - // Ensure Dapp One is on Localhost 7777 - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); + // Ensure Dapp One is on Localhost 7777 + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); - // Should auto switch without prompt since already approved via connect + // Should auto switch without prompt since already approved via connect - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); - // Wait for the first dapp's connect confirmation to disappear - await driver.waitUntilXWindowHandles(2); + // Wait for the first dapp's connect confirmation to disappear + await driver.waitUntilXWindowHandles(2); - // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. - // Open Dapp Two - await openDapp(driver, undefined, DAPP_ONE_URL); + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); - // Connect to dapp 2 - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); + // Connect to dapp 2 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - await driver.delay(regularDelayMs); + await driver.delay(regularDelayMs); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.clickElement({ - text: 'Connect', - tag: 'button', - }); + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); - await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.switchToWindowWithUrl(DAPP_ONE_URL); - switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x53a' }], - }); + switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x53a' }], + }); - // Ensure Dapp Two is on Localhost 8545 - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); + // Ensure Dapp Two is on Localhost 8545 + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); - // Should auto switch without prompt since already approved via connect + // Should auto switch without prompt since already approved via connect - // Dapp one send two tx - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.delay(largeDelayMs); - await driver.clickElement('#sendButton'); - await driver.clickElement('#sendButton'); + // Dapp one send two tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); - await driver.delay(largeDelayMs); + await driver.delay(largeDelayMs); - // Dapp two send two tx - await driver.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.delay(largeDelayMs); - await driver.clickElement('#sendButton'); - await driver.clickElement('#sendButton'); + // Dapp two send two tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.waitForSelector( - By.xpath("//div[normalize-space(.)='1 of 2']"), - ); + await driver.waitForSelector( + By.xpath("//div[normalize-space(.)='1 of 2']"), + ); - // Check correct network on confirm tx. - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 7777', - }); + // Check correct network on confirm tx. + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 7777', + }); - // Reject All Transactions - await driver.clickElement('.page-container__footer-secondary a'); + // Reject All Transactions + await driver.clickElement('.page-container__footer-secondary a'); - await driver.clickElement({ text: 'Reject all', tag: 'button' }); // TODO: Do we want to confirm here? + await driver.clickElement({ text: 'Reject all', tag: 'button' }); // TODO: Do we want to confirm here? - // Wait for confirmation to close - await driver.waitUntilXWindowHandles(4); + // Wait for confirmation to close + await driver.waitUntilXWindowHandles(4); - // Wait for new confirmations queued from second dapp to open - await driver.delay(largeDelayMs); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // Wait for new confirmations queued from second dapp to open + await driver.delay(largeDelayMs); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.waitForSelector( - By.xpath("//div[normalize-space(.)='1 of 2']"), - ); + await driver.waitForSelector( + By.xpath("//div[normalize-space(.)='1 of 2']"), + ); - // Check correct network on confirm tx. - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 8546', - }); - }, - ); + // Check correct network on confirm tx. + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8546', + }); + }, + ); + }); + }); + + describe('Redesigned confirmation screens', function () { + it('should batch confirmation txs for different dapps on same networks ', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + dappOptions: { numberOfDapps: 3 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + + async ({ driver }) => { + await unlockWallet(driver); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Connect to dapp 1 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.delay(regularDelayMs); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_URL); + + let switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x3e8' }], + }); + + // Ensure Dapp One is on Localhost 7777 + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + // Should auto switch without prompt since already approved via connect + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Wait for the first dapp's connect confirmation to disappear + await driver.waitUntilXWindowHandles(2); + + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + // Connect to dapp 2 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.delay(regularDelayMs); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + + switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x53a' }], + }); + + // Ensure Dapp Two is on Localhost 8545 + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + // Should auto switch without prompt since already approved via connect + + // Dapp one send two tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); + + await driver.delay(largeDelayMs); + + // Dapp two send two tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.waitForSelector( + By.xpath("//p[normalize-space(.)='1 of 2']"), + ); + + // Check correct network on confirm tx. + await driver.findElement({ + css: 'p', + text: 'Localhost 7777', + }); + + // Reject All Transactions + await driver.clickElement({ text: 'Reject all', tag: 'button' }); + + // Wait for confirmation to close + await driver.waitUntilXWindowHandles(4); + + // Wait for new confirmations queued from second dapp to open + await driver.delay(largeDelayMs); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.waitForSelector( + By.xpath("//p[normalize-space(.)='1 of 2']"), + ); + + // Check correct network on confirm tx. + await driver.findElement({ + css: 'p', + text: 'Localhost 8546', + }); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js b/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js index e2e53e4f51ca..b574d3f9f0e3 100644 --- a/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js @@ -15,153 +15,298 @@ const { const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { - it('should queue signTypedData tx after eth_sendTransaction confirmation and signTypedData confirmation should target the correct network after eth_sendTransaction is confirmed @no-mmi', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerTripleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .withSelectedNetworkControllerPerDomain() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - { - port: 7777, - chainId: 1000, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation screens', function () { + it('should queue signTypedData tx after eth_sendTransaction confirmation and signTypedData confirmation should target the correct network after eth_sendTransaction is confirmed @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withSelectedNetworkControllerPerDomain() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - await tempToggleSettingRedesignedConfirmations(driver); + async ({ driver }) => { + await unlockWallet(driver); + await tempToggleSettingRedesignedConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); - await tempToggleSettingRedesignedTransactionConfirmations(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); - // Open and connect Dapp One - await openDapp(driver, undefined, DAPP_URL); - - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.delay(regularDelayMs); - - await driver.waitUntilXWindowHandles(3); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); - // Open and connect to Dapp Two - await openDapp(driver, undefined, DAPP_ONE_URL); - - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.delay(regularDelayMs); - - await driver.waitUntilXWindowHandles(4); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElement({ - text: 'Connect', - tag: 'button', - }); - - // Switch Dapp Two to Localhost 8546 - await driver.switchToWindowWithUrl(DAPP_ONE_URL); - let switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x53a' }], - }); - - // Initiate switchEthereumChain on Dapp one - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); - - await driver.waitForSelector({ - css: '[id="chainId"]', - text: '0x53a', - }); - - // Should auto switch without prompt since already approved via connect - - // Switch back to Dapp One - await driver.switchToWindowWithUrl(DAPP_URL); - - // switch chain for Dapp One - switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x3e8' }], - }); - - // Initiate switchEthereumChain on Dapp one - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); - await driver.waitForSelector({ - css: '[id="chainId"]', - text: '0x3e8', - }); - // Should auto switch without prompt since already approved via connect - - await driver.switchToWindowWithUrl(DAPP_URL); - - // eth_sendTransaction request - await driver.clickElement('#sendButton'); - await driver.waitUntilXWindowHandles(3); - - await driver.switchToWindowWithUrl(DAPP_ONE_URL); - - // signTypedData request - await driver.clickElement('#signTypedData'); - - await driver.waitUntilXWindowHandles(4); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // Check correct network on the send confirmation. - await driver.waitForSelector({ - css: '[data-testid="network-display"]', - text: 'Localhost 7777', - }); + // Open and connect Dapp One + await openDapp(driver, undefined, DAPP_URL); - await driver.clickElement({ text: 'Confirm', tag: 'button' }); + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - await driver.delay(largeDelayMs); - await driver.waitUntilXWindowHandles(4); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // Check correct network on the signTypedData confirmation. - await driver.waitForSelector({ - css: '[data-testid="signature-request-network-display"]', - text: 'Localhost 8546', - }); - - await driver.clickElement({ text: 'Reject', tag: 'button' }); - }, - ); + await driver.delay(regularDelayMs); + + await driver.waitUntilXWindowHandles(3); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + // Open and connect to Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.delay(regularDelayMs); + + await driver.waitUntilXWindowHandles(4); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + // Switch Dapp Two to Localhost 8546 + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + let switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x53a' }], + }); + + // Initiate switchEthereumChain on Dapp one + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + await driver.waitForSelector({ + css: '[id="chainId"]', + text: '0x53a', + }); + + // Should auto switch without prompt since already approved via connect + + // Switch back to Dapp One + await driver.switchToWindowWithUrl(DAPP_URL); + + // switch chain for Dapp One + switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x3e8' }], + }); + + // Initiate switchEthereumChain on Dapp one + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + await driver.waitForSelector({ + css: '[id="chainId"]', + text: '0x3e8', + }); + // Should auto switch without prompt since already approved via connect + + await driver.switchToWindowWithUrl(DAPP_URL); + + // eth_sendTransaction request + await driver.clickElement('#sendButton'); + await driver.waitUntilXWindowHandles(3); + + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + + // signTypedData request + await driver.clickElement('#signTypedData'); + + await driver.waitUntilXWindowHandles(4); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Check correct network on the send confirmation. + await driver.waitForSelector({ + css: '[data-testid="network-display"]', + text: 'Localhost 7777', + }); + + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + + await driver.delay(largeDelayMs); + await driver.waitUntilXWindowHandles(4); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Check correct network on the signTypedData confirmation. + await driver.waitForSelector({ + css: '[data-testid="signature-request-network-display"]', + text: 'Localhost 8546', + }); + + await driver.clickElement({ text: 'Reject', tag: 'button' }); + }, + ); + }); + }); + + describe('Redesigned confirmation screens', function () { + it('should queue signTypedData tx after eth_sendTransaction confirmation and signTypedData confirmation should target the correct network after eth_sendTransaction is confirmed @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withSelectedNetworkControllerPerDomain() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open and connect Dapp One + await openDapp(driver, undefined, DAPP_URL); + + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.delay(regularDelayMs); + + await driver.waitUntilXWindowHandles(3); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + // Open and connect to Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.delay(regularDelayMs); + + await driver.waitUntilXWindowHandles(4); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + // Switch Dapp Two to Localhost 8546 + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + let switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x53a' }], + }); + + // Initiate switchEthereumChain on Dapp one + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + await driver.waitForSelector({ + css: '[id="chainId"]', + text: '0x53a', + }); + + // Should auto switch without prompt since already approved via connect + + // Switch back to Dapp One + await driver.switchToWindowWithUrl(DAPP_URL); + + // switch chain for Dapp One + switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x3e8' }], + }); + + // Initiate switchEthereumChain on Dapp one + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + await driver.waitForSelector({ + css: '[id="chainId"]', + text: '0x3e8', + }); + // Should auto switch without prompt since already approved via connect + + await driver.switchToWindowWithUrl(DAPP_URL); + + // eth_sendTransaction request + await driver.clickElement('#sendButton'); + await driver.waitUntilXWindowHandles(3); + + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + + // signTypedData request + await driver.clickElement('#signTypedData'); + + await driver.waitUntilXWindowHandles(4); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Check correct network on the send confirmation. + await driver.waitForSelector({ + css: 'p', + text: 'Localhost 7777', + }); + + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + + await driver.delay(largeDelayMs); + await driver.waitUntilXWindowHandles(4); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Check correct network on the signTypedData confirmation. + await driver.waitForSelector({ + css: 'p', + text: 'Localhost 8546', + }); + + await driver.clickElement({ text: 'Cancel', tag: 'button' }); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js index d37be3d483ac..58597ee790d9 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js @@ -14,149 +14,244 @@ const { const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing Dapp 1 Send Tx -> Dapp 2 Request Accounts Tx', function () { - it('should queue `eth_requestAccounts` requests when the requesting dapp does not already have connected accounts', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .withPermissionControllerConnectedToTestDapp() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation screens', function () { + it('should queue `eth_requestAccounts` requests when the requesting dapp does not already have connected accounts', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withPermissionControllerConnectedToTestDapp() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); - - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); - - // Dapp Send Button - await driver.clickElement('#sendButton'); - await driver.delay(regularDelayMs); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.waitForSelector({ - text: 'Reject', - tag: 'button', - }); - - await driver.delay(regularDelayMs); - - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - - // Leave the confirmation pending - await openDapp(driver, undefined, DAPP_ONE_URL); - - const accountsOnload = await ( - await driver.findElement('#accounts') - ).getText(); - assert.deepStrictEqual(accountsOnload, ''); - - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); - - await driver.delay(regularDelayMs); - - const accountsBeforeConnect = await ( - await driver.findElement('#accounts') - ).getText(); - assert.deepStrictEqual(accountsBeforeConnect, ''); - - // Reject the pending confirmation from the first dapp - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Reject', - tag: 'button', - }); - - // Wait for switch confirmation to close then request accounts confirmation to show for the second dapp - await driver.delay(regularDelayMs); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElement({ - text: 'Connect', - tag: 'button', - }); - - await driver.switchToWindowWithUrl(DAPP_ONE_URL); - - await driver.waitForSelector({ - text: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1', - css: '#accounts', - }); - }, - ); + async ({ driver }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.navigate(PAGES.HOME); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Dapp Send Button + await driver.clickElement('#sendButton'); + await driver.delay(regularDelayMs); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.waitForSelector({ + text: 'Reject', + tag: 'button', + }); + + await driver.delay(regularDelayMs); + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Leave the confirmation pending + await openDapp(driver, undefined, DAPP_ONE_URL); + + const accountsOnload = await ( + await driver.findElement('#accounts') + ).getText(); + assert.deepStrictEqual(accountsOnload, ''); + + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.delay(regularDelayMs); + + const accountsBeforeConnect = await ( + await driver.findElement('#accounts') + ).getText(); + assert.deepStrictEqual(accountsBeforeConnect, ''); + + // Reject the pending confirmation from the first dapp + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Reject', + tag: 'button', + }); + + // Wait for switch confirmation to close then request accounts confirmation to show for the second dapp + await driver.delay(regularDelayMs); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + + await driver.waitForSelector({ + text: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1', + css: '#accounts', + }); + }, + ); + }); }); - it('should not queue the `eth_requestAccounts` requests when the requesting dapp already has connected accounts', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .withPermissionControllerConnectedToTwoTestDapps() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Redesigned confirmation screens', function () { + it('should queue `eth_requestAccounts` requests when the requesting dapp does not already have connected accounts', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withPermissionControllerConnectedToTestDapp() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); + async ({ driver }) => { + await unlockWallet(driver); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Dapp Send Button + await driver.clickElement('#sendButton'); + await driver.delay(regularDelayMs); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); + await driver.waitForSelector({ + text: 'Cancel', + tag: 'button', + }); - // Dapp Send Button - await driver.clickElement('#sendButton'); + await driver.delay(regularDelayMs); - // Leave the confirmation pending + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); - await openDapp(driver, undefined, DAPP_ONE_URL); + // Leave the confirmation pending + await openDapp(driver, undefined, DAPP_ONE_URL); - const ethRequestAccounts = JSON.stringify({ - jsonrpc: '2.0', - method: 'eth_requestAccounts', - }); + const accountsOnload = await ( + await driver.findElement('#accounts') + ).getText(); + assert.deepStrictEqual(accountsOnload, ''); - const accounts = await driver.executeScript( - `return window.ethereum.request(${ethRequestAccounts})`, - ); + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - assert.deepStrictEqual(accounts, [ - '0x5cfe73b6021e818b776b421b1c4db2474086a7e1', - ]); - }, - ); + await driver.delay(regularDelayMs); + + const accountsBeforeConnect = await ( + await driver.findElement('#accounts') + ).getText(); + assert.deepStrictEqual(accountsBeforeConnect, ''); + + // Reject the pending confirmation from the first dapp + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Cancel', + tag: 'button', + }); + + // Wait for switch confirmation to close then request accounts confirmation to show for the second dapp + await driver.delay(regularDelayMs); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + + await driver.waitForSelector({ + text: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1', + css: '#accounts', + }); + }, + ); + }); + + it('should not queue the `eth_requestAccounts` requests when the requesting dapp already has connected accounts', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withPermissionControllerConnectedToTwoTestDapps() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Dapp Send Button + await driver.clickElement('#sendButton'); + + // Leave the confirmation pending + + await openDapp(driver, undefined, DAPP_ONE_URL); + + const ethRequestAccounts = JSON.stringify({ + jsonrpc: '2.0', + method: 'eth_requestAccounts', + }); + + const accounts = await driver.executeScript( + `return window.ethereum.request(${ethRequestAccounts})`, + ); + + assert.deepStrictEqual(accounts, [ + '0x5cfe73b6021e818b776b421b1c4db2474086a7e1', + ]); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js index 650d39089d3a..31ce249d60b4 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js @@ -12,311 +12,621 @@ const { const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { - it('should queue send tx after switch network confirmation and transaction should target the correct network after switch is confirmed', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerTripleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .withSelectedNetworkControllerPerDomain() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - { - port: 7777, - chainId: 1000, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation screens', function () { + it('should queue send tx after switch network confirmation and transaction should target the correct network after switch is confirmed', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withSelectedNetworkControllerPerDomain() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); + async ({ driver }) => { + await unlockWallet(driver); - await tempToggleSettingRedesignedTransactionConfirmations(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); - // Connect to dapp - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); + // Connect to dapp + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - const editButtons = await driver.findElements('[data-testid="edit"]'); + const editButtons = await driver.findElements('[data-testid="edit"]'); - await editButtons[1].click(); + await editButtons[1].click(); - // Disconnect Localhost 8545 - await driver.clickElement({ - text: 'Localhost 8545', - tag: 'p', - }); + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); - await driver.clickElement('[data-testid="connect-more-chains-button"]'); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + await driver.clickElement( + '[data-testid="connect-more-chains-button"]', + ); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); - // Network Selector - await driver.clickElement('[data-testid="network-display"]'); + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); - // Switch to second network - await driver.clickElement({ - text: 'Localhost 8546', - css: 'p', - }); + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); - // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. - // Open Dapp Two - await openDapp(driver, undefined, DAPP_ONE_URL); + // Connect to dapp 2 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - // Connect to dapp 2 - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + await driver.switchToWindowWithUrl(DAPP_URL); - await driver.switchToWindowWithUrl(DAPP_URL); + // switchEthereumChain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x539' }], + }); - // switchEthereumChain request - const switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x539' }], - }); + // Initiate switchEthereumChain on Dapp One + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.findElement({ + text: 'Use your enabled networks', + tag: 'p', + }); - // Initiate switchEthereumChain on Dapp One - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); + await driver.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.findElement({ - text: 'Use your enabled networks', - tag: 'p', - }); + await driver.clickElement('#sendButton'); - await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.clickElement('#sendButton'); + await driver.clickElement({ text: 'Confirm', tag: 'button' }); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.clickElement({ text: 'Confirm', tag: 'button' }); + // Wait for switch confirmation to close then tx confirmation to show. + // There is an extra window appearing and disappearing + // so we leave this delay until the issue is fixed (#27360) + await driver.delay(5000); - await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - // Wait for switch confirmation to close then tx confirmation to show. - // There is an extra window appearing and disappearing - // so we leave this delay until the issue is fixed (#27360) - await driver.delay(5000); + // Check correct network on the send confirmation. + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8546', + }); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Confirm', + tag: 'button', + }); - // Check correct network on the send confirmation. - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 8546', - }); + // Switch back to the extension + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + await driver.clickElement( + '[data-testid="account-overview__activity-tab"]', + ); + + // Check for transaction + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .activity-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + }, + ); + }); + + it('should queue send tx after switch network confirmation and transaction should target the correct network after switch is cancelled.', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withSelectedNetworkControllerPerDomain() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Confirm', - tag: 'button', - }); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Switch back to the extension - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); - await driver.clickElement( - '[data-testid="account-overview__activity-tab"]', - ); + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); - // Check for transaction - await driver.wait(async () => { - const confirmedTxes = await driver.findElements( - '.transaction-list__completed-transactions .activity-list-item', + // Connect to dapp + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + await editButtons[1].click(); + + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + + await driver.clickElement( + '[data-testid="connect-more-chains-button"]', + ); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, ); - return confirmedTxes.length === 1; - }, 10000); - }, - ); + + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); + + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); + + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + // Connect to dapp 2 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_URL); + + // switchEthereumChain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x539' }], + }); + + // Initiate switchEthereumChain on Dapp One + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + + await driver.clickElement('#sendButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ text: 'Cancel', tag: 'button' }); + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + + // Wait for switch confirmation to close then tx confirmation to show. + // There is an extra window appearing and disappearing + // so we leave this delay until the issue is fixed (#27360) + await driver.delay(5000); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Check correct network on the send confirmation. + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8546', + }); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Confirm', + tag: 'button', + }); + + // Switch back to the extension + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + await driver.clickElement( + '[data-testid="account-overview__activity-tab"]', + ); + + // Check for transaction + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .activity-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + }, + ); + }); }); - it('should queue send tx after switch network confirmation and transaction should target the correct network after switch is cancelled.', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerTripleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .withSelectedNetworkControllerPerDomain() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - { - port: 7777, - chainId: 1000, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Redesigned confirmation screens', function () { + it('should queue send tx after switch network confirmation and transaction should target the correct network after switch is confirmed', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withSelectedNetworkControllerPerDomain() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); + async ({ driver }) => { + await unlockWallet(driver); - await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + // Connect to dapp + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - // Connect to dapp - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); + const editButtons = await driver.findElements('[data-testid="edit"]'); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - const editButtons = await driver.findElements('[data-testid="edit"]'); + await editButtons[1].click(); - await editButtons[1].click(); + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); - // Disconnect Localhost 8545 - await driver.clickElement({ - text: 'Localhost 8545', - tag: 'p', - }); + await driver.clickElement( + '[data-testid="connect-more-chains-button"]', + ); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); + + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); + + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + // Connect to dapp 2 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithUrl(DAPP_URL); + + // switchEthereumChain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x539' }], + }); + + // Initiate switchEthereumChain on Dapp One + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.findElement({ + text: 'Use your enabled networks', + tag: 'p', + }); + + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + + await driver.clickElement('#sendButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + + // Wait for switch confirmation to close then tx confirmation to show. + // There is an extra window appearing and disappearing + // so we leave this delay until the issue is fixed (#27360) + await driver.delay(5000); - await driver.clickElement('[data-testid="connect-more-chains-button"]'); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + // Check correct network on the send confirmation. + await driver.findElement({ + css: 'p', + text: 'Localhost 8546', + }); - // Network Selector - await driver.clickElement('[data-testid="network-display"]'); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Confirm', + tag: 'button', + }); - // Switch to second network - await driver.clickElement({ - text: 'Localhost 8546', - css: 'p', - }); + // Switch back to the extension + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + await driver.clickElement( + '[data-testid="account-overview__activity-tab"]', + ); + + // Check for transaction + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .activity-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + }, + ); + }); + + it('should queue send tx after switch network confirmation and transaction should target the correct network after switch is cancelled.', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withSelectedNetworkControllerPerDomain() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Connect to dapp + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + await editButtons[1].click(); - // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. - // Open Dapp Two - await openDapp(driver, undefined, DAPP_ONE_URL); + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); - // Connect to dapp 2 - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); + await driver.clickElement( + '[data-testid="connect-more-chains-button"]', + ); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); + + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + // Connect to dapp 2 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - await driver.switchToWindowWithUrl(DAPP_URL); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - // switchEthereumChain request - const switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x539' }], - }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); - // Initiate switchEthereumChain on Dapp One - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); + await driver.switchToWindowWithUrl(DAPP_URL); - await driver.switchToWindowWithUrl(DAPP_ONE_URL); + // switchEthereumChain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x539' }], + }); - await driver.clickElement('#sendButton'); + // Initiate switchEthereumChain on Dapp One + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, + ); + + await driver.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.clickElement('#sendButton'); - await driver.clickElement({ text: 'Cancel', tag: 'button' }); - await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - // Wait for switch confirmation to close then tx confirmation to show. - // There is an extra window appearing and disappearing - // so we leave this delay until the issue is fixed (#27360) - await driver.delay(5000); + await driver.clickElement({ text: 'Cancel', tag: 'button' }); + await driver.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // Wait for switch confirmation to close then tx confirmation to show. + // There is an extra window appearing and disappearing + // so we leave this delay until the issue is fixed (#27360) + await driver.delay(5000); - // Check correct network on the send confirmation. - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 8546', - }); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Confirm', - tag: 'button', - }); + // Check correct network on the send confirmation. + await driver.findElement({ + css: 'p', + text: 'Localhost 8546', + }); - // Switch back to the extension - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Confirm', + tag: 'button', + }); - await driver.clickElement( - '[data-testid="account-overview__activity-tab"]', - ); + // Switch back to the extension + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); - // Check for transaction - await driver.wait(async () => { - const confirmedTxes = await driver.findElements( - '.transaction-list__completed-transactions .activity-list-item', + await driver.clickElement( + '[data-testid="account-overview__activity-tab"]', ); - return confirmedTxes.length === 1; - }, 10000); - }, - ); + + // Check for transaction + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .activity-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js index d75c9c2ca1ff..7e7e4c81d3a9 100644 --- a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js +++ b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js @@ -12,125 +12,246 @@ const { const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on different networks revokePermissions', function () { - it('should close transaction for revoked permission of eth_accounts but show queued tx from second dapp on a different network.', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation screens', function () { + it('should close transaction for revoked permission of eth_accounts but show queued tx from second dapp on a different network.', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); - - // Connect to dapp 1 - await driver.clickElement({ text: 'Connect', tag: 'button' }); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - - // Network Selector - await driver.clickElement('[data-testid="network-display"]'); - - // Switch to second network - await driver.clickElement({ - text: 'Localhost 8546', - css: 'p', - }); - - // Wait for the first dapp's connect confirmation to disappear - await driver.waitUntilXWindowHandles(2); - - // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. - // Open Dapp Two - await openDapp(driver, undefined, DAPP_ONE_URL); - - // Connect to dapp 2 - await driver.clickElement({ text: 'Connect', tag: 'button' }); - - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - // Dapp 1 send tx - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.findElement({ - css: '[id="chainId"]', - text: '0x539', - }); - await driver.clickElement('#sendButton'); - - await driver.waitUntilXWindowHandles(4); - await driver.delay(3000); - - // Dapp 2 send tx - await driver.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.findElement({ - css: '[id="chainId"]', - text: '0x53a', - }); - await driver.clickElement('#sendButton'); - await driver.waitUntilXWindowHandles(4); - - // Dapp 1 revokePermissions - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.findElement({ - css: '[id="chainId"]', - text: '0x539', - }); - await driver.assertElementNotPresent({ - css: '[id="chainId"]', - text: '0x53a', - }); - - // Confirmation will close then reopen - await driver.clickElement('#revokeAccountsPermission'); - // TODO: find a better way to handle different dialog ids - await driver.delay(3000); - - // Check correct network on confirm tx. - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 8546', - }); - }, - ); + + async ({ driver }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Connect to dapp 1 + await driver.clickElement({ text: 'Connect', tag: 'button' }); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); + + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); + + // Wait for the first dapp's connect confirmation to disappear + await driver.waitUntilXWindowHandles(2); + + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + // Connect to dapp 2 + await driver.clickElement({ text: 'Connect', tag: 'button' }); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Dapp 1 send tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x539', + }); + await driver.clickElement('#sendButton'); + + await driver.waitUntilXWindowHandles(4); + await driver.delay(3000); + + // Dapp 2 send tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x53a', + }); + await driver.clickElement('#sendButton'); + await driver.waitUntilXWindowHandles(4); + + // Dapp 1 revokePermissions + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x539', + }); + await driver.assertElementNotPresent({ + css: '[id="chainId"]', + text: '0x53a', + }); + + // Confirmation will close then reopen + await driver.clickElement('#revokeAccountsPermission'); + // TODO: find a better way to handle different dialog ids + await driver.delay(3000); + + // Check correct network on confirm tx. + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8546', + }); + }, + ); + }); + }); + + describe('New confirmation screens', function () { + it('should close transaction for revoked permission of eth_accounts but show queued tx from second dapp on a different network.', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + + async ({ driver }) => { + await unlockWallet(driver); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); + + // Connect to dapp 1 + await driver.clickElement({ text: 'Connect', tag: 'button' }); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); + + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); + + // Wait for the first dapp's connect confirmation to disappear + await driver.waitUntilXWindowHandles(2); + + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + // Connect to dapp 2 + await driver.clickElement({ text: 'Connect', tag: 'button' }); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Dapp 1 send tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x539', + }); + await driver.clickElement('#sendButton'); + + await driver.waitUntilXWindowHandles(4); + await driver.delay(3000); + + // Dapp 2 send tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x53a', + }); + await driver.clickElement('#sendButton'); + await driver.waitUntilXWindowHandles(4); + + // Dapp 1 revokePermissions + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ + css: '[id="chainId"]', + text: '0x539', + }); + await driver.assertElementNotPresent({ + css: '[id="chainId"]', + text: '0x53a', + }); + + // Confirmation will close then reopen + await driver.clickElement('#revokeAccountsPermission'); + // TODO: find a better way to handle different dialog ids + await driver.delay(3000); + + // Check correct network on confirm tx. + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.findElement({ + css: 'p', + text: 'Localhost 8546', + }); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js b/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js index b2df1a954d83..87ec535316f2 100644 --- a/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js +++ b/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js @@ -13,140 +13,276 @@ const { const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on different networks.', function () { - it('should switch to the dapps network automatically when handling sendTransaction calls @no-mmi', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .withSelectedNetworkControllerPerDomain() - .build(), - dappOptions: { numberOfDapps: 2 }, - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation screens', function () { + it('should switch to the dapps network automatically when handling sendTransaction calls @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withSelectedNetworkControllerPerDomain() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); + async ({ driver }) => { + await unlockWallet(driver); - await tempToggleSettingRedesignedTransactionConfirmations(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); - // Connect to dapp 1 - await driver.clickElement({ text: 'Connect', tag: 'button' }); + // Connect to dapp 1 + await driver.clickElement({ text: 'Connect', tag: 'button' }); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); - // Network Selector - await driver.clickElement('[data-testid="network-display"]'); + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); - // Switch to second network - await driver.clickElement({ - text: 'Localhost 8546', - css: 'p', - }); + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); - // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. - // Open Dapp Two - await openDapp(driver, undefined, DAPP_ONE_URL); + // Connect to dapp 2 + await driver.clickElement({ text: 'Connect', tag: 'button' }); - // Connect to dapp 2 - await driver.clickElement({ text: 'Connect', tag: 'button' }); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + // Dapp one send tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); - // Dapp one send tx - await driver.switchToWindowWithUrl(DAPP_URL); - await driver.delay(largeDelayMs); - await driver.clickElement('#sendButton'); + await driver.waitUntilXWindowHandles(4); - await driver.waitUntilXWindowHandles(4); + // Dapp two send tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); - // Dapp two send tx - await driver.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.delay(largeDelayMs); - await driver.clickElement('#sendButton'); + // First switch network + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - // First switch network - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // Wait for confirm tx after switch network confirmation. + await driver.delay(largeDelayMs); - // Wait for confirm tx after switch network confirmation. - await driver.delay(largeDelayMs); + await driver.waitUntilXWindowHandles(4); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.waitUntilXWindowHandles(4); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // Reject Transaction + await driver.findClickableElement({ text: 'Reject', tag: 'button' }); + await driver.clickElement( + '[data-testid="page-container-footer-cancel"]', + ); - // Reject Transaction - await driver.findClickableElement({ text: 'Reject', tag: 'button' }); - await driver.clickElement( - '[data-testid="page-container-footer-cancel"]', - ); + // TODO: No second confirmation from dapp two will show, have to go back to the extension to see the switch chain & dapp two's tx. + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.clickElement( + '[data-testid="account-overview__activity-tab"]', + ); - // TODO: No second confirmation from dapp two will show, have to go back to the extension to see the switch chain & dapp two's tx. - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - await driver.clickElement( - '[data-testid="account-overview__activity-tab"]', - ); + // Check for unconfirmed transaction in tx list + await driver.wait(async () => { + const unconfirmedTxes = await driver.findElements( + '.transaction-list-item--unconfirmed', + ); + return unconfirmedTxes.length === 1; + }, 10000); - // Check for unconfirmed transaction in tx list - await driver.wait(async () => { - const unconfirmedTxes = await driver.findElements( - '.transaction-list-item--unconfirmed', + // Click Unconfirmed Tx + await driver.clickElement('.transaction-list-item--unconfirmed'); + + await driver.assertElementNotPresent({ + tag: 'p', + text: 'Network switched to Localhost 8546', + }); + + // Confirm Tx + await driver.clickElement( + '[data-testid="page-container-footer-next"]', ); - return unconfirmedTxes.length === 1; - }, 10000); - // Click Unconfirmed Tx - await driver.clickElement('.transaction-list-item--unconfirmed'); + // Check for Confirmed Transaction + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .activity-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + }, + ); + }); + }); + + describe('Redesigned confirmation screens', function () { + it('should switch to the dapps network automatically when handling sendTransaction calls @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .withSelectedNetworkControllerPerDomain() + .build(), + dappOptions: { numberOfDapps: 2 }, + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); - await driver.assertElementNotPresent({ - tag: 'p', - text: 'Network switched to Localhost 8546', - }); + // Connect to dapp 1 + await driver.clickElement({ text: 'Connect', tag: 'button' }); - // Confirm Tx - await driver.clickElement('[data-testid="page-container-footer-next"]'); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - // Check for Confirmed Transaction - await driver.wait(async () => { - const confirmedTxes = await driver.findElements( - '.transaction-list__completed-transactions .activity-list-item', + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, ); - return confirmedTxes.length === 1; - }, 10000); - }, - ); + + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); + + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); + + // TODO: Request Queuing bug when opening both dapps at the same time will have them stuck on the same network, with will be incorrect for one of them. + // Open Dapp Two + await openDapp(driver, undefined, DAPP_ONE_URL); + + // Connect to dapp 2 + await driver.clickElement({ text: 'Connect', tag: 'button' }); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Dapp one send tx + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + + await driver.waitUntilXWindowHandles(4); + + // Dapp two send tx + await driver.switchToWindowWithUrl(DAPP_ONE_URL); + await driver.delay(largeDelayMs); + await driver.clickElement('#sendButton'); + + // First switch network + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Wait for confirm tx after switch network confirmation. + await driver.delay(largeDelayMs); + + await driver.waitUntilXWindowHandles(4); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Reject Transaction + await driver.findClickableElement({ text: 'Cancel', tag: 'button' }); + await driver.clickElement({ text: 'Cancel', tag: 'button' }); + + // TODO: No second confirmation from dapp two will show, have to go back to the extension to see the switch chain & dapp two's tx. + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.clickElement( + '[data-testid="account-overview__activity-tab"]', + ); + + // Check for unconfirmed transaction in tx list + await driver.wait(async () => { + const unconfirmedTxes = await driver.findElements( + '.transaction-list-item--unconfirmed', + ); + return unconfirmedTxes.length === 1; + }, 10000); + + // Click Unconfirmed Tx + await driver.clickElement('.transaction-list-item--unconfirmed'); + + await driver.assertElementNotPresent({ + tag: 'p', + text: 'Network switched to Localhost 8546', + }); + + // Confirm Tx + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + + // Check for Confirmed Transaction + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .activity-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/switch-network.spec.js b/test/e2e/tests/request-queuing/switch-network.spec.js index 315f80df08f9..13143f6d342d 100644 --- a/test/e2e/tests/request-queuing/switch-network.spec.js +++ b/test/e2e/tests/request-queuing/switch-network.spec.js @@ -12,89 +12,176 @@ const { const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing Switch Network on Dapp Send Tx while on different networks.', function () { - it('should switch to the dapps network automatically when mm network differs, dapp tx is on correct network', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPermissionControllerConnectedToTestDapp() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation screens', function () { + it('should switch to the dapps network automatically when mm network differs, dapp tx is on correct network', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPermissionControllerConnectedToTestDapp() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); + async ({ driver }) => { + await unlockWallet(driver); - await tempToggleSettingRedesignedTransactionConfirmations(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); - // Open dapp - await openDapp(driver, undefined, DAPP_URL); + // Open dapp + await openDapp(driver, undefined, DAPP_URL); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); + + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + + // Queue confirm tx should first auto switch network + await driver.clickElement('#sendButton'); + + await driver.delay(regularDelayMs); + + await driver.waitUntilXWindowHandles(3); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Confirm Transaction + await driver.findClickableElement({ text: 'Confirm', tag: 'button' }); + await driver.clickElement( + '[data-testid="page-container-footer-next"]', + ); - // Network Selector - await driver.clickElement('[data-testid="network-display"]'); + await driver.delay(regularDelayMs); - // Switch to second network - await driver.clickElement({ - text: 'Localhost 8546', - css: 'p', - }); + // Switch back to the extension + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.navigate(PAGES.HOME); + + // Check correct network switched and on the correct network + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8545', + }); + + // Check for transaction + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .activity-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + }, + ); + }); + }); - await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + describe('Redesigned confirmation screens', function () { + it('should switch to the dapps network automatically when mm network differs, dapp tx is on correct network', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPermissionControllerConnectedToTestDapp() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); - // Queue confirm tx should first auto switch network - await driver.clickElement('#sendButton'); + // Open dapp + await openDapp(driver, undefined, DAPP_URL); - await driver.delay(regularDelayMs); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); - await driver.waitUntilXWindowHandles(3); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); - // Confirm Transaction - await driver.findClickableElement({ text: 'Confirm', tag: 'button' }); - await driver.clickElement('[data-testid="page-container-footer-next"]'); + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); - await driver.delay(regularDelayMs); + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); - // Switch back to the extension - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - await driver.navigate(PAGES.HOME); + // Queue confirm tx should first auto switch network + await driver.clickElement('#sendButton'); - // Check correct network switched and on the correct network - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 8545', - }); + await driver.delay(regularDelayMs); - // Check for transaction - await driver.wait(async () => { - const confirmedTxes = await driver.findElements( - '.transaction-list__completed-transactions .activity-list-item', + await driver.waitUntilXWindowHandles(3); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + // Confirm Transaction + await driver.findClickableElement({ text: 'Confirm', tag: 'button' }); + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + + await driver.delay(regularDelayMs); + + // Switch back to the extension + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, ); - return confirmedTxes.length === 1; - }, 10000); - }, - ); + await driver.navigate(PAGES.HOME); + + // Check correct network switched and on the correct network + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8545', + }); + + // Check for transaction + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .activity-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/ui.spec.js b/test/e2e/tests/request-queuing/ui.spec.js index 3b0ad9929cd8..c50fda4f807b 100644 --- a/test/e2e/tests/request-queuing/ui.spec.js +++ b/test/e2e/tests/request-queuing/ui.spec.js @@ -137,6 +137,38 @@ async function switchToDialogPopoverValidateDetails(driver, expectedDetails) { assert.equal(chainId, expectedDetails.chainId); } +async function switchToDialogPopoverValidateDetailsRedesign( + driver, + expectedDetails, +) { + // Switches to the MetaMask Dialog window for confirmation + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + await driver.findElement({ + css: 'p', + text: expectedDetails.networkText, + }); + + // Get state details + await driver.waitForControllersLoaded(); + const notificationWindowState = await driver.executeScript(() => + window.stateHooks?.getCleanAppState?.(), + ); + + const { + metamask: { selectedNetworkClientId, networkConfigurationsByChainId }, + } = notificationWindowState; + + const { chainId } = Object.values(networkConfigurationsByChainId).find( + ({ rpcEndpoints }) => + rpcEndpoints.some( + ({ networkClientId }) => networkClientId === selectedNetworkClientId, + ), + ); + + assert.equal(chainId, expectedDetails.chainId); +} + async function rejectTransaction(driver) { await driver.clickElementAndWaitForWindowToClose({ tag: 'button', @@ -144,6 +176,13 @@ async function rejectTransaction(driver) { }); } +async function rejectTransactionRedesign(driver) { + await driver.clickElementAndWaitForWindowToClose({ + tag: 'button', + text: 'Cancel', + }); +} + async function confirmTransaction(driver) { await driver.clickElement({ tag: 'button', text: 'Confirm' }); } @@ -191,588 +230,1051 @@ async function validateBalanceAndActivity( } describe('Request-queue UI changes', function () { - it('should show network specific to domain @no-mmi', async function () { - const port = 8546; - const chainId = 1338; // 0x53a - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Old confirmation screens', function () { + it('should show network specific to domain @no-mmi', async function () { + const port = 8546; + const chainId = 1338; // 0x53a + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), }, - dappOptions: { numberOfDapps: 2 }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - // Open the first dapp - await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); - - // Open the second dapp and switch chains - await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x53a'); - - // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 8546', - }); - - // Go to the first dapp, ensure it uses localhost - await selectDappClickSend(driver, DAPP_URL); - await switchToDialogPopoverValidateDetails(driver, { - chainId: '0x539', - networkText: 'Localhost 8545', - originText: DAPP_URL, - }); - await rejectTransaction(driver); - - // Go to the second dapp, ensure it uses Ethereum Mainnet - await selectDappClickSend(driver, DAPP_ONE_URL); - await switchToDialogPopoverValidateDetails(driver, { - chainId: '0x53a', - networkText: 'Localhost 8546', - originText: DAPP_ONE_URL, - }); - await rejectTransaction(driver); - }, - ); - }); + async ({ driver }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x53a'); + + // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8546', + }); + + // Go to the first dapp, ensure it uses localhost + await selectDappClickSend(driver, DAPP_URL); + await switchToDialogPopoverValidateDetails(driver, { + chainId: '0x539', + networkText: 'Localhost 8545', + originText: DAPP_URL, + }); + await rejectTransaction(driver); + + // Go to the second dapp, ensure it uses Ethereum Mainnet + await selectDappClickSend(driver, DAPP_ONE_URL); + await switchToDialogPopoverValidateDetails(driver, { + chainId: '0x53a', + networkText: 'Localhost 8546', + originText: DAPP_ONE_URL, + }); + await rejectTransaction(driver); + }, + ); + }); - it('handles three confirmations on three confirmations concurrently @no-mmi', async function () { - const port = 8546; - const chainId = 1338; // 0x53a - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerTripleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - // Ganache for network 1 - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - // Ganache for network 3 - { - port: 7777, - chainId: 1000, - ganacheOptions2: defaultGanacheOptions, - }, - ], + it('handles three confirmations on three confirmations concurrently @no-mmi', async function () { + const port = 8546; + const chainId = 1338; // 0x53a + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + // Ganache for network 1 + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + // Ganache for network 3 + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + dappOptions: { numberOfDapps: 3 }, + title: this.test.fullTitle(), }, - dappOptions: { numberOfDapps: 3 }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - // Open the first dapp - await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); - - // Open the second dapp and switch chains - await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x53a'); - - if (!IS_FIREFOX) { - // Open the third dapp and switch chains - await openDappAndSwitchChain(driver, DAPP_TWO_URL, '0x3e8'); - } - - // Trigger a send confirmation on the first dapp, do not confirm or reject - await selectDappClickSend(driver, DAPP_URL); - - // Trigger a send confirmation on the second dapp, do not confirm or reject - await selectDappClickSend(driver, DAPP_ONE_URL); - - if (!IS_FIREFOX) { - // Trigger a send confirmation on the third dapp, do not confirm or reject - await selectDappClickSend(driver, DAPP_TWO_URL); - } - - // Switch to the Notification window, ensure first transaction still showing - await switchToDialogPopoverValidateDetails(driver, { - chainId: '0x539', - networkText: 'Localhost 8545', - originText: DAPP_URL, - }); - - // Confirm transaction, wait for first confirmation window to close, second to display - await confirmTransaction(driver); - await driver.delay(veryLargeDelayMs); - - // Switch to the new Notification window, ensure second transaction showing - await switchToDialogPopoverValidateDetails(driver, { - chainId: '0x53a', - networkText: 'Localhost 8546', - originText: DAPP_ONE_URL, - }); - - // Reject this transaction, wait for second confirmation window to close, third to display - await rejectTransaction(driver); - await driver.delay(veryLargeDelayMs); - - if (!IS_FIREFOX) { - // Switch to the new Notification window, ensure third transaction showing + async ({ driver }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x53a'); + + if (!IS_FIREFOX) { + // Open the third dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_TWO_URL, '0x3e8'); + } + + // Trigger a send confirmation on the first dapp, do not confirm or reject + await selectDappClickSend(driver, DAPP_URL); + + // Trigger a send confirmation on the second dapp, do not confirm or reject + await selectDappClickSend(driver, DAPP_ONE_URL); + + if (!IS_FIREFOX) { + // Trigger a send confirmation on the third dapp, do not confirm or reject + await selectDappClickSend(driver, DAPP_TWO_URL); + } + + // Switch to the Notification window, ensure first transaction still showing await switchToDialogPopoverValidateDetails(driver, { - chainId: '0x3e8', - networkText: 'Localhost 7777', - originText: DAPP_TWO_URL, + chainId: '0x539', + networkText: 'Localhost 8545', + originText: DAPP_URL, }); - // Confirm transaction + // Confirm transaction, wait for first confirmation window to close, second to display await confirmTransaction(driver); - } - - // With first and last confirmations confirmed, and second rejected, - // Ensure only first and last network balances were affected - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + await driver.delay(veryLargeDelayMs); - // Wait for transaction to be completed on final confirmation - await driver.delay(veryLargeDelayMs); + // Switch to the new Notification window, ensure second transaction showing + await switchToDialogPopoverValidateDetails(driver, { + chainId: '0x53a', + networkText: 'Localhost 8546', + originText: DAPP_ONE_URL, + }); - if (!IS_FIREFOX) { - // Start on the last joined network, whose send transaction was just confirmed + // Reject this transaction, wait for second confirmation window to close, third to display + await rejectTransaction(driver); + await driver.delay(veryLargeDelayMs); + + if (!IS_FIREFOX) { + // Switch to the new Notification window, ensure third transaction showing + await switchToDialogPopoverValidateDetails(driver, { + chainId: '0x3e8', + networkText: 'Localhost 7777', + originText: DAPP_TWO_URL, + }); + + // Confirm transaction + await confirmTransaction(driver); + } + + // With first and last confirmations confirmed, and second rejected, + // Ensure only first and last network balances were affected + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Wait for transaction to be completed on final confirmation + await driver.delay(veryLargeDelayMs); + + if (!IS_FIREFOX) { + // Start on the last joined network, whose send transaction was just confirmed + await validateBalanceAndActivity(driver, '24.9998'); + } + + // Switch to second network, ensure full balance + await switchToNetworkByName(driver, 'Localhost 8546'); + await validateBalanceAndActivity(driver, '25', 0); + + // Turn on test networks in Networks menu so Localhost 8545 is available + await driver.clickElement('[data-testid="network-display"]'); + await driver.clickElement('.mm-modal-content__dialog .toggle-button'); + await driver.clickElement( + '.mm-modal-content__dialog button[aria-label="Close"]', + ); + + // Switch to first network, whose send transaction was just confirmed + await switchToNetworkByName(driver, 'Localhost 8545'); await validateBalanceAndActivity(driver, '24.9998'); - } - - // Switch to second network, ensure full balance - await switchToNetworkByName(driver, 'Localhost 8546'); - await validateBalanceAndActivity(driver, '25', 0); - - // Turn on test networks in Networks menu so Localhost 8545 is available - await driver.clickElement('[data-testid="network-display"]'); - await driver.clickElement('.mm-modal-content__dialog .toggle-button'); - await driver.clickElement( - '.mm-modal-content__dialog button[aria-label="Close"]', - ); - - // Switch to first network, whose send transaction was just confirmed - await switchToNetworkByName(driver, 'Localhost 8545'); - await validateBalanceAndActivity(driver, '24.9998'); - }, - ); - }); + }, + ); + }); - it('should gracefully handle deleted network @no-mmi', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesController({ - preferences: { showTestNetworks: true }, - }) - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + it('should gracefully handle deleted network @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesController({ + preferences: { showTestNetworks: true }, + }) + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), }, - dappOptions: { numberOfDapps: 2 }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - // Open the first dapp - await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); - - // Open the second dapp and switch chains - await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); - - // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Ethereum Mainnet', - }); - - await driver.clickElement('[data-testid="network-display"]'); - - const networkRow = await driver.findElement({ - css: '.multichain-network-list-item', - text: 'Localhost 8545', - }); - - const networkMenu = await driver.findNestedElement( - networkRow, - `[data-testid="network-list-item-options-button-${CHAIN_IDS.LOCALHOST}"]`, - ); - - await networkMenu.click(); - await driver.clickElement( - '[data-testid="network-list-item-options-delete"]', - ); - - await driver.clickElement({ tag: 'button', text: 'Delete' }); - - // Go back to first dapp, try an action, ensure deleted network doesn't block UI - // The current globally selected network, Ethereum Mainnet, should be used - await selectDappClickSend(driver, DAPP_URL); - await driver.delay(veryLargeDelayMs); - await switchToDialogPopoverValidateDetails(driver, { - chainId: '0x1', - networkText: 'Ethereum Mainnet', - originText: DAPP_URL, - }); - }, - ); - }); + async ({ driver }) => { + await unlockWallet(driver); - it('should signal from UI to dapp the network change @no-mmi', async function () { - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - ganacheOptions: defaultGanacheOptions, - title: this.test.fullTitle(), - driverOptions: { constrainWindowSize: true }, - }, - async ({ driver }) => { - // Navigate to extension home screen - await unlockWallet(driver); - - // Open the first dapp which starts on chain '0x539 - await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); - - // Ensure the dapp starts on the correct network - await driver.waitForSelector({ - css: '[id="chainId"]', - text: '0x539', - }); - - // Open the popup with shimmed activeTabOrigin - await openPopupWithActiveTabOrigin(driver, DAPP_URL); - - // Switch to mainnet - await switchToNetworkByName(driver, 'Ethereum Mainnet'); - - // Switch back to the Dapp tab - await driver.switchToWindowWithUrl(DAPP_URL); - - // Check to make sure the dapp network changed - await driver.waitForSelector({ - css: '[id="chainId"]', - text: '0x1', - }); - }, - ); - }); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); + + // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Ethereum Mainnet', + }); - it('should autoswitch networks to the last used network for domain', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + await driver.clickElement('[data-testid="network-display"]'); + + const networkRow = await driver.findElement({ + css: '.multichain-network-list-item', + text: 'Localhost 8545', + }); + + const networkMenu = await driver.findNestedElement( + networkRow, + `[data-testid="network-list-item-options-button-${CHAIN_IDS.LOCALHOST}"]`, + ); + + await networkMenu.click(); + await driver.clickElement( + '[data-testid="network-list-item-options-delete"]', + ); + + await driver.clickElement({ tag: 'button', text: 'Delete' }); + + // Go back to first dapp, try an action, ensure deleted network doesn't block UI + // The current globally selected network, Ethereum Mainnet, should be used + await selectDappClickSend(driver, DAPP_URL); + await driver.delay(veryLargeDelayMs); + await switchToDialogPopoverValidateDetails(driver, { + chainId: '0x1', + networkText: 'Ethereum Mainnet', + originText: DAPP_URL, + }); }, - dappOptions: { numberOfDapps: 2 }, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - // Open fullscreen - await unlockWallet(driver); - - // Open the first dapp which starts on chain '0x539 - await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); - - // Open tab 2, switch to Ethereum Mainnet - await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); - - // Open the popup with shimmed activeTabOrigin - await openPopupWithActiveTabOrigin(driver, DAPP_URL); - - // Ensure network was reset to original - await driver.findElement({ - css: '.multichain-app-header__contents--avatar-network .mm-text', - text: 'Localhost 8545', - }); - - // Ensure toast is shown to the user - await driver.findElement({ - css: '.toast-text', - text: 'Localhost 8545 is now active on 127.0.0.1:8080', - }); - }, - ); - }); + ); + }); - it('should autoswitch networks when last confirmation from another network is rejected', async function () { - const port = 8546; - const chainId = 1338; - - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + it('should autoswitch networks when last confirmation from another network is rejected', async function () { + const port = 8546; + const chainId = 1338; + + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), + driverOptions: { constrainWindowSize: true }, }, - dappOptions: { numberOfDapps: 2 }, - title: this.test.fullTitle(), - driverOptions: { constrainWindowSize: true }, - }, - async ({ driver }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Open the first dapp which starts on chain '0x539 - await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); - - // Open tab 2, switch to Ethereum Mainnet - await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); - await driver.waitForSelector({ - css: '.error-message-text', - text: 'You are on the Ethereum Mainnet.', - }); - await driver.delay(veryLargeDelayMs); - - // Start a Send on Ethereum Mainnet - await driver.clickElement('#sendButton'); - await driver.delay(regularDelayMs); - - // Open the popup with shimmed activeTabOrigin - await openPopupWithActiveTabOrigin(driver, DAPP_URL); - - // Ensure the confirmation pill shows Ethereum Mainnet - await driver.waitForSelector({ - css: '[data-testid="network-display"]', - text: 'Ethereum Mainnet', - }); - - // Reject the confirmation - await driver.clickElement( - '[data-testid="page-container-footer-cancel"]', - ); - - // Wait for network to automatically change to localhost - await driver.waitForSelector({ - css: '.multichain-app-header__contents--avatar-network .mm-text', - text: 'Localhost 8545', - }); - - // Ensure toast is shown to the user - await driver.waitForSelector({ - css: '.toast-text', - text: 'Localhost 8545 is now active on 127.0.0.1:8080', - }); - }, - ); - }); + async ({ driver }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); - it('should gracefully handle network connectivity failure for signatures @no-mmi', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + // Open the first dapp which starts on chain '0x539 + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open tab 2, switch to Ethereum Mainnet + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); + await driver.waitForSelector({ + css: '.error-message-text', + text: 'You are on the Ethereum Mainnet.', + }); + await driver.delay(veryLargeDelayMs); + + // Start a Send on Ethereum Mainnet + await driver.clickElement('#sendButton'); + await driver.delay(regularDelayMs); + + // Open the popup with shimmed activeTabOrigin + await openPopupWithActiveTabOrigin(driver, DAPP_URL); + + // Ensure the confirmation pill shows Ethereum Mainnet + await driver.waitForSelector({ + css: '[data-testid="network-display"]', + text: 'Ethereum Mainnet', + }); + + // Reject the confirmation + await driver.clickElement( + '[data-testid="page-container-footer-cancel"]', + ); + + // Wait for network to automatically change to localhost + await driver.waitForSelector({ + css: '.multichain-app-header__contents--avatar-network .mm-text', + text: 'Localhost 8545', + }); + + // Ensure toast is shown to the user + await driver.waitForSelector({ + css: '.toast-text', + text: 'Localhost 8545 is now active on 127.0.0.1:8080', + }); }, - // This test intentionally quits Ganache while the extension is using it, causing - // PollingBlockTracker errors and others. These are expected. - ignoredConsoleErrors: ['ignore-all'], - dappOptions: { numberOfDapps: 2 }, - title: this.test.fullTitle(), - }, - async ({ driver, ganacheServer, secondaryGanacheServer }) => { - await unlockWallet(driver); - await tempToggleSettingRedesignedConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - // Open the first dapp - await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); - - // Open the second dapp and switch chains - await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); - - // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - await driver.waitForSelector({ - css: '[data-testid="network-display"]', - text: 'Ethereum Mainnet', - }); - - // Kill ganache servers - await ganacheServer.quit(); - await secondaryGanacheServer[0].quit(); - - // Go back to first dapp, try an action, ensure network connection failure doesn't block UI - await selectDappClickPersonalSign(driver, DAPP_URL); - - // When the network is down, there is a performance degradation that causes the - // popup to take a few seconds to open in MV3 (issue #25690) - await driver.waitUntilXWindowHandles(4, 1000, 15000); - - await switchToDialogPopoverValidateDetails(driver, { - chainId: '0x539', - networkText: 'Localhost 8545', - originText: DAPP_URL, - }); - }, - ); + ); + }); + + it('should gracefully handle network connectivity failure for signatures @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + // This test intentionally quits Ganache while the extension is using it, causing + // PollingBlockTracker errors and others. These are expected. + ignoredConsoleErrors: ['ignore-all'], + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), + }, + async ({ driver, ganacheServer, secondaryGanacheServer }) => { + await unlockWallet(driver); + await tempToggleSettingRedesignedConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); + + // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.waitForSelector({ + css: '[data-testid="network-display"]', + text: 'Ethereum Mainnet', + }); + + // Kill ganache servers + await ganacheServer.quit(); + await secondaryGanacheServer[0].quit(); + + // Go back to first dapp, try an action, ensure network connection failure doesn't block UI + await selectDappClickPersonalSign(driver, DAPP_URL); + + // When the network is down, there is a performance degradation that causes the + // popup to take a few seconds to open in MV3 (issue #25690) + await driver.waitUntilXWindowHandles(4, 1000, 15000); + + await switchToDialogPopoverValidateDetails(driver, { + chainId: '0x539', + networkText: 'Localhost 8545', + originText: DAPP_URL, + }); + }, + ); + }); + + it('should gracefully handle network connectivity failure for confirmations @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + // Presently confirmations take up to 10 seconds to display on a dead network + driverOptions: { timeOut: 30000 }, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + // This test intentionally quits Ganache while the extension is using it, causing + // PollingBlockTracker errors and others. These are expected. + ignoredConsoleErrors: ['ignore-all'], + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), + }, + async ({ driver, ganacheServer, secondaryGanacheServer }) => { + await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); + + // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Ethereum Mainnet', + }); + + // Kill ganache servers + await ganacheServer.quit(); + await secondaryGanacheServer[0].quit(); + + // Go back to first dapp, try an action, ensure network connection failure doesn't block UI + await selectDappClickSend(driver, DAPP_URL); + + // When the network is down, there is a performance degradation that causes the + // popup to take a few seconds to open in MV3 (issue #25690) + await driver.waitUntilXWindowHandles(4, 1000, 15000); + + await switchToDialogPopoverValidateDetails(driver, { + chainId: '0x539', + networkText: 'Localhost 8545', + originText: DAPP_URL, + }); + }, + ); + }); }); - it('should gracefully handle network connectivity failure for confirmations @no-mmi', async function () { - const port = 8546; - const chainId = 1338; - await withFixtures( - { - dapp: true, - // Presently confirmations take up to 10 seconds to display on a dead network - driverOptions: { timeOut: 30000 }, - fixtures: new FixtureBuilder() - .withNetworkControllerDoubleGanache() - .withPreferencesControllerUseRequestQueueEnabled() - .build(), - ganacheOptions: { - ...defaultGanacheOptions, - concurrent: [ - { - port, - chainId, - ganacheOptions2: defaultGanacheOptions, - }, - ], + describe('Redesigned confirmation screens', function () { + it('should show network specific to domain @no-mmi', async function () { + const port = 8546; + const chainId = 1338; // 0x53a + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), }, - // This test intentionally quits Ganache while the extension is using it, causing - // PollingBlockTracker errors and others. These are expected. - ignoredConsoleErrors: ['ignore-all'], - dappOptions: { numberOfDapps: 2 }, - title: this.test.fullTitle(), - }, - async ({ driver, ganacheServer, secondaryGanacheServer }) => { - await unlockWallet(driver); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - // Open the first dapp - await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); - - // Open the second dapp and switch chains - await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); - - // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Ethereum Mainnet', - }); - - // Kill ganache servers - await ganacheServer.quit(); - await secondaryGanacheServer[0].quit(); - - // Go back to first dapp, try an action, ensure network connection failure doesn't block UI - await selectDappClickSend(driver, DAPP_URL); - - // When the network is down, there is a performance degradation that causes the - // popup to take a few seconds to open in MV3 (issue #25690) - await driver.waitUntilXWindowHandles(4, 1000, 15000); - - await switchToDialogPopoverValidateDetails(driver, { - chainId: '0x539', - networkText: 'Localhost 8545', - originText: DAPP_URL, - }); - }, - ); + async ({ driver }) => { + await unlockWallet(driver); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x53a'); + + // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8546', + }); + + // Go to the first dapp, ensure it uses localhost + await selectDappClickSend(driver, DAPP_URL); + await switchToDialogPopoverValidateDetailsRedesign(driver, { + chainId: '0x539', + networkText: 'Localhost 8545', + originText: DAPP_URL, + }); + await rejectTransactionRedesign(driver); + + // Go to the second dapp, ensure it uses Ethereum Mainnet + await selectDappClickSend(driver, DAPP_ONE_URL); + await switchToDialogPopoverValidateDetailsRedesign(driver, { + chainId: '0x53a', + networkText: 'Localhost 8546', + originText: DAPP_ONE_URL, + }); + await rejectTransactionRedesign(driver); + }, + ); + }); + + it('handles three confirmations on three confirmations concurrently @no-mmi', async function () { + const port = 8546; + const chainId = 1338; // 0x53a + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerTripleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + // Ganache for network 1 + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + // Ganache for network 3 + { + port: 7777, + chainId: 1000, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + dappOptions: { numberOfDapps: 3 }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x53a'); + + if (!IS_FIREFOX) { + // Open the third dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_TWO_URL, '0x3e8'); + } + + // Trigger a send confirmation on the first dapp, do not confirm or reject + await selectDappClickSend(driver, DAPP_URL); + + // Trigger a send confirmation on the second dapp, do not confirm or reject + await selectDappClickSend(driver, DAPP_ONE_URL); + + if (!IS_FIREFOX) { + // Trigger a send confirmation on the third dapp, do not confirm or reject + await selectDappClickSend(driver, DAPP_TWO_URL); + } + + // Switch to the Notification window, ensure first transaction still showing + await switchToDialogPopoverValidateDetailsRedesign(driver, { + chainId: '0x539', + networkText: 'Localhost 8545', + originText: DAPP_URL, + }); + + // Confirm transaction, wait for first confirmation window to close, second to display + await confirmTransaction(driver); + await driver.delay(veryLargeDelayMs); + + // Switch to the new Notification window, ensure second transaction showing + await switchToDialogPopoverValidateDetailsRedesign(driver, { + chainId: '0x53a', + networkText: 'Localhost 8546', + originText: DAPP_ONE_URL, + }); + + // Reject this transaction, wait for second confirmation window to close, third to display + await rejectTransactionRedesign(driver); + await driver.delay(veryLargeDelayMs); + + if (!IS_FIREFOX) { + // Switch to the new Notification window, ensure third transaction showing + await switchToDialogPopoverValidateDetailsRedesign(driver, { + chainId: '0x3e8', + networkText: 'Localhost 7777', + originText: DAPP_TWO_URL, + }); + + // Confirm transaction + await confirmTransaction(driver); + } + + // With first and last confirmations confirmed, and second rejected, + // Ensure only first and last network balances were affected + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + + // Wait for transaction to be completed on final confirmation + await driver.delay(veryLargeDelayMs); + + if (!IS_FIREFOX) { + // Start on the last joined network, whose send transaction was just confirmed + await validateBalanceAndActivity(driver, '24.9998'); + } + + // Switch to second network, ensure full balance + await switchToNetworkByName(driver, 'Localhost 8546'); + await validateBalanceAndActivity(driver, '25', 0); + + // Turn on test networks in Networks menu so Localhost 8545 is available + await driver.clickElement('[data-testid="network-display"]'); + await driver.clickElement('.mm-modal-content__dialog .toggle-button'); + await driver.clickElement( + '.mm-modal-content__dialog button[aria-label="Close"]', + ); + + // Switch to first network, whose send transaction was just confirmed + await switchToNetworkByName(driver, 'Localhost 8545'); + await validateBalanceAndActivity(driver, '24.9998'); + }, + ); + }); + + it('should gracefully handle deleted network @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesController({ + preferences: { showTestNetworks: true }, + }) + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); + + // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Ethereum Mainnet', + }); + + await driver.clickElement('[data-testid="network-display"]'); + + const networkRow = await driver.findElement({ + css: '.multichain-network-list-item', + text: 'Localhost 8545', + }); + + const networkMenu = await driver.findNestedElement( + networkRow, + `[data-testid="network-list-item-options-button-${CHAIN_IDS.LOCALHOST}"]`, + ); + + await networkMenu.click(); + await driver.clickElement( + '[data-testid="network-list-item-options-delete"]', + ); + + await driver.clickElement({ tag: 'button', text: 'Delete' }); + + // Go back to first dapp, try an action, ensure deleted network doesn't block UI + // The current globally selected network, Ethereum Mainnet, should be used + await selectDappClickSend(driver, DAPP_URL); + await driver.delay(veryLargeDelayMs); + await switchToDialogPopoverValidateDetailsRedesign(driver, { + chainId: '0x1', + networkText: 'Ethereum Mainnet', + originText: DAPP_URL, + }); + }, + ); + }); + + it('should signal from UI to dapp the network change @no-mmi', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + driverOptions: { constrainWindowSize: true }, + }, + async ({ driver }) => { + // Navigate to extension home screen + await unlockWallet(driver); + + // Open the first dapp which starts on chain '0x539 + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Ensure the dapp starts on the correct network + await driver.waitForSelector({ + css: '[id="chainId"]', + text: '0x539', + }); + + // Open the popup with shimmed activeTabOrigin + await openPopupWithActiveTabOrigin(driver, DAPP_URL); + + // Switch to mainnet + await switchToNetworkByName(driver, 'Ethereum Mainnet'); + + // Switch back to the Dapp tab + await driver.switchToWindowWithUrl(DAPP_URL); + + // Check to make sure the dapp network changed + await driver.waitForSelector({ + css: '[id="chainId"]', + text: '0x1', + }); + }, + ); + }); + + it('should autoswitch networks to the last used network for domain', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + // Open fullscreen + await unlockWallet(driver); + + // Open the first dapp which starts on chain '0x539 + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open tab 2, switch to Ethereum Mainnet + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); + + // Open the popup with shimmed activeTabOrigin + await openPopupWithActiveTabOrigin(driver, DAPP_URL); + + // Ensure network was reset to original + await driver.findElement({ + css: '.multichain-app-header__contents--avatar-network .mm-text', + text: 'Localhost 8545', + }); + + // Ensure toast is shown to the user + await driver.findElement({ + css: '.toast-text', + text: 'Localhost 8545 is now active on 127.0.0.1:8080', + }); + }, + ); + }); + + it('should autoswitch networks when last confirmation from another network is rejected', async function () { + const port = 8546; + const chainId = 1338; + + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), + driverOptions: { constrainWindowSize: true }, + }, + async ({ driver }) => { + await unlockWallet(driver); + + // Open the first dapp which starts on chain '0x539 + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open tab 2, switch to Ethereum Mainnet + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); + await driver.waitForSelector({ + css: '.error-message-text', + text: 'You are on the Ethereum Mainnet.', + }); + await driver.delay(veryLargeDelayMs); + + // Start a Send on Ethereum Mainnet + await driver.clickElement('#sendButton'); + await driver.delay(regularDelayMs); + + // Open the popup with shimmed activeTabOrigin + await openPopupWithActiveTabOrigin(driver, DAPP_URL); + + // Ensure the confirmation pill shows Ethereum Mainnet + await driver.waitForSelector({ + css: 'p', + text: 'Ethereum Mainnet', + }); + + // Reject the confirmation + await driver.clickElement({ css: 'button', text: 'Cancel' }); + + // Wait for network to automatically change to localhost + await driver.waitForSelector({ + css: '.multichain-app-header__contents--avatar-network .mm-text', + text: 'Localhost 8545', + }); + + // Ensure toast is shown to the user + await driver.waitForSelector({ + css: '.toast-text', + text: 'Localhost 8545 is now active on 127.0.0.1:8080', + }); + }, + ); + }); + + it('should gracefully handle network connectivity failure for signatures @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + // This test intentionally quits Ganache while the extension is using it, causing + // PollingBlockTracker errors and others. These are expected. + ignoredConsoleErrors: ['ignore-all'], + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), + }, + async ({ driver, ganacheServer, secondaryGanacheServer }) => { + await unlockWallet(driver); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); + + // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.waitForSelector({ + css: '[data-testid="network-display"]', + text: 'Ethereum Mainnet', + }); + + // Kill ganache servers + await ganacheServer.quit(); + await secondaryGanacheServer[0].quit(); + + // Go back to first dapp, try an action, ensure network connection failure doesn't block UI + await selectDappClickPersonalSign(driver, DAPP_URL); + + // When the network is down, there is a performance degradation that causes the + // popup to take a few seconds to open in MV3 (issue #25690) + await driver.waitUntilXWindowHandles(4, 1000, 15000); + + await switchToDialogPopoverValidateDetailsRedesign(driver, { + chainId: '0x539', + networkText: 'Localhost 8545', + originText: DAPP_URL, + }); + }, + ); + }); + + it('should gracefully handle network connectivity failure for confirmations @no-mmi', async function () { + const port = 8546; + const chainId = 1338; + await withFixtures( + { + dapp: true, + // Presently confirmations take up to 10 seconds to display on a dead network + driverOptions: { timeOut: 30000 }, + fixtures: new FixtureBuilder() + .withNetworkControllerDoubleGanache() + .withPreferencesControllerUseRequestQueueEnabled() + .build(), + ganacheOptions: { + ...defaultGanacheOptions, + concurrent: [ + { + port, + chainId, + ganacheOptions2: defaultGanacheOptions, + }, + ], + }, + // This test intentionally quits Ganache while the extension is using it, causing + // PollingBlockTracker errors and others. These are expected. + ignoredConsoleErrors: ['ignore-all'], + dappOptions: { numberOfDapps: 2 }, + title: this.test.fullTitle(), + }, + async ({ driver, ganacheServer, secondaryGanacheServer }) => { + await unlockWallet(driver); + + // Open the first dapp + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); + + // Open the second dapp and switch chains + await openDappAndSwitchChain(driver, DAPP_ONE_URL, '0x1'); + + // Go to wallet fullscreen, ensure that the global network changed to Ethereum Mainnet + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Ethereum Mainnet', + }); + + // Kill ganache servers + await ganacheServer.quit(); + await secondaryGanacheServer[0].quit(); + + // Go back to first dapp, try an action, ensure network connection failure doesn't block UI + await selectDappClickSend(driver, DAPP_URL); + + // When the network is down, there is a performance degradation that causes the + // popup to take a few seconds to open in MV3 (issue #25690) + await driver.waitUntilXWindowHandles(4, 1000, 15000); + + await switchToDialogPopoverValidateDetailsRedesign(driver, { + chainId: '0x539', + networkText: 'Localhost 8545', + originText: DAPP_URL, + }); + }, + ); + }); }); }); From 5fec2987eb5c74364aa8679cdac96030c3660381 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 15 Nov 2024 16:21:28 +0000 Subject: [PATCH 05/19] wip --- test/e2e/tests/confirmations/helpers.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/e2e/tests/confirmations/helpers.ts b/test/e2e/tests/confirmations/helpers.ts index 355f664ec61c..3d2b97d07d74 100644 --- a/test/e2e/tests/confirmations/helpers.ts +++ b/test/e2e/tests/confirmations/helpers.ts @@ -35,12 +35,6 @@ export function withRedesignConfirmationFixtures( metaMetricsId: 'fake-metrics-id', participateInMetaMetrics: true, }) - .withPreferencesController({ - preferences: { - redesignedConfirmationsEnabled: true, - isRedesignedConfirmationsDeveloperEnabled: true, - }, - }) .build(), ganacheOptions: transactionEnvelopeType === TransactionEnvelopeType.legacy From 24b0b3c871f93c98926f51f1a6db1a5c069760ee Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 15 Nov 2024 17:57:39 +0000 Subject: [PATCH 06/19] wip --- test/e2e/tests/tokens/custom-token-send-transfer.spec.js | 7 ++++++- test/e2e/tests/tokens/nft/erc1155-interaction.spec.js | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js index 248dd10e1bdd..54bc5ce29d20 100644 --- a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js +++ b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js @@ -9,6 +9,7 @@ const { WINDOW_TITLES, clickNestedButton, tempToggleSettingRedesignedTransactionConfirmations, + veryLargeDelayMs, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); @@ -129,8 +130,11 @@ describe('Transfer custom tokens @no-mmi', function () { // transfer token from dapp await openDapp(driver, contractAddress); + await driver.delay(veryLargeDelayMs); + await driver.clickElement({ text: 'Transfer Tokens', tag: 'button' }); - await switchToNotificationWindow(driver); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); await driver.waitForSelector({ text: '1.5 TST', tag: 'h1' }); // edit gas fee @@ -193,6 +197,7 @@ describe('Transfer custom tokens @no-mmi', function () { // transfer token from dapp await openDapp(driver, contractAddress); + await driver.delay(veryLargeDelayMs); await driver.clickElement({ text: 'Transfer Tokens Without Gas', tag: 'button', diff --git a/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js b/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js index b690492ac49d..21c98a397916 100644 --- a/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js +++ b/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js @@ -8,6 +8,7 @@ const { WINDOW_TITLES, defaultGanacheOptions, tempToggleSettingRedesignedTransactionConfirmations, + veryLargeDelayMs, } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); @@ -278,6 +279,9 @@ describe('ERC1155 NFTs testdapp interaction', function () { // Create a revoke approval for all erc1155 token request in test dapp await openDapp(driver, contract); + + await driver.delay(veryLargeDelayMs); + await driver.clickElement('#revokeERC1155Button'); // Wait for notification popup and check the displayed message From 7c90dc256735b4476c9049cd5409ca6a4236de02 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Wed, 20 Nov 2024 12:20:06 +0000 Subject: [PATCH 07/19] wip --- .circleci/scripts/test-run-e2e-timeout-minutes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/scripts/test-run-e2e-timeout-minutes.ts b/.circleci/scripts/test-run-e2e-timeout-minutes.ts index c539133b0c60..570c55773dfa 100644 --- a/.circleci/scripts/test-run-e2e-timeout-minutes.ts +++ b/.circleci/scripts/test-run-e2e-timeout-minutes.ts @@ -3,6 +3,6 @@ import { filterE2eChangedFiles } from '../../test/e2e/changedFilesUtil'; const changedOrNewTests = filterE2eChangedFiles(); // 20 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes -const extraTime = Math.min(20 + changedOrNewTests.length * 3, 30); +const extraTime = Math.min(20 + changedOrNewTests.length * 3, 120); console.log(extraTime); From d2504e321d5e253b0b66deafcb9bb18e7eda647b Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Wed, 20 Nov 2024 16:56:39 +0000 Subject: [PATCH 08/19] wip --- .circleci/scripts/test-run-e2e-timeout-minutes.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/scripts/test-run-e2e-timeout-minutes.ts b/.circleci/scripts/test-run-e2e-timeout-minutes.ts index 570c55773dfa..d381fb1451f6 100644 --- a/.circleci/scripts/test-run-e2e-timeout-minutes.ts +++ b/.circleci/scripts/test-run-e2e-timeout-minutes.ts @@ -2,7 +2,7 @@ import { filterE2eChangedFiles } from '../../test/e2e/changedFilesUtil'; const changedOrNewTests = filterE2eChangedFiles(); -// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes -const extraTime = Math.min(20 + changedOrNewTests.length * 3, 120); +// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 60 minutes +const extraTime = Math.min(20 + changedOrNewTests.length * 3, 60); console.log(extraTime); From 47d4b323689f62327d3f804b8f9e16a2be872449 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Thu, 21 Nov 2024 12:01:23 +0000 Subject: [PATCH 09/19] Update migration --- app/scripts/migrations/132.test.ts | 19 +++++++++++++++ app/scripts/migrations/132.ts | 37 +++++++++++++++++++----------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/app/scripts/migrations/132.test.ts b/app/scripts/migrations/132.test.ts index 56cf100139ef..fb53f90a38fb 100644 --- a/app/scripts/migrations/132.test.ts +++ b/app/scripts/migrations/132.test.ts @@ -27,6 +27,25 @@ describe('migration #132', () => { expect(transformedState.data).toEqual(oldState); }); + it('adds preferences property to the controller if it is not set and set the preference to true if migration runs', async () => { + const oldState = { PreferencesController: {} }; + + const expectedState = { + PreferencesController: { + preferences: { + redesignedTransactionsEnabled: true, + }, + }, + }; + + const transformedState = await migrate({ + meta: { version: oldVersion }, + data: oldState, + }); + + expect(transformedState.data).toEqual(expectedState); + }); + it('changes property to true if migration runs', async () => { const oldState = { PreferencesController: { diff --git a/app/scripts/migrations/132.ts b/app/scripts/migrations/132.ts index 428517351738..9668b503d511 100644 --- a/app/scripts/migrations/132.ts +++ b/app/scripts/migrations/132.ts @@ -29,21 +29,30 @@ export async function migrate( function transformState( state: Record, ): Record { - const preferencesControllerState = state?.PreferencesController as - | Record - | undefined; - - const preferences = preferencesControllerState?.preferences as - | Record - | undefined; - - if (isObject(preferencesControllerState) && isObject(preferences)) { - // `redesignedTransactionsEnabled` was previously set to `false` by default - // in `124.ts` - if (preferences.redesignedTransactionsEnabled === false) { - preferences.redesignedTransactionsEnabled = true; - } + if (!isObject(state?.PreferencesController)) { + return state; } + if (!isObject(state.PreferencesController?.preferences)) { + state.PreferencesController = { + ...state.PreferencesController, + preferences: {}, + }; + } + + let preferencesControllerState = state.PreferencesController as Record< + string, + unknown + >; + + const preferences = preferencesControllerState.preferences as Record< + string, + unknown + >; + + // `redesignedTransactionsEnabled` was previously set to `false` by + // default in `124.ts` + preferences.redesignedTransactionsEnabled = true; + return state; } From 1913c38157a2f5e6ba509d9710903852e2cdd9cc Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 22 Nov 2024 10:47:40 +0000 Subject: [PATCH 10/19] Rename withRedesignConfirmationFixtures --- test/e2e/tests/confirmations/helpers.ts | 2 +- test/e2e/tests/confirmations/navigation.spec.ts | 8 ++++---- .../signatures/malicious-signatures.spec.ts | 8 ++++---- .../confirmations/signatures/nft-permit.spec.ts | 6 +++--- .../tests/confirmations/signatures/permit.spec.ts | 6 +++--- .../confirmations/signatures/personal-sign.spec.ts | 6 +++--- .../signatures/sign-typed-data-v3.spec.ts | 6 +++--- .../signatures/sign-typed-data-v4.spec.ts | 6 +++--- .../signatures/sign-typed-data.spec.ts | 6 +++--- .../tests/confirmations/signatures/siwe.spec.ts | 6 +++--- ...erc1155-revoke-set-approval-for-all-redesign.ts | 6 +++--- .../erc1155-set-approval-for-all-redesign.spec.ts | 6 +++--- .../transactions/erc20-token-send-redesign.spec.ts | 10 +++++----- .../erc721-revoke-set-approval-for-all-redesign.ts | 6 +++--- .../erc721-set-approval-for-all-redesign.spec.ts | 6 +++--- .../transactions/native-send-redesign.spec.ts | 10 +++++----- .../transactions/nft-token-send-redesign.spec.ts | 14 +++++++------- 17 files changed, 59 insertions(+), 59 deletions(-) diff --git a/test/e2e/tests/confirmations/helpers.ts b/test/e2e/tests/confirmations/helpers.ts index 3d2b97d07d74..2b1078549c5b 100644 --- a/test/e2e/tests/confirmations/helpers.ts +++ b/test/e2e/tests/confirmations/helpers.ts @@ -14,7 +14,7 @@ export async function scrollAndConfirmAndAssertConfirm(driver: Driver) { await driver.clickElement('[data-testid="confirm-footer-button"]'); } -export function withRedesignConfirmationFixtures( +export function withTransactionEnvelopeTypeFixtures( // Default params first is discouraged because it makes it hard to call the function without the // optional parameters. But it doesn't apply here because we're always passing in a variable for // title. It's optional because it's sometimes unset. diff --git a/test/e2e/tests/confirmations/navigation.spec.ts b/test/e2e/tests/confirmations/navigation.spec.ts index 38d29ad3ad77..97985381b08b 100644 --- a/test/e2e/tests/confirmations/navigation.spec.ts +++ b/test/e2e/tests/confirmations/navigation.spec.ts @@ -8,11 +8,11 @@ import { WINDOW_TITLES, } from '../../helpers'; import { Driver } from '../../webdriver/driver'; -import { withRedesignConfirmationFixtures } from './helpers'; +import { withTransactionEnvelopeTypeFixtures } from './helpers'; describe('Navigation Signature - Different signature types', function (this: Suite) { it('initiates and queues multiple signatures and confirms', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver }: { driver: Driver }) => { @@ -52,7 +52,7 @@ describe('Navigation Signature - Different signature types', function (this: Sui }); it('initiates and queues a mix of signatures and transactions and navigates', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver }: { driver: Driver }) => { @@ -100,7 +100,7 @@ describe('Navigation Signature - Different signature types', function (this: Sui }); it('initiates multiple signatures and rejects all', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver }: { driver: Driver }) => { diff --git a/test/e2e/tests/confirmations/signatures/malicious-signatures.spec.ts b/test/e2e/tests/confirmations/signatures/malicious-signatures.spec.ts index 328ad7811e1b..5876a4d5e17f 100644 --- a/test/e2e/tests/confirmations/signatures/malicious-signatures.spec.ts +++ b/test/e2e/tests/confirmations/signatures/malicious-signatures.spec.ts @@ -7,7 +7,7 @@ import { Driver } from '../../../webdriver/driver'; import { mockSignatureRejected, scrollAndConfirmAndAssertConfirm, - withRedesignConfirmationFixtures, + withTransactionEnvelopeTypeFixtures, } from '../helpers'; import { TestSuiteArguments } from '../transactions/shared'; import { @@ -22,7 +22,7 @@ import { describe('Malicious Confirmation Signature - Bad Domain @no-mmi', function (this: Suite) { it('displays alert for domain binding and confirms', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver }: TestSuiteArguments) => { @@ -45,7 +45,7 @@ describe('Malicious Confirmation Signature - Bad Domain @no-mmi', function (this }); it('initiates and rejects from confirmation screen', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ @@ -93,7 +93,7 @@ describe('Malicious Confirmation Signature - Bad Domain @no-mmi', function (this }); it('initiates and rejects from alert friction modal', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ diff --git a/test/e2e/tests/confirmations/signatures/nft-permit.spec.ts b/test/e2e/tests/confirmations/signatures/nft-permit.spec.ts index 383a3bd6b924..de70d25b359b 100644 --- a/test/e2e/tests/confirmations/signatures/nft-permit.spec.ts +++ b/test/e2e/tests/confirmations/signatures/nft-permit.spec.ts @@ -9,7 +9,7 @@ import { mockSignatureApproved, mockSignatureRejected, scrollAndConfirmAndAssertConfirm, - withRedesignConfirmationFixtures, + withTransactionEnvelopeTypeFixtures, } from '../helpers'; import { TestSuiteArguments } from '../transactions/shared'; import { @@ -26,7 +26,7 @@ import { describe('Confirmation Signature - NFT Permit @no-mmi', function (this: Suite) { it('initiates and confirms and emits the correct events', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ @@ -77,7 +77,7 @@ describe('Confirmation Signature - NFT Permit @no-mmi', function (this: Suite) { }); it('initiates and rejects and emits the correct events', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ diff --git a/test/e2e/tests/confirmations/signatures/permit.spec.ts b/test/e2e/tests/confirmations/signatures/permit.spec.ts index bc74b9fd2f5f..f6c8fc972b5f 100644 --- a/test/e2e/tests/confirmations/signatures/permit.spec.ts +++ b/test/e2e/tests/confirmations/signatures/permit.spec.ts @@ -14,7 +14,7 @@ import { mockSignatureApproved, mockSignatureRejected, scrollAndConfirmAndAssertConfirm, - withRedesignConfirmationFixtures, + withTransactionEnvelopeTypeFixtures, } from '../helpers'; import { TestSuiteArguments } from '../transactions/shared'; import { @@ -31,7 +31,7 @@ import { describe('Confirmation Signature - Permit @no-mmi', function (this: Suite) { it('initiates and confirms and emits the correct events', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ @@ -76,7 +76,7 @@ describe('Confirmation Signature - Permit @no-mmi', function (this: Suite) { }); it('initiates and rejects and emits the correct events', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ diff --git a/test/e2e/tests/confirmations/signatures/personal-sign.spec.ts b/test/e2e/tests/confirmations/signatures/personal-sign.spec.ts index 8444deab7c61..5f87c2d6b6e8 100644 --- a/test/e2e/tests/confirmations/signatures/personal-sign.spec.ts +++ b/test/e2e/tests/confirmations/signatures/personal-sign.spec.ts @@ -8,7 +8,7 @@ import { Driver } from '../../../webdriver/driver'; import { mockSignatureApproved, mockSignatureRejected, - withRedesignConfirmationFixtures, + withTransactionEnvelopeTypeFixtures, } from '../helpers'; import { TestSuiteArguments } from '../transactions/shared'; import { @@ -25,7 +25,7 @@ import { describe('Confirmation Signature - Personal Sign @no-mmi', function (this: Suite) { it('initiates and confirms', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ @@ -66,7 +66,7 @@ describe('Confirmation Signature - Personal Sign @no-mmi', function (this: Suite }); it('initiates and rejects', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ diff --git a/test/e2e/tests/confirmations/signatures/sign-typed-data-v3.spec.ts b/test/e2e/tests/confirmations/signatures/sign-typed-data-v3.spec.ts index a7f2e7b81691..7ea7f0879279 100644 --- a/test/e2e/tests/confirmations/signatures/sign-typed-data-v3.spec.ts +++ b/test/e2e/tests/confirmations/signatures/sign-typed-data-v3.spec.ts @@ -9,7 +9,7 @@ import { mockSignatureApproved, mockSignatureRejected, scrollAndConfirmAndAssertConfirm, - withRedesignConfirmationFixtures, + withTransactionEnvelopeTypeFixtures, } from '../helpers'; import { TestSuiteArguments } from '../transactions/shared'; import { @@ -26,7 +26,7 @@ import { describe('Confirmation Signature - Sign Typed Data V3 @no-mmi', function (this: Suite) { it('initiates and confirms', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ @@ -70,7 +70,7 @@ describe('Confirmation Signature - Sign Typed Data V3 @no-mmi', function (this: }); it('initiates and rejects', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ diff --git a/test/e2e/tests/confirmations/signatures/sign-typed-data-v4.spec.ts b/test/e2e/tests/confirmations/signatures/sign-typed-data-v4.spec.ts index 33b94be6b332..4dfe9f04972f 100644 --- a/test/e2e/tests/confirmations/signatures/sign-typed-data-v4.spec.ts +++ b/test/e2e/tests/confirmations/signatures/sign-typed-data-v4.spec.ts @@ -9,7 +9,7 @@ import { mockSignatureApproved, mockSignatureRejected, scrollAndConfirmAndAssertConfirm, - withRedesignConfirmationFixtures, + withTransactionEnvelopeTypeFixtures, } from '../helpers'; import { TestSuiteArguments } from '../transactions/shared'; import { @@ -26,7 +26,7 @@ import { describe('Confirmation Signature - Sign Typed Data V4 @no-mmi', function (this: Suite) { it('initiates and confirms', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ @@ -74,7 +74,7 @@ describe('Confirmation Signature - Sign Typed Data V4 @no-mmi', function (this: }); it('initiates and rejects', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ diff --git a/test/e2e/tests/confirmations/signatures/sign-typed-data.spec.ts b/test/e2e/tests/confirmations/signatures/sign-typed-data.spec.ts index 2f1c33fe4d07..e7f8e1446f5c 100644 --- a/test/e2e/tests/confirmations/signatures/sign-typed-data.spec.ts +++ b/test/e2e/tests/confirmations/signatures/sign-typed-data.spec.ts @@ -8,7 +8,7 @@ import { Driver } from '../../../webdriver/driver'; import { mockSignatureApproved, mockSignatureRejected, - withRedesignConfirmationFixtures, + withTransactionEnvelopeTypeFixtures, } from '../helpers'; import { TestSuiteArguments } from '../transactions/shared'; import { @@ -25,7 +25,7 @@ import { describe('Confirmation Signature - Sign Typed Data @no-mmi', function (this: Suite) { it('initiates and confirms', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ @@ -66,7 +66,7 @@ describe('Confirmation Signature - Sign Typed Data @no-mmi', function (this: Sui }); it('initiates and rejects', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ diff --git a/test/e2e/tests/confirmations/signatures/siwe.spec.ts b/test/e2e/tests/confirmations/signatures/siwe.spec.ts index 9f261a28f569..4c7bec0ae121 100644 --- a/test/e2e/tests/confirmations/signatures/siwe.spec.ts +++ b/test/e2e/tests/confirmations/signatures/siwe.spec.ts @@ -8,7 +8,7 @@ import { mockSignatureApproved, mockSignatureRejected, scrollAndConfirmAndAssertConfirm, - withRedesignConfirmationFixtures, + withTransactionEnvelopeTypeFixtures, } from '../helpers'; import { TestSuiteArguments } from '../transactions/shared'; import { @@ -29,7 +29,7 @@ import { describe('Confirmation Signature - SIWE @no-mmi', function (this: Suite) { it('initiates and confirms', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ @@ -74,7 +74,7 @@ describe('Confirmation Signature - SIWE @no-mmi', function (this: Suite) { }); it('initiates and rejects', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ diff --git a/test/e2e/tests/confirmations/transactions/erc1155-revoke-set-approval-for-all-redesign.ts b/test/e2e/tests/confirmations/transactions/erc1155-revoke-set-approval-for-all-redesign.ts index 33a7760a050d..f79bf6835e14 100644 --- a/test/e2e/tests/confirmations/transactions/erc1155-revoke-set-approval-for-all-redesign.ts +++ b/test/e2e/tests/confirmations/transactions/erc1155-revoke-set-approval-for-all-redesign.ts @@ -7,7 +7,7 @@ import SetApprovalForAllTransactionConfirmation from '../../../page-objects/page import TestDapp from '../../../page-objects/pages/test-dapp'; import ContractAddressRegistry from '../../../seeder/contract-address-registry'; import { Driver } from '../../../webdriver/driver'; -import { withRedesignConfirmationFixtures } from '../helpers'; +import { withTransactionEnvelopeTypeFixtures } from '../helpers'; import { mocked4BytesSetApprovalForAll } from './erc721-revoke-set-approval-for-all-redesign'; import { TestSuiteArguments } from './shared'; @@ -16,7 +16,7 @@ const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); describe('Confirmation Redesign ERC1155 Revoke setApprovalForAll', function () { describe('Submit an revoke transaction @no-mmi', function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -28,7 +28,7 @@ describe('Confirmation Redesign ERC1155 Revoke setApprovalForAll', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver, contractRegistry }: TestSuiteArguments) => { diff --git a/test/e2e/tests/confirmations/transactions/erc1155-set-approval-for-all-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/erc1155-set-approval-for-all-redesign.spec.ts index da9da0a59873..cbb85482e6f1 100644 --- a/test/e2e/tests/confirmations/transactions/erc1155-set-approval-for-all-redesign.spec.ts +++ b/test/e2e/tests/confirmations/transactions/erc1155-set-approval-for-all-redesign.spec.ts @@ -6,7 +6,7 @@ import SetApprovalForAllTransactionConfirmation from '../../../page-objects/page import TestDapp from '../../../page-objects/pages/test-dapp'; import ContractAddressRegistry from '../../../seeder/contract-address-registry'; import { Driver } from '../../../webdriver/driver'; -import { withRedesignConfirmationFixtures } from '../helpers'; +import { withTransactionEnvelopeTypeFixtures } from '../helpers'; import { TestSuiteArguments } from './shared'; const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); @@ -14,7 +14,7 @@ const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); describe('Confirmation Redesign ERC1155 setApprovalForAll', function () { describe('Submit a transaction @no-mmi', function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -29,7 +29,7 @@ describe('Confirmation Redesign ERC1155 setApprovalForAll', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver, contractRegistry }: TestSuiteArguments) => { diff --git a/test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.spec.ts index f5293161172f..2fbe2c553a06 100644 --- a/test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.spec.ts +++ b/test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.spec.ts @@ -14,7 +14,7 @@ import SendTokenPage from '../../../page-objects/pages/send/send-token-page'; import TestDapp from '../../../page-objects/pages/test-dapp'; import ContractAddressRegistry from '../../../seeder/contract-address-registry'; import { Driver } from '../../../webdriver/driver'; -import { withRedesignConfirmationFixtures } from '../helpers'; +import { withTransactionEnvelopeTypeFixtures } from '../helpers'; import { TestSuiteArguments } from './shared'; const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); @@ -22,7 +22,7 @@ const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); describe('Confirmation Redesign ERC20 Token Send @no-mmi', function () { describe('Wallet initiated', async function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -37,7 +37,7 @@ describe('Confirmation Redesign ERC20 Token Send @no-mmi', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -54,7 +54,7 @@ describe('Confirmation Redesign ERC20 Token Send @no-mmi', function () { describe('dApp initiated', async function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -69,7 +69,7 @@ describe('Confirmation Redesign ERC20 Token Send @no-mmi', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver, contractRegistry }: TestSuiteArguments) => { diff --git a/test/e2e/tests/confirmations/transactions/erc721-revoke-set-approval-for-all-redesign.ts b/test/e2e/tests/confirmations/transactions/erc721-revoke-set-approval-for-all-redesign.ts index 95768c35de3f..27e2eb31a04e 100644 --- a/test/e2e/tests/confirmations/transactions/erc721-revoke-set-approval-for-all-redesign.ts +++ b/test/e2e/tests/confirmations/transactions/erc721-revoke-set-approval-for-all-redesign.ts @@ -7,7 +7,7 @@ import SetApprovalForAllTransactionConfirmation from '../../../page-objects/page import TestDapp from '../../../page-objects/pages/test-dapp'; import ContractAddressRegistry from '../../../seeder/contract-address-registry'; import { Driver } from '../../../webdriver/driver'; -import { withRedesignConfirmationFixtures } from '../helpers'; +import { withTransactionEnvelopeTypeFixtures } from '../helpers'; import { TestSuiteArguments } from './shared'; const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); @@ -15,7 +15,7 @@ const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); describe('Confirmation Redesign ERC721 Revoke setApprovalForAll', function () { describe('Submit an revoke transaction @no-mmi', function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -27,7 +27,7 @@ describe('Confirmation Redesign ERC721 Revoke setApprovalForAll', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver, contractRegistry }: TestSuiteArguments) => { diff --git a/test/e2e/tests/confirmations/transactions/erc721-set-approval-for-all-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/erc721-set-approval-for-all-redesign.spec.ts index ba3c877973e5..4e1f54511d40 100644 --- a/test/e2e/tests/confirmations/transactions/erc721-set-approval-for-all-redesign.spec.ts +++ b/test/e2e/tests/confirmations/transactions/erc721-set-approval-for-all-redesign.spec.ts @@ -6,7 +6,7 @@ import SetApprovalForAllTransactionConfirmation from '../../../page-objects/page import TestDapp from '../../../page-objects/pages/test-dapp'; import ContractAddressRegistry from '../../../seeder/contract-address-registry'; import { Driver } from '../../../webdriver/driver'; -import { withRedesignConfirmationFixtures } from '../helpers'; +import { withTransactionEnvelopeTypeFixtures } from '../helpers'; import { TestSuiteArguments } from './shared'; const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); @@ -14,7 +14,7 @@ const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); describe('Confirmation Redesign ERC721 setApprovalForAll', function () { describe('Submit a transaction @no-mmi', function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -29,7 +29,7 @@ describe('Confirmation Redesign ERC721 setApprovalForAll', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver, contractRegistry }: TestSuiteArguments) => { diff --git a/test/e2e/tests/confirmations/transactions/native-send-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/native-send-redesign.spec.ts index e8226977d019..46318e113c35 100644 --- a/test/e2e/tests/confirmations/transactions/native-send-redesign.spec.ts +++ b/test/e2e/tests/confirmations/transactions/native-send-redesign.spec.ts @@ -11,7 +11,7 @@ import HomePage from '../../../page-objects/pages/homepage'; import SendTokenPage from '../../../page-objects/pages/send/send-token-page'; import TestDapp from '../../../page-objects/pages/test-dapp'; import { Driver } from '../../../webdriver/driver'; -import { withRedesignConfirmationFixtures } from '../helpers'; +import { withTransactionEnvelopeTypeFixtures } from '../helpers'; import { TestSuiteArguments } from './shared'; const TOKEN_RECIPIENT_ADDRESS = '0x2f318C334780961FB129D2a6c30D0763d9a5C970'; @@ -19,7 +19,7 @@ const TOKEN_RECIPIENT_ADDRESS = '0x2f318C334780961FB129D2a6c30D0763d9a5C970'; describe('Confirmation Redesign Native Send @no-mmi', function () { describe('Wallet initiated', async function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver }: TestSuiteArguments) => { @@ -29,7 +29,7 @@ describe('Confirmation Redesign Native Send @no-mmi', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver }: TestSuiteArguments) => { @@ -41,7 +41,7 @@ describe('Confirmation Redesign Native Send @no-mmi', function () { describe('dApp initiated', async function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver }: TestSuiteArguments) => { @@ -51,7 +51,7 @@ describe('Confirmation Redesign Native Send @no-mmi', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver }: TestSuiteArguments) => { diff --git a/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts index 8d319b62c482..6fc048c7f11b 100644 --- a/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts +++ b/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts @@ -16,7 +16,7 @@ import SendTokenPage from '../../../page-objects/pages/send/send-token-page'; import TestDapp from '../../../page-objects/pages/test-dapp'; import ContractAddressRegistry from '../../../seeder/contract-address-registry'; import { Driver } from '../../../webdriver/driver'; -import { withRedesignConfirmationFixtures } from '../helpers'; +import { withTransactionEnvelopeTypeFixtures } from '../helpers'; import { TestSuiteArguments } from './shared'; const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); @@ -27,7 +27,7 @@ describe('Confirmation Redesign Token Send @no-mmi', function () { describe('ERC721', function () { describe('Wallet initiated', async function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -42,7 +42,7 @@ describe('Confirmation Redesign Token Send @no-mmi', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -59,7 +59,7 @@ describe('Confirmation Redesign Token Send @no-mmi', function () { describe('dApp initiated', async function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -74,7 +74,7 @@ describe('Confirmation Redesign Token Send @no-mmi', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -93,7 +93,7 @@ describe('Confirmation Redesign Token Send @no-mmi', function () { describe('ERC1155', function () { describe('Wallet initiated', async function () { it('Sends a type 0 transaction (Legacy)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver, contractRegistry }: TestSuiteArguments) => { @@ -108,7 +108,7 @@ describe('Confirmation Redesign Token Send @no-mmi', function () { }); it('Sends a type 2 transaction (EIP1559)', async function () { - await withRedesignConfirmationFixtures( + await withTransactionEnvelopeTypeFixtures( this.test?.fullTitle(), TransactionEnvelopeType.feeMarket, async ({ driver, contractRegistry }: TestSuiteArguments) => { From 4b264113f2516bbbe71b2ad7978c6a2000603f19 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 22 Nov 2024 11:13:22 +0000 Subject: [PATCH 11/19] Migrate snap-account-transfers.spec.ts tests --- .../flows/send-transaction.flow.ts | 76 +++ .../account/snap-account-transfers.spec.ts | 461 ++++++++++++------ 2 files changed, 381 insertions(+), 156 deletions(-) diff --git a/test/e2e/page-objects/flows/send-transaction.flow.ts b/test/e2e/page-objects/flows/send-transaction.flow.ts index 3f56076e3934..1cb2a26d31bb 100644 --- a/test/e2e/page-objects/flows/send-transaction.flow.ts +++ b/test/e2e/page-objects/flows/send-transaction.flow.ts @@ -3,6 +3,7 @@ import ConfirmTxPage from '../pages/send/confirm-tx-page'; import SendTokenPage from '../pages/send/send-token-page'; import { Driver } from '../../webdriver/driver'; import SnapSimpleKeyringPage from '../pages/snap-simple-keyring-page'; +import TransactionConfirmation from '../pages/confirmations/redesign/transaction-confirmation'; /** * This function initiates the steps required to send a transaction from the homepage to final confirmation. @@ -47,6 +48,44 @@ export const sendTransactionToAddress = async ({ await confirmTxPage.confirmTx(); }; +/** + * This function initiates the steps required to send a transaction from the homepage to final confirmation. + * + * @param params - An object containing the parameters. + * @param params.driver - The webdriver instance. + * @param params.recipientAddress - The recipient address. + * @param params.amount - The amount of the asset to be sent in the transaction. + * @param params.gasFee - The expected transaction gas fee. + * @param params.totalFee - The expected total transaction fee. + */ +export const sendRedesignedTransactionToAddress = async ({ + driver, + recipientAddress, + amount, +}: { + driver: Driver; + recipientAddress: string; + amount: string; +}): Promise => { + console.log( + `Start flow to send amount ${amount} to recipient ${recipientAddress} on home screen`, + ); + // click send button on homepage to start flow + const homePage = new HomePage(driver); + await homePage.startSendFlow(); + + // user should land on send token screen to fill recipient and amount + const sendToPage = new SendTokenPage(driver); + await sendToPage.check_pageIsLoaded(); + await sendToPage.fillRecipient(recipientAddress); + await sendToPage.fillAmount(amount); + await sendToPage.goToNextScreen(); + + // confirm transaction when user lands on confirm transaction screen + const transactionConfirmationPage = new TransactionConfirmation(driver); + await transactionConfirmationPage.clickFooterConfirmButton(); +}; + /** * This function initiates the steps required to send a transaction from the homepage to final confirmation. * @@ -132,3 +171,40 @@ export const sendTransactionWithSnapAccount = async ({ ); } }; + +/** + * This function initiates the steps required to send a transaction from snap account on homepage to final confirmation. + * + * @param params - An object containing the parameters. + * @param params.driver - The webdriver instance. + * @param params.recipientAddress - The recipient address. + * @param params.amount - The amount of the asset to be sent in the transaction. + * @param params.gasFee - The expected transaction gas fee. + * @param params.totalFee - The expected total transaction fee. + * @param params.isSyncFlow - Indicates whether synchronous approval option is on for the snap. Defaults to true. + * @param params.approveTransaction - Indicates whether the transaction should be approved. Defaults to true. + */ +export const sendRedesignedTransactionWithSnapAccount = async ({ + driver, + recipientAddress, + amount, + isSyncFlow = true, + approveTransaction = true, +}: { + driver: Driver; + recipientAddress: string; + amount: string; + isSyncFlow?: boolean; + approveTransaction?: boolean; +}): Promise => { + await sendRedesignedTransactionToAddress({ + driver, + recipientAddress, + amount, + }); + if (!isSyncFlow) { + await new SnapSimpleKeyringPage(driver).approveRejectSnapAccountTransaction( + approveTransaction, + ); + } +}; diff --git a/test/e2e/tests/account/snap-account-transfers.spec.ts b/test/e2e/tests/account/snap-account-transfers.spec.ts index 82b19f90817e..387e744fd8ca 100644 --- a/test/e2e/tests/account/snap-account-transfers.spec.ts +++ b/test/e2e/tests/account/snap-account-transfers.spec.ts @@ -16,169 +16,318 @@ import HomePage from '../../page-objects/pages/homepage'; import SnapSimpleKeyringPage from '../../page-objects/pages/snap-simple-keyring-page'; import { installSnapSimpleKeyring } from '../../page-objects/flows/snap-simple-keyring.flow'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; -import { sendTransactionWithSnapAccount } from '../../page-objects/flows/send-transaction.flow'; +import { + sendRedesignedTransactionWithSnapAccount, + sendTransactionWithSnapAccount, +} from '../../page-objects/flows/send-transaction.flow'; describe('Snap Account Transfers @no-mmi', function (this: Suite) { - it('can import a private key and transfer 1 ETH (sync flow)', async function () { - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: multipleGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ - driver, - ganacheServer, - }: { - driver: Driver; - ganacheServer?: Ganache; - }) => { - await loginWithBalanceValidation(driver, ganacheServer); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - await installSnapSimpleKeyring(driver); - const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); - - // import snap account with private key on snap simple keyring page. - await snapSimpleKeyringPage.importAccountWithPrivateKey( - PRIVATE_KEY_TWO, - ); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - const headerNavbar = new HeaderNavbar(driver); - await headerNavbar.check_accountLabel('SSK Account'); - - // send 1 ETH from snap account to account 1 - await sendTransactionWithSnapAccount({ + describe('Old confirmation screens', function () { + it('can import a private key and transfer 1 ETH (sync flow)', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: multipleGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver, - recipientAddress: DEFAULT_FIXTURE_ACCOUNT, - amount: '1', - gasFee: '0.000042', - totalFee: '1.000042', - }); - await headerNavbar.check_pageIsLoaded(); - await headerNavbar.openAccountMenu(); - const accountList = new AccountListPage(driver); - await accountList.check_pageIsLoaded(); - - // check the balance of the 2 accounts are updated - await accountList.check_accountBalanceDisplayed('26'); - await accountList.check_accountBalanceDisplayed('24'); - }, - ); - }); + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + await installSnapSimpleKeyring(driver); + const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); - it('can import a private key and transfer 1 ETH (async flow approve)', async function () { - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: multipleGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ - driver, - ganacheServer, - }: { - driver: Driver; - ganacheServer?: Ganache; - }) => { - await loginWithBalanceValidation(driver, ganacheServer); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - await installSnapSimpleKeyring(driver, false); - const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); - - // import snap account with private key on snap simple keyring page. - await snapSimpleKeyringPage.importAccountWithPrivateKey( - PRIVATE_KEY_TWO, - ); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - const headerNavbar = new HeaderNavbar(driver); - await headerNavbar.check_accountLabel('SSK Account'); - - // send 1 ETH from snap account to account 1 and approve the transaction - await sendTransactionWithSnapAccount({ + // import snap account with private key on snap simple keyring page. + await snapSimpleKeyringPage.importAccountWithPrivateKey( + PRIVATE_KEY_TWO, + ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + const headerNavbar = new HeaderNavbar(driver); + await headerNavbar.check_accountLabel('SSK Account'); + + // send 1 ETH from snap account to account 1 + await sendTransactionWithSnapAccount({ + driver, + recipientAddress: DEFAULT_FIXTURE_ACCOUNT, + amount: '1', + gasFee: '0.000042', + totalFee: '1.000042', + }); + await headerNavbar.check_pageIsLoaded(); + await headerNavbar.openAccountMenu(); + const accountList = new AccountListPage(driver); + await accountList.check_pageIsLoaded(); + + // check the balance of the 2 accounts are updated + await accountList.check_accountBalanceDisplayed('26'); + await accountList.check_accountBalanceDisplayed('24'); + }, + ); + }); + + it('can import a private key and transfer 1 ETH (async flow approve)', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: multipleGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver, - recipientAddress: DEFAULT_FIXTURE_ACCOUNT, - amount: '1', - gasFee: '0.000042', - totalFee: '1.000042', - isSyncFlow: false, - }); - await headerNavbar.check_pageIsLoaded(); - await headerNavbar.openAccountMenu(); - const accountList = new AccountListPage(driver); - await accountList.check_pageIsLoaded(); - - // check the balance of the 2 accounts are updated - await accountList.check_accountBalanceDisplayed('26'); - await accountList.check_accountBalanceDisplayed('24'); - }, - ); + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + await installSnapSimpleKeyring(driver, false); + const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); + + // import snap account with private key on snap simple keyring page. + await snapSimpleKeyringPage.importAccountWithPrivateKey( + PRIVATE_KEY_TWO, + ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + const headerNavbar = new HeaderNavbar(driver); + await headerNavbar.check_accountLabel('SSK Account'); + + // send 1 ETH from snap account to account 1 and approve the transaction + await sendTransactionWithSnapAccount({ + driver, + recipientAddress: DEFAULT_FIXTURE_ACCOUNT, + amount: '1', + gasFee: '0.000042', + totalFee: '1.000042', + isSyncFlow: false, + }); + await headerNavbar.check_pageIsLoaded(); + await headerNavbar.openAccountMenu(); + const accountList = new AccountListPage(driver); + await accountList.check_pageIsLoaded(); + + // check the balance of the 2 accounts are updated + await accountList.check_accountBalanceDisplayed('26'); + await accountList.check_accountBalanceDisplayed('24'); + }, + ); + }); + + it('can import a private key and transfer 1 ETH (async flow reject)', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: multipleGanacheOptions, + title: this.test?.fullTitle(), + ignoredConsoleErrors: ['Request rejected by user or snap.'], + }, + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + await installSnapSimpleKeyring(driver, false); + const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); + + // Import snap account with private key on snap simple keyring page. + await snapSimpleKeyringPage.importAccountWithPrivateKey( + PRIVATE_KEY_TWO, + ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + const headerNavbar = new HeaderNavbar(driver); + await headerNavbar.check_accountLabel('SSK Account'); + + // send 1 ETH from snap account to account 1 and reject the transaction + await sendTransactionWithSnapAccount({ + driver, + recipientAddress: DEFAULT_FIXTURE_ACCOUNT, + amount: '1', + gasFee: '0.000042', + totalFee: '1.000042', + isSyncFlow: false, + approveTransaction: false, + }); + + // check the transaction is failed in MetaMask activity list + const homepage = new HomePage(driver); + await homepage.check_pageIsLoaded(); + await homepage.check_failedTxNumberDisplayedInActivity(); + }, + ); + }); }); - it('can import a private key and transfer 1 ETH (async flow reject)', async function () { - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: multipleGanacheOptions, - title: this.test?.fullTitle(), - ignoredConsoleErrors: ['Request rejected by user or snap.'], - }, - async ({ - driver, - ganacheServer, - }: { - driver: Driver; - ganacheServer?: Ganache; - }) => { - await loginWithBalanceValidation(driver, ganacheServer); - - await tempToggleSettingRedesignedTransactionConfirmations(driver); - - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - - await installSnapSimpleKeyring(driver, false); - const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); - - // Import snap account with private key on snap simple keyring page. - await snapSimpleKeyringPage.importAccountWithPrivateKey( - PRIVATE_KEY_TWO, - ); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - const headerNavbar = new HeaderNavbar(driver); - await headerNavbar.check_accountLabel('SSK Account'); - - // send 1 ETH from snap account to account 1 and reject the transaction - await sendTransactionWithSnapAccount({ + describe('Redesigned confirmation screens', function () { + it('can import a private key and transfer 1 ETH (sync flow)', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: multipleGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + + await installSnapSimpleKeyring(driver); + const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); + + // import snap account with private key on snap simple keyring page. + await snapSimpleKeyringPage.importAccountWithPrivateKey( + PRIVATE_KEY_TWO, + ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + const headerNavbar = new HeaderNavbar(driver); + await headerNavbar.check_accountLabel('SSK Account'); + + // send 1 ETH from snap account to account 1 + await sendRedesignedTransactionWithSnapAccount({ + driver, + recipientAddress: DEFAULT_FIXTURE_ACCOUNT, + amount: '1', + }); + await headerNavbar.check_pageIsLoaded(); + await headerNavbar.openAccountMenu(); + const accountList = new AccountListPage(driver); + await accountList.check_pageIsLoaded(); + + // check the balance of the 2 accounts are updated + await accountList.check_accountBalanceDisplayed('26'); + await accountList.check_accountBalanceDisplayed('24'); + }, + ); + }); + + it('can import a private key and transfer 1 ETH (async flow approve)', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: multipleGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver, - recipientAddress: DEFAULT_FIXTURE_ACCOUNT, - amount: '1', - gasFee: '0.000042', - totalFee: '1.000042', - isSyncFlow: false, - approveTransaction: false, - }); - - // check the transaction is failed in MetaMask activity list - const homepage = new HomePage(driver); - await homepage.check_pageIsLoaded(); - await homepage.check_failedTxNumberDisplayedInActivity(); - }, - ); + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + + await installSnapSimpleKeyring(driver, false); + const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); + + // import snap account with private key on snap simple keyring page. + await snapSimpleKeyringPage.importAccountWithPrivateKey( + PRIVATE_KEY_TWO, + ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + const headerNavbar = new HeaderNavbar(driver); + await headerNavbar.check_accountLabel('SSK Account'); + + // send 1 ETH from snap account to account 1 and approve the transaction + await sendRedesignedTransactionWithSnapAccount({ + driver, + recipientAddress: DEFAULT_FIXTURE_ACCOUNT, + amount: '1', + isSyncFlow: false, + }); + await headerNavbar.check_pageIsLoaded(); + await headerNavbar.openAccountMenu(); + const accountList = new AccountListPage(driver); + await accountList.check_pageIsLoaded(); + + // check the balance of the 2 accounts are updated + await accountList.check_accountBalanceDisplayed('26'); + await accountList.check_accountBalanceDisplayed('24'); + }, + ); + }); + + it('can import a private key and transfer 1 ETH (async flow reject)', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: multipleGanacheOptions, + title: this.test?.fullTitle(), + ignoredConsoleErrors: ['Request rejected by user or snap.'], + }, + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + + await installSnapSimpleKeyring(driver, false); + const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); + + // Import snap account with private key on snap simple keyring page. + await snapSimpleKeyringPage.importAccountWithPrivateKey( + PRIVATE_KEY_TWO, + ); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + const headerNavbar = new HeaderNavbar(driver); + await headerNavbar.check_accountLabel('SSK Account'); + + // send 1 ETH from snap account to account 1 and reject the transaction + await sendRedesignedTransactionWithSnapAccount({ + driver, + recipientAddress: DEFAULT_FIXTURE_ACCOUNT, + amount: '1', + isSyncFlow: false, + approveTransaction: false, + }); + + // check the transaction is failed in MetaMask activity list + const homepage = new HomePage(driver); + await homepage.check_pageIsLoaded(); + await homepage.check_failedTxNumberDisplayedInActivity(); + }, + ); + }); }); }); From 0ef5fc824d7ab77a4ff44f4e92935904cb3541ce Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 22 Nov 2024 11:20:01 +0000 Subject: [PATCH 12/19] Revert test spacing --- test/e2e/snaps/test-snap-txinsights.spec.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/e2e/snaps/test-snap-txinsights.spec.js b/test/e2e/snaps/test-snap-txinsights.spec.js index c5b2076b897e..17964e40d8fb 100644 --- a/test/e2e/snaps/test-snap-txinsights.spec.js +++ b/test/e2e/snaps/test-snap-txinsights.spec.js @@ -32,18 +32,23 @@ describe('Test Snap TxInsights', function () { text: 'Installed Snaps', tag: 'h2', }); + // find and scroll to the transaction-insights test snap const snapButton1 = await driver.findElement( '#connecttransaction-insights', ); await driver.scrollToElement(snapButton1); + // added delay for firefox (deflake) await driver.delayFirefox(1000); + // wait for and click connect await driver.waitForSelector('#connecttransaction-insights'); await driver.clickElement('#connecttransaction-insights'); + // switch to metamask extension await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and click connect await driver.waitForSelector({ text: 'Connect', @@ -53,12 +58,14 @@ describe('Test Snap TxInsights', function () { text: 'Connect', tag: 'button', }); + // wait for and click confirm await driver.waitForSelector({ text: 'Confirm' }); await driver.clickElement({ text: 'Confirm', tag: 'button', }); + // wait for and click ok and wait for window to close await driver.waitForSelector({ text: 'OK' }); await driver.clickElementAndWaitForWindowToClose({ @@ -80,14 +87,19 @@ describe('Test Snap TxInsights', function () { text: 'Connect', tag: 'button', }); + // switch to test-snaps page await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + // click send tx await driver.clickElement('#sendInsights'); + // delay added for rendering (deflake) await driver.delay(2000); + // switch back to MetaMask window await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and switch to insight snap pane await driver.waitForSelector({ text: 'Insights Example Snap', @@ -97,6 +109,7 @@ describe('Test Snap TxInsights', function () { text: 'Insights Example Snap', tag: 'button', }); + // check that txinsightstest tab contains the right info await driver.waitForSelector({ css: '.snap-ui-renderer__content', From 2d2398f4180ca55f87b2b68077b7b6dfcf635cb0 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 22 Nov 2024 11:27:20 +0000 Subject: [PATCH 13/19] Revert test run timeout --- .circleci/scripts/test-run-e2e-timeout-minutes.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/scripts/test-run-e2e-timeout-minutes.ts b/.circleci/scripts/test-run-e2e-timeout-minutes.ts index d381fb1451f6..c539133b0c60 100644 --- a/.circleci/scripts/test-run-e2e-timeout-minutes.ts +++ b/.circleci/scripts/test-run-e2e-timeout-minutes.ts @@ -2,7 +2,7 @@ import { filterE2eChangedFiles } from '../../test/e2e/changedFilesUtil'; const changedOrNewTests = filterE2eChangedFiles(); -// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 60 minutes -const extraTime = Math.min(20 + changedOrNewTests.length * 3, 60); +// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes +const extraTime = Math.min(20 + changedOrNewTests.length * 3, 30); console.log(extraTime); From 4171b58bc566623887284a7a0ff86ee50f05e466 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 22 Nov 2024 11:28:58 +0000 Subject: [PATCH 14/19] remove unnecessary test --- .../e2e/snaps/test-snap-txinsights-v2.spec.js | 134 ------------------ 1 file changed, 134 deletions(-) diff --git a/test/e2e/snaps/test-snap-txinsights-v2.spec.js b/test/e2e/snaps/test-snap-txinsights-v2.spec.js index 857c04d601f7..68e4e6183585 100644 --- a/test/e2e/snaps/test-snap-txinsights-v2.spec.js +++ b/test/e2e/snaps/test-snap-txinsights-v2.spec.js @@ -148,138 +148,4 @@ describe('Test Snap TxInsights-v2', function () { ); }); }); - - describe('Redesigned confirmation screens', function () { - it('tests tx insights v2 functionality', async function () { - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, - title: this.test.fullTitle(), - }, - async ({ driver }) => { - await unlockWallet(driver); - - // navigate to test snaps page and connect - await driver.openNewPage(TEST_SNAPS_WEBSITE_URL); - - // wait for page to load - await driver.waitForSelector({ - text: 'Installed Snaps', - tag: 'h2', - }); - - // find and scroll to the transaction-insights test snap - const snapButton1 = await driver.findElement( - '#connecttransaction-insights', - ); - await driver.scrollToElement(snapButton1); - - // added delay for firefox (deflake) - await driver.delayFirefox(1000); - - // wait for and click connect - await driver.waitForSelector('#connecttransaction-insights'); - await driver.clickElement('#connecttransaction-insights'); - - // switch to metamask extension - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // wait for and click connect - await driver.waitForSelector({ - text: 'Connect', - tag: 'button', - }); - await driver.clickElement({ - text: 'Connect', - tag: 'button', - }); - - // wait for and click connect - await driver.waitForSelector({ text: 'Confirm' }); - await driver.clickElement({ - text: 'Confirm', - tag: 'button', - }); - - // wait for and click ok and wait for window to close - await driver.waitForSelector({ text: 'OK' }); - await driver.clickElementAndWaitForWindowToClose({ - text: 'OK', - tag: 'button', - }); - - // switch to test-snaps page - await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); - - // wait for and click get accounts - await driver.waitForSelector('#getAccounts'); - await driver.clickElement('#getAccounts'); - - // switch back to MetaMask window - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // wait for and click confirm and wait for window to close - await driver.waitForSelector({ - text: 'Connect', - tag: 'button', - }); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); - - // switch to test-snaps page and send tx - await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); - await driver.clickElement('#sendInsights'); - - // delay added for rendering (deflake) - await driver.delay(2000); - - // switch back to MetaMask window and switch to tx insights pane - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - - // find confirm button - await driver.findClickableElement({ - text: 'Confirm', - tag: 'button', - }); - - // wait for and click insights snap tab - await driver.waitForSelector({ - text: 'Insights Example Snap', - tag: 'span', - }); - - // check that tx insight accordion contains the right info - await driver.waitForSelector({ - css: 'p', - text: 'ERC-20', - }); - - // click confirm to continue - await driver.clickElement({ - text: 'Confirm', - tag: 'button', - }); - - // switch back to MetaMask tab - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - - // switch to activity pane - await driver.clickElement({ - tag: 'button', - text: 'Activity', - }); - // wait for transaction confirmation - await driver.waitForSelector({ - css: '.transaction-status-label', - text: 'Confirmed', - }); - }, - ); - }); - }); }); From 23dea5b2f0a45b82eff94e8c6eb04e5950081251 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 22 Nov 2024 11:59:35 +0000 Subject: [PATCH 15/19] fix whitespace --- .../e2e/snaps/test-snap-txinsights-v2.spec.js | 25 +++++++++++++++++++ test/e2e/snaps/test-snap-txinsights.spec.js | 4 +++ 2 files changed, 29 insertions(+) diff --git a/test/e2e/snaps/test-snap-txinsights-v2.spec.js b/test/e2e/snaps/test-snap-txinsights-v2.spec.js index 68e4e6183585..8080fafd11ae 100644 --- a/test/e2e/snaps/test-snap-txinsights-v2.spec.js +++ b/test/e2e/snaps/test-snap-txinsights-v2.spec.js @@ -32,18 +32,23 @@ describe('Test Snap TxInsights-v2', function () { text: 'Installed Snaps', tag: 'h2', }); + // find and scroll to the transaction-insights test snap const snapButton1 = await driver.findElement( '#connecttransaction-insights', ); await driver.scrollToElement(snapButton1); + // added delay for firefox (deflake) await driver.delayFirefox(1000); + // wait for and click connect await driver.waitForSelector('#connecttransaction-insights'); await driver.clickElement('#connecttransaction-insights'); + // switch to metamask extension await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and click connect await driver.waitForSelector({ text: 'Connect', @@ -53,25 +58,31 @@ describe('Test Snap TxInsights-v2', function () { text: 'Connect', tag: 'button', }); + // wait for and click connect await driver.waitForSelector({ text: 'Confirm' }); await driver.clickElement({ text: 'Confirm', tag: 'button', }); + // wait for and click ok and wait for window to close await driver.waitForSelector({ text: 'OK' }); await driver.clickElementAndWaitForWindowToClose({ text: 'OK', tag: 'button', }); + // switch to test-snaps page await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + // wait for and click get accounts await driver.waitForSelector('#getAccounts'); await driver.clickElement('#getAccounts'); + // switch back to MetaMask window await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and click confirm and wait for window to close await driver.waitForSelector({ text: 'Connect', @@ -81,18 +92,23 @@ describe('Test Snap TxInsights-v2', function () { text: 'Connect', tag: 'button', }); + // switch to test-snaps page and send tx await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); await driver.clickElement('#sendInsights'); + // delay added for rendering (deflake) await driver.delay(2000); + // switch back to MetaMask window and switch to tx insights pane await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // find confirm button await driver.findClickableElement({ text: 'Confirm', tag: 'button', }); + // wait for and click insights snap tab await driver.waitForSelector({ text: 'Insights Example Snap', @@ -102,43 +118,52 @@ describe('Test Snap TxInsights-v2', function () { text: 'Insights Example Snap', tag: 'button', }); + // check that txinsightstest tab contains the right info await driver.waitForSelector({ css: '.snap-ui-renderer__content', text: 'ERC-20', }); + // click confirm to continue await driver.clickElement({ text: 'Confirm', tag: 'button', }); + // check for warning from txinsights await driver.waitForSelector({ css: '.snap-delineator__header__text', text: 'Warning from Insights Example Snap', }); + // check info in warning await driver.waitForSelector({ css: '.snap-ui-renderer__text', text: 'ERC-20', }); + // click the warning confirm checkbox await driver.clickElement('.mm-checkbox__input'); + // click confirm button to send transaction await driver.clickElement({ css: '.mm-box--color-error-inverse', text: 'Confirm', tag: 'button', }); + // switch back to MetaMask tab await driver.switchToWindowWithTitle( WINDOW_TITLES.ExtensionInFullScreenView, ); + // switch to activity pane await driver.clickElement({ tag: 'button', text: 'Activity', }); + // wait for transaction confirmation await driver.waitForSelector({ css: '.transaction-status-label', diff --git a/test/e2e/snaps/test-snap-txinsights.spec.js b/test/e2e/snaps/test-snap-txinsights.spec.js index 17964e40d8fb..109051725396 100644 --- a/test/e2e/snaps/test-snap-txinsights.spec.js +++ b/test/e2e/snaps/test-snap-txinsights.spec.js @@ -72,12 +72,16 @@ describe('Test Snap TxInsights', function () { text: 'OK', tag: 'button', }); + // switch to test-snaps page and get accounts await driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps); + // click get accounts await driver.clickElement('#getAccounts'); + // switch back to MetaMask window await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // wait for and click next and wait for window to close await driver.waitForSelector({ text: 'Connect', From a41965667896131784810ea11ace6f08f02f63b2 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 22 Nov 2024 12:14:19 +0000 Subject: [PATCH 16/19] fix linting errors --- app/scripts/migrations/132.ts | 2 +- test/e2e/page-objects/flows/send-transaction.flow.ts | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/scripts/migrations/132.ts b/app/scripts/migrations/132.ts index 9668b503d511..ec12595d389a 100644 --- a/app/scripts/migrations/132.ts +++ b/app/scripts/migrations/132.ts @@ -40,7 +40,7 @@ function transformState( }; } - let preferencesControllerState = state.PreferencesController as Record< + const preferencesControllerState = state.PreferencesController as Record< string, unknown >; diff --git a/test/e2e/page-objects/flows/send-transaction.flow.ts b/test/e2e/page-objects/flows/send-transaction.flow.ts index 1cb2a26d31bb..8af88f01aca6 100644 --- a/test/e2e/page-objects/flows/send-transaction.flow.ts +++ b/test/e2e/page-objects/flows/send-transaction.flow.ts @@ -55,8 +55,6 @@ export const sendTransactionToAddress = async ({ * @param params.driver - The webdriver instance. * @param params.recipientAddress - The recipient address. * @param params.amount - The amount of the asset to be sent in the transaction. - * @param params.gasFee - The expected transaction gas fee. - * @param params.totalFee - The expected total transaction fee. */ export const sendRedesignedTransactionToAddress = async ({ driver, @@ -179,8 +177,6 @@ export const sendTransactionWithSnapAccount = async ({ * @param params.driver - The webdriver instance. * @param params.recipientAddress - The recipient address. * @param params.amount - The amount of the asset to be sent in the transaction. - * @param params.gasFee - The expected transaction gas fee. - * @param params.totalFee - The expected total transaction fee. * @param params.isSyncFlow - Indicates whether synchronous approval option is on for the snap. Defaults to true. * @param params.approveTransaction - Indicates whether the transaction should be approved. Defaults to true. */ From e8b230dda23b89f748f5f37583ff3632d4417afe Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 22 Nov 2024 16:28:00 +0000 Subject: [PATCH 17/19] Refactor closing the settings panel --- test/e2e/helpers.js | 5 +++++ test/e2e/json-rpc/switchEthereumChain.spec.js | 2 -- .../e2e/snaps/test-snap-txinsights-v2.spec.js | 1 - test/e2e/snaps/test-snap-txinsights.spec.js | 1 - .../account/snap-account-transfers.spec.ts | 9 -------- .../contract-interactions.spec.js | 3 --- .../dapp-interactions/dapp-tx-edit.spec.js | 6 ------ .../failing-contract.spec.js | 6 ------ test/e2e/tests/network/network-error.spec.js | 1 - .../petnames/petnames-transactions.spec.js | 2 -- .../ppom-blockaid-alert-simple-send.spec.js | 3 --- .../batch-txs-per-dapp-diff-network.spec.js | 3 --- .../batch-txs-per-dapp-extra-tx.spec.js | 3 --- .../batch-txs-per-dapp-same-network.spec.js | 3 --- .../dapp1-send-dapp2-signTypedData.spec.js | 3 --- ...-switch-dapp2-eth-request-accounts.spec.js | 1 - .../dapp1-switch-dapp2-send.spec.js | 6 ------ ...multi-dapp-sendTx-revokePermission.spec.js | 3 --- .../multiple-networks-dapps-txs.spec.js | 3 --- .../request-queuing/switch-network.spec.js | 3 --- test/e2e/tests/request-queuing/ui.spec.js | 15 ------------- .../metamask-responsive-ui.spec.js | 3 --- .../tests/settings/4byte-directory.spec.js | 6 ------ test/e2e/tests/settings/show-hex-data.spec.js | 1 - .../tokens/custom-token-add-approve.spec.js | 12 ----------- .../tokens/custom-token-send-transfer.spec.js | 9 -------- .../tokens/increase-token-allowance.spec.js | 1 - .../tokens/nft/erc1155-interaction.spec.js | 12 ----------- .../tokens/nft/erc721-interaction.spec.js | 21 ------------------- test/e2e/tests/tokens/nft/send-nft.spec.js | 3 --- .../tests/transaction/change-assets.spec.js | 12 ----------- .../tests/transaction/edit-gas-fee.spec.js | 8 ------- .../tests/transaction/gas-estimates.spec.js | 18 ---------------- .../transaction/multiple-transactions.spec.js | 6 ------ .../transaction/navigate-transactions.spec.js | 15 ------------- test/e2e/tests/transaction/send-edit.spec.js | 2 -- test/e2e/tests/transaction/send-eth.spec.js | 12 ----------- .../transaction/send-hex-address.spec.js | 6 ------ .../e2e/tests/transaction/simple-send.spec.ts | 1 - 39 files changed, 5 insertions(+), 225 deletions(-) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 444caa3130e1..cc7173e87aa3 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -893,6 +893,11 @@ async function tempToggleSettingRedesignedTransactionConfirmations(driver) { await driver.clickElement( '[data-testid="toggle-redesigned-transactions-container"]', ); + + // Close settings page + await driver.clickElement( + '.settings-page__header__title-container__close-button', + ); } /** diff --git a/test/e2e/json-rpc/switchEthereumChain.spec.js b/test/e2e/json-rpc/switchEthereumChain.spec.js index 8841b7007a81..858dcacf9241 100644 --- a/test/e2e/json-rpc/switchEthereumChain.spec.js +++ b/test/e2e/json-rpc/switchEthereumChain.spec.js @@ -35,8 +35,6 @@ describe('Switch Ethereum Chain for two dapps', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); - // Open settings menu button const accountOptionsMenuSelector = '[data-testid="account-options-menu-button"]'; diff --git a/test/e2e/snaps/test-snap-txinsights-v2.spec.js b/test/e2e/snaps/test-snap-txinsights-v2.spec.js index 8080fafd11ae..74a82350ace7 100644 --- a/test/e2e/snaps/test-snap-txinsights-v2.spec.js +++ b/test/e2e/snaps/test-snap-txinsights-v2.spec.js @@ -22,7 +22,6 @@ describe('Test Snap TxInsights-v2', function () { await unlockWallet(driver); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); // navigate to test snaps page and connect await driver.openNewPage(TEST_SNAPS_WEBSITE_URL); diff --git a/test/e2e/snaps/test-snap-txinsights.spec.js b/test/e2e/snaps/test-snap-txinsights.spec.js index 109051725396..0ade039ac065 100644 --- a/test/e2e/snaps/test-snap-txinsights.spec.js +++ b/test/e2e/snaps/test-snap-txinsights.spec.js @@ -22,7 +22,6 @@ describe('Test Snap TxInsights', function () { await unlockWallet(driver); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); // navigate to test snaps page and connect await driver.driver.get(TEST_SNAPS_WEBSITE_URL); diff --git a/test/e2e/tests/account/snap-account-transfers.spec.ts b/test/e2e/tests/account/snap-account-transfers.spec.ts index 387e744fd8ca..202170106e47 100644 --- a/test/e2e/tests/account/snap-account-transfers.spec.ts +++ b/test/e2e/tests/account/snap-account-transfers.spec.ts @@ -41,9 +41,6 @@ describe('Snap Account Transfers @no-mmi', function (this: Suite) { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await installSnapSimpleKeyring(driver); const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); @@ -95,9 +92,6 @@ describe('Snap Account Transfers @no-mmi', function (this: Suite) { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await installSnapSimpleKeyring(driver, false); const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); @@ -151,9 +145,6 @@ describe('Snap Account Transfers @no-mmi', function (this: Suite) { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await installSnapSimpleKeyring(driver, false); const snapSimpleKeyringPage = new SnapSimpleKeyringPage(driver); diff --git a/test/e2e/tests/dapp-interactions/contract-interactions.spec.js b/test/e2e/tests/dapp-interactions/contract-interactions.spec.js index 2c6bc07be695..6bda3e9ed055 100644 --- a/test/e2e/tests/dapp-interactions/contract-interactions.spec.js +++ b/test/e2e/tests/dapp-interactions/contract-interactions.spec.js @@ -35,9 +35,6 @@ describe('Deploy contract and call contract methods', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // deploy contract await openDapp(driver, contractAddress); diff --git a/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js b/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js index 2ff6fc525358..a7aff71ebf44 100644 --- a/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js +++ b/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js @@ -31,9 +31,6 @@ describe('Editing confirmations of dapp initiated contract interactions', functi await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // deploy contract await openDapp(driver, contractAddress); // wait for deployed contract, calls and confirms a contract method where ETH is sent @@ -68,9 +65,6 @@ describe('Editing confirmations of dapp initiated contract interactions', functi await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openDapp(driver); await driver.clickElement('#sendButton'); diff --git a/test/e2e/tests/dapp-interactions/failing-contract.spec.js b/test/e2e/tests/dapp-interactions/failing-contract.spec.js index 90419ba6d0be..7b842bb4b95a 100644 --- a/test/e2e/tests/dapp-interactions/failing-contract.spec.js +++ b/test/e2e/tests/dapp-interactions/failing-contract.spec.js @@ -33,9 +33,6 @@ describe('Failing contract interaction ', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openDapp(driver, contractAddress); let windowHandles = await driver.getAllWindowHandles(); const extension = windowHandles[0]; @@ -102,9 +99,6 @@ describe('Failing contract interaction on non-EIP1559 network', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openDapp(driver, contractAddress); let windowHandles = await driver.getAllWindowHandles(); const extension = windowHandles[0]; diff --git a/test/e2e/tests/network/network-error.spec.js b/test/e2e/tests/network/network-error.spec.js index b85430420d1a..833643210464 100644 --- a/test/e2e/tests/network/network-error.spec.js +++ b/test/e2e/tests/network/network-error.spec.js @@ -61,7 +61,6 @@ describe('Gas API fallback', function () { await logInWithBalanceValidation(driver, ganacheServer); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); await openActionMenuAndStartSendFlow(driver); await driver.fill( diff --git a/test/e2e/tests/petnames/petnames-transactions.spec.js b/test/e2e/tests/petnames/petnames-transactions.spec.js index b2249feb1d66..d3044bd65ed2 100644 --- a/test/e2e/tests/petnames/petnames-transactions.spec.js +++ b/test/e2e/tests/petnames/petnames-transactions.spec.js @@ -53,7 +53,6 @@ describe('Petnames - Transactions', function () { await unlockWallet(driver); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); await openDapp(driver); await createDappSendTransaction(driver); @@ -101,7 +100,6 @@ describe('Petnames - Transactions', function () { async ({ driver }) => { await unlockWallet(driver); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); await createWalletSendTransaction(driver, ADDRESS_MOCK); await expectName(driver, ABBREVIATED_ADDRESS_MOCK, false); diff --git a/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js b/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js index cad3c9aadafa..c6e693d01ed3 100644 --- a/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js +++ b/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js @@ -212,9 +212,6 @@ describe('Simple Send Security Alert - Blockaid @no-mmi', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await sendScreenToConfirmScreen( driver, '0xB8c77482e45F1F44dE1745F52C74426C631bDD52', diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js index 8dba11b86646..eaf791b4ebb9 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js @@ -44,9 +44,6 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks', fun await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js index bdbceed0be58..4c4cb28976b5 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js @@ -44,9 +44,6 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks', fun await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js index 991e497354d8..bd69656c3fc9 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js @@ -50,9 +50,6 @@ describe('Request Queuing for Multiple Dapps and Txs on same networks', function await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js b/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js index b574d3f9f0e3..28b19efbeb04 100644 --- a/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-send-dapp2-signTypedData.spec.js @@ -54,9 +54,6 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open and connect Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js index 58597ee790d9..9c1e874fc4cc 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js @@ -43,7 +43,6 @@ describe('Request Queuing Dapp 1 Send Tx -> Dapp 2 Request Accounts Tx', functio await unlockWallet(driver); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); // Open Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js index 31ce249d60b4..e2e211fee301 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js @@ -47,9 +47,6 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp One await openDapp(driver, undefined, DAPP_URL); @@ -207,9 +204,6 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js index 7e7e4c81d3a9..56c244c484bb 100644 --- a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js +++ b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js @@ -42,9 +42,6 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks revok await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js b/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js index 87ec535316f2..04845b28828b 100644 --- a/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js +++ b/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js @@ -43,9 +43,6 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks.', fu await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp One await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/switch-network.spec.js b/test/e2e/tests/request-queuing/switch-network.spec.js index 13143f6d342d..913bdf459a26 100644 --- a/test/e2e/tests/request-queuing/switch-network.spec.js +++ b/test/e2e/tests/request-queuing/switch-network.spec.js @@ -41,9 +41,6 @@ describe('Request Queuing Switch Network on Dapp Send Tx while on different netw await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open dapp await openDapp(driver, undefined, DAPP_URL); diff --git a/test/e2e/tests/request-queuing/ui.spec.js b/test/e2e/tests/request-queuing/ui.spec.js index c50fda4f807b..707c252396b7 100644 --- a/test/e2e/tests/request-queuing/ui.spec.js +++ b/test/e2e/tests/request-queuing/ui.spec.js @@ -259,9 +259,6 @@ describe('Request-queue UI changes', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open the first dapp await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); @@ -333,9 +330,6 @@ describe('Request-queue UI changes', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open the first dapp await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); @@ -455,9 +449,6 @@ describe('Request-queue UI changes', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open the first dapp await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); @@ -614,9 +605,6 @@ describe('Request-queue UI changes', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open the first dapp await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); @@ -685,9 +673,6 @@ describe('Request-queue UI changes', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open the first dapp await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); diff --git a/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js b/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js index 33f1915f300f..78d92dff5999 100644 --- a/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js +++ b/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js @@ -134,9 +134,6 @@ describe('MetaMask Responsive UI', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Send ETH from inside MetaMask // starts to send a transaction await openActionMenuAndStartSendFlow(driver); diff --git a/test/e2e/tests/settings/4byte-directory.spec.js b/test/e2e/tests/settings/4byte-directory.spec.js index a9d1916d692f..ff14ddda2432 100644 --- a/test/e2e/tests/settings/4byte-directory.spec.js +++ b/test/e2e/tests/settings/4byte-directory.spec.js @@ -31,9 +31,6 @@ describe('4byte setting', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // deploy contract await openDapp(driver, contractAddress); @@ -72,9 +69,6 @@ describe('4byte setting', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // goes to the settings screen await openMenuSafe(driver); await driver.clickElement({ text: 'Settings', tag: 'div' }); diff --git a/test/e2e/tests/settings/show-hex-data.spec.js b/test/e2e/tests/settings/show-hex-data.spec.js index 767c55decfb9..bbd60c3275e7 100644 --- a/test/e2e/tests/settings/show-hex-data.spec.js +++ b/test/e2e/tests/settings/show-hex-data.spec.js @@ -82,7 +82,6 @@ describe('Check the toggle for hex data', function () { await logInWithBalanceValidation(driver, ganacheServer); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); await toggleHexData(driver); await clickOnLogo(driver); diff --git a/test/e2e/tests/tokens/custom-token-add-approve.spec.js b/test/e2e/tests/tokens/custom-token-add-approve.spec.js index a01a96692ec9..390e69cf3e77 100644 --- a/test/e2e/tests/tokens/custom-token-add-approve.spec.js +++ b/test/e2e/tests/tokens/custom-token-add-approve.spec.js @@ -87,9 +87,6 @@ describe('Create token, approve token and approve token without gas', function ( await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // create token await openDapp(driver, contractAddress); @@ -190,9 +187,6 @@ describe('Create token, approve token and approve token without gas', function ( await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // create token await openDapp(driver, contractAddress); @@ -330,9 +324,6 @@ describe('Create token, approve token and approve token without gas', function ( await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // create token await openDapp(driver, contractAddress); const windowHandles = await driver.getAllWindowHandles(); @@ -416,9 +407,6 @@ describe('Create token, approve token and approve token without gas', function ( await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openDapp(driver, contractAddress); const windowHandles = await driver.getAllWindowHandles(); const extension = windowHandles[0]; diff --git a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js index 54bc5ce29d20..1dd71ea5853a 100644 --- a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js +++ b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js @@ -33,9 +33,6 @@ describe('Transfer custom tokens @no-mmi', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // go to custom tokens view on extension, perform send tokens await driver.clickElement({ css: '[data-testid="multichain-token-list-item-value"]', @@ -125,9 +122,6 @@ describe('Transfer custom tokens @no-mmi', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // transfer token from dapp await openDapp(driver, contractAddress); await driver.delay(veryLargeDelayMs); @@ -192,9 +186,6 @@ describe('Transfer custom tokens @no-mmi', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // transfer token from dapp await openDapp(driver, contractAddress); await driver.delay(veryLargeDelayMs); diff --git a/test/e2e/tests/tokens/increase-token-allowance.spec.js b/test/e2e/tests/tokens/increase-token-allowance.spec.js index 218e55aa1db9..ef2ba6af37cb 100644 --- a/test/e2e/tests/tokens/increase-token-allowance.spec.js +++ b/test/e2e/tests/tokens/increase-token-allowance.spec.js @@ -41,7 +41,6 @@ describe('Increase Token Allowance', function () { await unlockWallet(driver); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); const contractAddress = await contractRegistry.getContractAddress( smartContract, diff --git a/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js b/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js index 21c98a397916..473c765669c8 100644 --- a/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js +++ b/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js @@ -43,9 +43,6 @@ describe('ERC1155 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -128,9 +125,6 @@ describe('ERC1155 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openDapp(driver, contract); await driver.fill('#batchTransferTokenIds', '1, 2, 3'); @@ -185,9 +179,6 @@ describe('ERC1155 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Create a set approval for all erc1155 token request in test dapp await openDapp(driver, contract); await driver.clickElement('#setApprovalForAllERC1155Button'); @@ -274,9 +265,6 @@ describe('ERC1155 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Create a revoke approval for all erc1155 token request in test dapp await openDapp(driver, contract); diff --git a/test/e2e/tests/tokens/nft/erc721-interaction.spec.js b/test/e2e/tests/tokens/nft/erc721-interaction.spec.js index 35c2e9b86685..d1bf8174cb5b 100644 --- a/test/e2e/tests/tokens/nft/erc721-interaction.spec.js +++ b/test/e2e/tests/tokens/nft/erc721-interaction.spec.js @@ -32,9 +32,6 @@ describe('ERC721 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -100,9 +97,6 @@ describe('ERC721 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -226,9 +220,6 @@ describe('ERC721 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -329,9 +320,6 @@ describe('ERC721 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -381,9 +369,6 @@ describe('ERC721 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -453,9 +438,6 @@ describe('ERC721 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -524,9 +506,6 @@ describe('ERC721 NFTs testdapp interaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); diff --git a/test/e2e/tests/tokens/nft/send-nft.spec.js b/test/e2e/tests/tokens/nft/send-nft.spec.js index eb44466d20ef..6aeece064c1e 100644 --- a/test/e2e/tests/tokens/nft/send-nft.spec.js +++ b/test/e2e/tests/tokens/nft/send-nft.spec.js @@ -28,9 +28,6 @@ describe('Send NFT', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Fill the send NFT form and confirm the transaction await driver.clickElement('[data-testid="account-overview__nfts-tab"]'); await driver.clickElement('.nft-item__container'); diff --git a/test/e2e/tests/transaction/change-assets.spec.js b/test/e2e/tests/transaction/change-assets.spec.js index 59209054d28d..d8c095259ac4 100644 --- a/test/e2e/tests/transaction/change-assets.spec.js +++ b/test/e2e/tests/transaction/change-assets.spec.js @@ -26,9 +26,6 @@ describe('Change assets', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Wait for balance to load await driver.delay(500); @@ -109,9 +106,6 @@ describe('Change assets', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Click the Send button await driver.clickElement({ css: '[data-testid="multichain-token-list-button"] span', @@ -193,9 +187,6 @@ describe('Change assets', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Choose the nft await driver.clickElement('[data-testid="account-overview__nfts-tab"]'); await driver.clickElement('[data-testid="nft-default-image"]'); @@ -285,9 +276,6 @@ describe('Change assets', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Create second account await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement( diff --git a/test/e2e/tests/transaction/edit-gas-fee.spec.js b/test/e2e/tests/transaction/edit-gas-fee.spec.js index 8db05aa19375..6e3bfb8f6c82 100644 --- a/test/e2e/tests/transaction/edit-gas-fee.spec.js +++ b/test/e2e/tests/transaction/edit-gas-fee.spec.js @@ -27,9 +27,6 @@ describe('Editing Confirm Transaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await createInternalTransaction(driver); await driver.findElement({ @@ -106,8 +103,6 @@ describe('Editing Confirm Transaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); await createInternalTransaction(driver); await driver.findElement({ @@ -187,9 +182,6 @@ describe('Editing Confirm Transaction', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await createDappTransaction(driver, { maxFeePerGas: '0x2000000000', maxPriorityFeePerGas: '0x1000000000', diff --git a/test/e2e/tests/transaction/gas-estimates.spec.js b/test/e2e/tests/transaction/gas-estimates.spec.js index 83c16f59a25b..1335c954d76e 100644 --- a/test/e2e/tests/transaction/gas-estimates.spec.js +++ b/test/e2e/tests/transaction/gas-estimates.spec.js @@ -31,9 +31,6 @@ describe('Gas estimates generated by MetaMask', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openActionMenuAndStartSendFlow(driver); await driver.fill( @@ -78,9 +75,6 @@ describe('Gas estimates generated by MetaMask', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openActionMenuAndStartSendFlow(driver); await driver.fill( @@ -122,9 +116,6 @@ describe('Gas estimates generated by MetaMask', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openActionMenuAndStartSendFlow(driver); await driver.fill( @@ -162,9 +153,6 @@ describe('Gas estimates generated by MetaMask', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openActionMenuAndStartSendFlow(driver); await driver.fill( 'input[placeholder="Enter public address (0x) or domain name"]', @@ -213,9 +201,6 @@ describe('Gas estimates generated by MetaMask', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openActionMenuAndStartSendFlow(driver); await driver.fill( 'input[placeholder="Enter public address (0x) or domain name"]', @@ -247,9 +232,6 @@ describe('Gas estimates generated by MetaMask', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await openActionMenuAndStartSendFlow(driver); await driver.fill( 'input[placeholder="Enter public address (0x) or domain name"]', diff --git a/test/e2e/tests/transaction/multiple-transactions.spec.js b/test/e2e/tests/transaction/multiple-transactions.spec.js index 915f877a0ef3..351a2d35f2b6 100644 --- a/test/e2e/tests/transaction/multiple-transactions.spec.js +++ b/test/e2e/tests/transaction/multiple-transactions.spec.js @@ -27,9 +27,6 @@ describe('Multiple transactions', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // initiates a transaction from the dapp await openDapp(driver); // creates first transaction @@ -94,9 +91,6 @@ describe('Multiple transactions', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // initiates a transaction from the dapp await openDapp(driver); // creates first transaction diff --git a/test/e2e/tests/transaction/navigate-transactions.spec.js b/test/e2e/tests/transaction/navigate-transactions.spec.js index f80445e03784..cf90a2b814f5 100644 --- a/test/e2e/tests/transaction/navigate-transactions.spec.js +++ b/test/e2e/tests/transaction/navigate-transactions.spec.js @@ -36,9 +36,6 @@ describe('Navigate transactions', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await createMultipleTransactions(driver, TRANSACTION_COUNT); const navigation = new ConfirmationNavigation(driver); @@ -83,9 +80,6 @@ describe('Navigate transactions', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await createMultipleTransactions(driver, TRANSACTION_COUNT); const navigation = new ConfirmationNavigation(driver); @@ -123,9 +117,6 @@ describe('Navigate transactions', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await createMultipleTransactions(driver, TRANSACTION_COUNT); // reject transaction @@ -153,9 +144,6 @@ describe('Navigate transactions', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await createMultipleTransactions(driver, TRANSACTION_COUNT); // confirm transaction @@ -183,9 +171,6 @@ describe('Navigate transactions', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await createMultipleTransactions(driver, TRANSACTION_COUNT); // reject transactions diff --git a/test/e2e/tests/transaction/send-edit.spec.js b/test/e2e/tests/transaction/send-edit.spec.js index 942035d5e705..030b9ab4467e 100644 --- a/test/e2e/tests/transaction/send-edit.spec.js +++ b/test/e2e/tests/transaction/send-edit.spec.js @@ -24,7 +24,6 @@ describe('Editing Confirm Transaction', function () { async ({ driver }) => { await unlockWallet(driver); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); await createInternalTransaction(driver); await driver.findElement({ @@ -101,7 +100,6 @@ describe('Editing Confirm Transaction', function () { async ({ driver }) => { await unlockWallet(driver); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); await createInternalTransaction(driver); diff --git a/test/e2e/tests/transaction/send-eth.spec.js b/test/e2e/tests/transaction/send-eth.spec.js index dbdbcbfecf39..bfe9a4144ea5 100644 --- a/test/e2e/tests/transaction/send-eth.spec.js +++ b/test/e2e/tests/transaction/send-eth.spec.js @@ -110,9 +110,6 @@ describe('Send ETH', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await driver.delay(1000); await openActionMenuAndStartSendFlow(driver); @@ -265,9 +262,6 @@ describe('Send ETH', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // initiates a send from the dapp await openDapp(driver); await driver.clickElement({ text: 'Send', tag: 'button' }); @@ -346,9 +340,6 @@ describe('Send ETH', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // initiates a transaction from the dapp await openDapp(driver); await driver.clickElement({ text: 'Create Token', tag: 'button' }); @@ -454,9 +445,6 @@ describe('Send ETH', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - await driver.assertElementNotPresent('.loading-overlay__spinner'); const balance = await driver.findElement( '[data-testid="eth-overview__primary-currency"]', diff --git a/test/e2e/tests/transaction/send-hex-address.spec.js b/test/e2e/tests/transaction/send-hex-address.spec.js index 608ace11e7cd..b6639ea50930 100644 --- a/test/e2e/tests/transaction/send-hex-address.spec.js +++ b/test/e2e/tests/transaction/send-hex-address.spec.js @@ -124,9 +124,6 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Send TST await driver.clickElement( '[data-testid="account-overview__asset-tab"]', @@ -191,9 +188,6 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { await tempToggleSettingRedesignedTransactionConfirmations(driver); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); - // Send TST await driver.clickElement( '[data-testid="account-overview__asset-tab"]', diff --git a/test/e2e/tests/transaction/simple-send.spec.ts b/test/e2e/tests/transaction/simple-send.spec.ts index 637ffcde474b..5e89b7c5f781 100644 --- a/test/e2e/tests/transaction/simple-send.spec.ts +++ b/test/e2e/tests/transaction/simple-send.spec.ts @@ -29,7 +29,6 @@ describe('Simple send eth', function (this: Suite) { await loginWithBalanceValidation(driver, ganacheServer); await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.navigate(PAGES.HOME); await sendTransactionToAddress({ driver, From d708e8b820e2fefe011996e4cac3753fff2b33c9 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Fri, 22 Nov 2024 17:00:31 +0000 Subject: [PATCH 18/19] fix linting errors --- test/e2e/json-rpc/switchEthereumChain.spec.js | 1 - test/e2e/snaps/test-snap-txinsights-v2.spec.js | 1 - test/e2e/snaps/test-snap-txinsights.spec.js | 1 - test/e2e/tests/account/snap-account-transfers.spec.ts | 2 +- test/e2e/tests/dapp-interactions/contract-interactions.spec.js | 1 - test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js | 1 - test/e2e/tests/dapp-interactions/failing-contract.spec.js | 1 - test/e2e/tests/network/network-error.spec.js | 1 - test/e2e/tests/petnames/petnames-transactions.spec.js | 1 - test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js | 1 - .../request-queuing/batch-txs-per-dapp-diff-network.spec.js | 1 - .../tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js | 1 - .../request-queuing/batch-txs-per-dapp-same-network.spec.js | 1 - .../dapp1-switch-dapp2-eth-request-accounts.spec.js | 1 - test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js | 1 - .../request-queuing/multi-dapp-sendTx-revokePermission.spec.js | 1 - .../tests/request-queuing/multiple-networks-dapps-txs.spec.js | 1 - test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js | 1 - test/e2e/tests/settings/4byte-directory.spec.js | 1 - test/e2e/tests/settings/show-hex-data.spec.js | 1 - test/e2e/tests/tokens/custom-token-add-approve.spec.js | 1 - test/e2e/tests/tokens/custom-token-send-transfer.spec.js | 1 - test/e2e/tests/tokens/increase-token-allowance.spec.js | 1 - test/e2e/tests/tokens/nft/erc1155-interaction.spec.js | 1 - test/e2e/tests/tokens/nft/erc721-interaction.spec.js | 1 - test/e2e/tests/tokens/nft/send-nft.spec.js | 1 - test/e2e/tests/transaction/change-assets.spec.js | 1 - test/e2e/tests/transaction/edit-gas-fee.spec.js | 1 - test/e2e/tests/transaction/gas-estimates.spec.js | 1 - test/e2e/tests/transaction/multiple-transactions.spec.js | 1 - test/e2e/tests/transaction/navigate-transactions.spec.js | 1 - test/e2e/tests/transaction/send-edit.spec.js | 1 - test/e2e/tests/transaction/send-eth.spec.js | 1 - test/e2e/tests/transaction/send-hex-address.spec.js | 1 - test/e2e/tests/transaction/simple-send.spec.ts | 2 +- 35 files changed, 2 insertions(+), 35 deletions(-) diff --git a/test/e2e/json-rpc/switchEthereumChain.spec.js b/test/e2e/json-rpc/switchEthereumChain.spec.js index 858dcacf9241..6a8576b3f136 100644 --- a/test/e2e/json-rpc/switchEthereumChain.spec.js +++ b/test/e2e/json-rpc/switchEthereumChain.spec.js @@ -11,7 +11,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); -const { PAGES } = require('../webdriver/driver'); const { isManifestV3 } = require('../../../shared/modules/mv3.utils'); describe('Switch Ethereum Chain for two dapps', function () { diff --git a/test/e2e/snaps/test-snap-txinsights-v2.spec.js b/test/e2e/snaps/test-snap-txinsights-v2.spec.js index 74a82350ace7..ba2d468a870a 100644 --- a/test/e2e/snaps/test-snap-txinsights-v2.spec.js +++ b/test/e2e/snaps/test-snap-txinsights-v2.spec.js @@ -6,7 +6,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); -const { PAGES } = require('../webdriver/driver'); const { TEST_SNAPS_WEBSITE_URL } = require('./enums'); describe('Test Snap TxInsights-v2', function () { diff --git a/test/e2e/snaps/test-snap-txinsights.spec.js b/test/e2e/snaps/test-snap-txinsights.spec.js index 0ade039ac065..0171759587b5 100644 --- a/test/e2e/snaps/test-snap-txinsights.spec.js +++ b/test/e2e/snaps/test-snap-txinsights.spec.js @@ -6,7 +6,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); -const { PAGES } = require('../webdriver/driver'); const { TEST_SNAPS_WEBSITE_URL } = require('./enums'); describe('Test Snap TxInsights', function () { diff --git a/test/e2e/tests/account/snap-account-transfers.spec.ts b/test/e2e/tests/account/snap-account-transfers.spec.ts index 202170106e47..e38a65c89738 100644 --- a/test/e2e/tests/account/snap-account-transfers.spec.ts +++ b/test/e2e/tests/account/snap-account-transfers.spec.ts @@ -7,7 +7,7 @@ import { withFixtures, } from '../../helpers'; import { DEFAULT_FIXTURE_ACCOUNT } from '../../constants'; -import { Driver, PAGES } from '../../webdriver/driver'; +import { Driver } from '../../webdriver/driver'; import { Ganache } from '../../seeder/ganache'; import AccountListPage from '../../page-objects/pages/account-list-page'; import FixtureBuilder from '../../fixture-builder'; diff --git a/test/e2e/tests/dapp-interactions/contract-interactions.spec.js b/test/e2e/tests/dapp-interactions/contract-interactions.spec.js index 6bda3e9ed055..a685954b5857 100644 --- a/test/e2e/tests/dapp-interactions/contract-interactions.spec.js +++ b/test/e2e/tests/dapp-interactions/contract-interactions.spec.js @@ -9,7 +9,6 @@ const { clickNestedButton, tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -const { PAGES } = require('../../webdriver/driver'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); diff --git a/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js b/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js index a7aff71ebf44..ad168a2b9332 100644 --- a/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js +++ b/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js @@ -1,4 +1,3 @@ -const { PAGES } = require('../../webdriver/driver'); const { defaultGanacheOptions, logInWithBalanceValidation, diff --git a/test/e2e/tests/dapp-interactions/failing-contract.spec.js b/test/e2e/tests/dapp-interactions/failing-contract.spec.js index 7b842bb4b95a..c05938d668e0 100644 --- a/test/e2e/tests/dapp-interactions/failing-contract.spec.js +++ b/test/e2e/tests/dapp-interactions/failing-contract.spec.js @@ -10,7 +10,6 @@ const { } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); describe('Failing contract interaction ', function () { const smartContract = SMART_CONTRACTS.FAILING; diff --git a/test/e2e/tests/network/network-error.spec.js b/test/e2e/tests/network/network-error.spec.js index 833643210464..61842f482151 100644 --- a/test/e2e/tests/network/network-error.spec.js +++ b/test/e2e/tests/network/network-error.spec.js @@ -7,7 +7,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); const { GAS_API_BASE_URL } = require('../../../../shared/constants/swaps'); describe('Gas API fallback', function () { diff --git a/test/e2e/tests/petnames/petnames-transactions.spec.js b/test/e2e/tests/petnames/petnames-transactions.spec.js index d3044bd65ed2..55c295c51c3a 100644 --- a/test/e2e/tests/petnames/petnames-transactions.spec.js +++ b/test/e2e/tests/petnames/petnames-transactions.spec.js @@ -8,7 +8,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); const { expectName, focusTestDapp, diff --git a/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js b/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js index c6e693d01ed3..5368c2617f13 100644 --- a/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js +++ b/test/e2e/tests/ppom/ppom-blockaid-alert-simple-send.spec.js @@ -1,6 +1,5 @@ const { strict: assert } = require('assert'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); const { defaultGanacheOptions, withFixtures, diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js index eaf791b4ebb9..958c1351d8b3 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-diff-network.spec.js @@ -11,7 +11,6 @@ const { largeDelayMs, tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on different networks', function () { describe('Old confirmation screens', function () { diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js index 4c4cb28976b5..066acacab23a 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-extra-tx.spec.js @@ -11,7 +11,6 @@ const { withFixtures, tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on different networks', function () { describe('Old confirmation flows', function () { diff --git a/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js b/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js index bd69656c3fc9..d3241c95c9d5 100644 --- a/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js +++ b/test/e2e/tests/request-queuing/batch-txs-per-dapp-same-network.spec.js @@ -12,7 +12,6 @@ const { largeDelayMs, tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on same networks', function () { describe('Old confirmation screens', function () { diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js index 9c1e874fc4cc..67efbfe6fee9 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js @@ -11,7 +11,6 @@ const { defaultGanacheOptions, tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing Dapp 1 Send Tx -> Dapp 2 Request Accounts Tx', function () { describe('Old confirmation screens', function () { diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js index e2e211fee301..24c09ee18d09 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js @@ -9,7 +9,6 @@ const { withFixtures, tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { describe('Old confirmation screens', function () { diff --git a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js index 56c244c484bb..3a413f147e06 100644 --- a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js +++ b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js @@ -9,7 +9,6 @@ const { defaultGanacheOptions, tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on different networks revokePermissions', function () { describe('Old confirmation screens', function () { diff --git a/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js b/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js index 04845b28828b..f831ff1ff38d 100644 --- a/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js +++ b/test/e2e/tests/request-queuing/multiple-networks-dapps-txs.spec.js @@ -10,7 +10,6 @@ const { largeDelayMs, tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -const { PAGES } = require('../../webdriver/driver'); describe('Request Queuing for Multiple Dapps and Txs on different networks.', function () { describe('Old confirmation screens', function () { diff --git a/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js b/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js index 78d92dff5999..c1ff9f3477ab 100644 --- a/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js +++ b/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js @@ -9,7 +9,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); describe('MetaMask Responsive UI', function () { it('Creating a new wallet @no-mmi', async function () { diff --git a/test/e2e/tests/settings/4byte-directory.spec.js b/test/e2e/tests/settings/4byte-directory.spec.js index ff14ddda2432..b36f72f0575c 100644 --- a/test/e2e/tests/settings/4byte-directory.spec.js +++ b/test/e2e/tests/settings/4byte-directory.spec.js @@ -9,7 +9,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); -const { PAGES } = require('../../webdriver/driver'); describe('4byte setting', function () { it('makes a call to 4byte when the setting is on', async function () { diff --git a/test/e2e/tests/settings/show-hex-data.spec.js b/test/e2e/tests/settings/show-hex-data.spec.js index bbd60c3275e7..353847a544b4 100644 --- a/test/e2e/tests/settings/show-hex-data.spec.js +++ b/test/e2e/tests/settings/show-hex-data.spec.js @@ -5,7 +5,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); const selectors = { accountOptionsMenu: '[data-testid="account-options-menu-button"]', diff --git a/test/e2e/tests/tokens/custom-token-add-approve.spec.js b/test/e2e/tests/tokens/custom-token-add-approve.spec.js index 390e69cf3e77..9226ad1a36f1 100644 --- a/test/e2e/tests/tokens/custom-token-add-approve.spec.js +++ b/test/e2e/tests/tokens/custom-token-add-approve.spec.js @@ -1,5 +1,4 @@ const { strict: assert } = require('assert'); -const { PAGES } = require('../../webdriver/driver'); const { clickNestedButton, defaultGanacheOptions, diff --git a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js index 1dd71ea5853a..0c5498a82cca 100644 --- a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js +++ b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js @@ -13,7 +13,6 @@ const { } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); -const { PAGES } = require('../../webdriver/driver'); const recipientAddress = '0x2f318C334780961FB129D2a6c30D0763d9a5C970'; diff --git a/test/e2e/tests/tokens/increase-token-allowance.spec.js b/test/e2e/tests/tokens/increase-token-allowance.spec.js index ef2ba6af37cb..9ce8db2cc065 100644 --- a/test/e2e/tests/tokens/increase-token-allowance.spec.js +++ b/test/e2e/tests/tokens/increase-token-allowance.spec.js @@ -13,7 +13,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); -const { PAGES } = require('../../webdriver/driver'); const DEFAULT_TEST_DAPP_INCREASE_ALLOWANCE_SPENDING_CAP = '1'; diff --git a/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js b/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js index 473c765669c8..388247bb3fcd 100644 --- a/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js +++ b/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js @@ -12,7 +12,6 @@ const { } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); -const { PAGES } = require('../../../webdriver/driver'); describe('ERC1155 NFTs testdapp interaction', function () { const smartContract = SMART_CONTRACTS.ERC1155; diff --git a/test/e2e/tests/tokens/nft/erc721-interaction.spec.js b/test/e2e/tests/tokens/nft/erc721-interaction.spec.js index d1bf8174cb5b..8b634ffc3ce3 100644 --- a/test/e2e/tests/tokens/nft/erc721-interaction.spec.js +++ b/test/e2e/tests/tokens/nft/erc721-interaction.spec.js @@ -10,7 +10,6 @@ const { } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); -const { PAGES } = require('../../../webdriver/driver'); describe('ERC721 NFTs testdapp interaction', function () { const smartContract = SMART_CONTRACTS.NFTS; diff --git a/test/e2e/tests/tokens/nft/send-nft.spec.js b/test/e2e/tests/tokens/nft/send-nft.spec.js index 6aeece064c1e..13cb310f1416 100644 --- a/test/e2e/tests/tokens/nft/send-nft.spec.js +++ b/test/e2e/tests/tokens/nft/send-nft.spec.js @@ -8,7 +8,6 @@ const { } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); -const { PAGES } = require('../../../webdriver/driver'); describe('Send NFT', function () { const smartContract = SMART_CONTRACTS.NFTS; diff --git a/test/e2e/tests/transaction/change-assets.spec.js b/test/e2e/tests/transaction/change-assets.spec.js index d8c095259ac4..f6a997c164e9 100644 --- a/test/e2e/tests/transaction/change-assets.spec.js +++ b/test/e2e/tests/transaction/change-assets.spec.js @@ -7,7 +7,6 @@ const { } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); -const { PAGES } = require('../../webdriver/driver'); const { tEn } = require('../../../lib/i18n-helpers'); describe('Change assets', function () { diff --git a/test/e2e/tests/transaction/edit-gas-fee.spec.js b/test/e2e/tests/transaction/edit-gas-fee.spec.js index 6e3bfb8f6c82..3e7655750594 100644 --- a/test/e2e/tests/transaction/edit-gas-fee.spec.js +++ b/test/e2e/tests/transaction/edit-gas-fee.spec.js @@ -3,7 +3,6 @@ const { createInternalTransaction, createDappTransaction, } = require('../../page-objects/flows/transaction'); -const { PAGES } = require('../../webdriver/driver'); const { withFixtures, diff --git a/test/e2e/tests/transaction/gas-estimates.spec.js b/test/e2e/tests/transaction/gas-estimates.spec.js index 1335c954d76e..f12275ad4d9f 100644 --- a/test/e2e/tests/transaction/gas-estimates.spec.js +++ b/test/e2e/tests/transaction/gas-estimates.spec.js @@ -6,7 +6,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); const { CHAIN_IDS } = require('../../../../shared/constants/network'); const { GAS_API_BASE_URL } = require('../../../../shared/constants/swaps'); diff --git a/test/e2e/tests/transaction/multiple-transactions.spec.js b/test/e2e/tests/transaction/multiple-transactions.spec.js index 351a2d35f2b6..b7ad05b3a93d 100644 --- a/test/e2e/tests/transaction/multiple-transactions.spec.js +++ b/test/e2e/tests/transaction/multiple-transactions.spec.js @@ -9,7 +9,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); describe('Multiple transactions', function () { it('creates multiple queued transactions, then confirms', async function () { diff --git a/test/e2e/tests/transaction/navigate-transactions.spec.js b/test/e2e/tests/transaction/navigate-transactions.spec.js index cf90a2b814f5..16e8f9374cb5 100644 --- a/test/e2e/tests/transaction/navigate-transactions.spec.js +++ b/test/e2e/tests/transaction/navigate-transactions.spec.js @@ -4,7 +4,6 @@ const { const { default: ConfirmationNavigation, } = require('../../page-objects/pages/confirmations/legacy/navigation'); -const { PAGES } = require('../../webdriver/driver'); const { withFixtures, diff --git a/test/e2e/tests/transaction/send-edit.spec.js b/test/e2e/tests/transaction/send-edit.spec.js index 030b9ab4467e..8d19d6d071b1 100644 --- a/test/e2e/tests/transaction/send-edit.spec.js +++ b/test/e2e/tests/transaction/send-edit.spec.js @@ -2,7 +2,6 @@ const { strict: assert } = require('assert'); const { createInternalTransaction, } = require('../../page-objects/flows/transaction'); -const { PAGES } = require('../../webdriver/driver'); const { defaultGanacheOptions, diff --git a/test/e2e/tests/transaction/send-eth.spec.js b/test/e2e/tests/transaction/send-eth.spec.js index bfe9a4144ea5..9ee1b58dc170 100644 --- a/test/e2e/tests/transaction/send-eth.spec.js +++ b/test/e2e/tests/transaction/send-eth.spec.js @@ -12,7 +12,6 @@ const { tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); describe('Send ETH', function () { describe('from inside MetaMask', function () { diff --git a/test/e2e/tests/transaction/send-hex-address.spec.js b/test/e2e/tests/transaction/send-hex-address.spec.js index b6639ea50930..b6ad969c6735 100644 --- a/test/e2e/tests/transaction/send-hex-address.spec.js +++ b/test/e2e/tests/transaction/send-hex-address.spec.js @@ -7,7 +7,6 @@ const { } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); -const { PAGES } = require('../../webdriver/driver'); const hexPrefixedAddress = '0x2f318C334780961FB129D2a6c30D0763d9a5C970'; const nonHexPrefixedAddress = hexPrefixedAddress.substring(2); diff --git a/test/e2e/tests/transaction/simple-send.spec.ts b/test/e2e/tests/transaction/simple-send.spec.ts index 5e89b7c5f781..7d2f4835cdca 100644 --- a/test/e2e/tests/transaction/simple-send.spec.ts +++ b/test/e2e/tests/transaction/simple-send.spec.ts @@ -1,5 +1,5 @@ import { Suite } from 'mocha'; -import { Driver, PAGES } from '../../webdriver/driver'; +import { Driver } from '../../webdriver/driver'; import { Ganache } from '../../seeder/ganache'; import { withFixtures, From 7b198b9354ab880b9fa9f205429d998e40841dfb Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Mon, 25 Nov 2024 14:58:08 +0000 Subject: [PATCH 19/19] Add comment on accounts tests --- test/e2e/tests/account/snap-account-transfers.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/e2e/tests/account/snap-account-transfers.spec.ts b/test/e2e/tests/account/snap-account-transfers.spec.ts index e38a65c89738..af2a61a62a39 100644 --- a/test/e2e/tests/account/snap-account-transfers.spec.ts +++ b/test/e2e/tests/account/snap-account-transfers.spec.ts @@ -22,6 +22,8 @@ import { } from '../../page-objects/flows/send-transaction.flow'; describe('Snap Account Transfers @no-mmi', function (this: Suite) { + // TODO: Remove the old confirmations screen tests once migration has been complete. + // See: https://github.com/MetaMask/MetaMask-planning/issues/3030 describe('Old confirmation screens', function () { it('can import a private key and transfer 1 ETH (sync flow)', async function () { await withFixtures(