diff --git a/app/scripts/migrations/132.test.ts b/app/scripts/migrations/132.test.ts new file mode 100644 index 000000000000..fb53f90a38fb --- /dev/null +++ b/app/scripts/migrations/132.test.ts @@ -0,0 +1,73 @@ +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('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: { + 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..ec12595d389a --- /dev/null +++ b/app/scripts/migrations/132.ts @@ -0,0 +1,58 @@ +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 { + if (!isObject(state?.PreferencesController)) { + return state; + } + + if (!isObject(state.PreferencesController?.preferences)) { + state.PreferencesController = { + ...state.PreferencesController, + preferences: {}, + }; + } + + const 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; +} 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; diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 19c9aeecd6c7..cc7173e87aa3 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -860,6 +860,46 @@ 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"]', + ); + + // Close settings page + await driver.clickElement( + '.settings-page__header__title-container__close-button', + ); +} + /** * Opens the account options menu safely, handling potential race conditions * with the MMI build. @@ -928,6 +968,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..6a8576b3f136 100644 --- a/test/e2e/json-rpc/switchEthereumChain.spec.js +++ b/test/e2e/json-rpc/switchEthereumChain.spec.js @@ -8,509 +8,669 @@ const { unlockWallet, switchToNotificationWindow, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); 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); + + // 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); - - // 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); - - // 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/page-objects/flows/send-transaction.flow.ts b/test/e2e/page-objects/flows/send-transaction.flow.ts index 3f56076e3934..8af88f01aca6 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,42 @@ 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. + */ +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 +169,38 @@ 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.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/snaps/test-snap-txinsights-v2.spec.js b/test/e2e/snaps/test-snap-txinsights-v2.spec.js index a249e9daa79b..ba2d468a870a 100644 --- a/test/e2e/snaps/test-snap-txinsights-v2.spec.js +++ b/test/e2e/snaps/test-snap-txinsights-v2.spec.js @@ -3,166 +3,172 @@ const { withFixtures, unlockWallet, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); 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); - - // 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); + + // 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', + }); + }, + ); + }); }); }); diff --git a/test/e2e/snaps/test-snap-txinsights.spec.js b/test/e2e/snaps/test-snap-txinsights.spec.js index 21feafd06cb9..0171759587b5 100644 --- a/test/e2e/snaps/test-snap-txinsights.spec.js +++ b/test/e2e/snaps/test-snap-txinsights.spec.js @@ -3,117 +3,229 @@ const { withFixtures, unlockWallet, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); 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); - - // 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); + + // 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/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'); }, ); diff --git a/test/e2e/tests/account/snap-account-transfers.spec.ts b/test/e2e/tests/account/snap-account-transfers.spec.ts index ee2466cf28e1..af2a61a62a39 100644 --- a/test/e2e/tests/account/snap-account-transfers.spec.ts +++ b/test/e2e/tests/account/snap-account-transfers.spec.ts @@ -2,6 +2,7 @@ import { Suite } from 'mocha'; import { multipleGanacheOptions, PRIVATE_KEY_TWO, + tempToggleSettingRedesignedTransactionConfirmations, WINDOW_TITLES, withFixtures, } from '../../helpers'; @@ -15,151 +16,311 @@ 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 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({ + // 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( + { + 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); + + 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({ + 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, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); - 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 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({ + await tempToggleSettingRedesignedTransactionConfirmations(driver); + + 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, - 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); + + 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 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, - 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); + 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, + 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(); + }, + ); + }); }); }); diff --git a/test/e2e/tests/confirmations/helpers.ts b/test/e2e/tests/confirmations/helpers.ts index 355f664ec61c..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. @@ -35,12 +35,6 @@ export function withRedesignConfirmationFixtures( metaMetricsId: 'fake-metrics-id', participateInMetaMetrics: true, }) - .withPreferencesController({ - preferences: { - redesignedConfirmationsEnabled: true, - isRedesignedConfirmationsDeveloperEnabled: true, - }, - }) .build(), ganacheOptions: transactionEnvelopeType === TransactionEnvelopeType.legacy 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) => { diff --git a/test/e2e/tests/dapp-interactions/contract-interactions.spec.js b/test/e2e/tests/dapp-interactions/contract-interactions.spec.js index e7de105e0112..a685954b5857 100644 --- a/test/e2e/tests/dapp-interactions/contract-interactions.spec.js +++ b/test/e2e/tests/dapp-interactions/contract-interactions.spec.js @@ -7,8 +7,8 @@ const { WINDOW_TITLES, locateAccountBalanceDOM, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); - const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); @@ -32,6 +32,8 @@ describe('Deploy contract and call contract methods', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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..ad168a2b9332 100644 --- a/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js +++ b/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js @@ -4,6 +4,7 @@ const { openDapp, WINDOW_TITLES, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); @@ -27,6 +28,8 @@ describe('Editing confirmations of dapp initiated contract interactions', functi ); await logInWithBalanceValidation(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // deploy contract await openDapp(driver, contractAddress); // wait for deployed contract, calls and confirms a contract method where ETH is sent @@ -59,6 +62,8 @@ describe('Editing confirmations of dapp initiated contract interactions', functi async ({ driver }) => { await logInWithBalanceValidation(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..c05938d668e0 100644 --- a/test/e2e/tests/dapp-interactions/failing-contract.spec.js +++ b/test/e2e/tests/dapp-interactions/failing-contract.spec.js @@ -6,6 +6,7 @@ const { WINDOW_TITLES, generateGanacheOptions, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); @@ -29,6 +30,8 @@ describe('Failing contract interaction ', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await openDapp(driver, contractAddress); let windowHandles = await driver.getAllWindowHandles(); const extension = windowHandles[0]; @@ -93,6 +96,8 @@ describe('Failing contract interaction on non-EIP1559 network', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..61842f482151 100644 --- a/test/e2e/tests/network/network-error.spec.js +++ b/test/e2e/tests/network/network-error.spec.js @@ -4,6 +4,7 @@ const { logInWithBalanceValidation, openActionMenuAndStartSendFlow, generateGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { GAS_API_BASE_URL } = require('../../../../shared/constants/swaps'); @@ -58,6 +59,8 @@ describe('Gas API fallback', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..55c295c51c3a 100644 --- a/test/e2e/tests/petnames/petnames-transactions.spec.js +++ b/test/e2e/tests/petnames/petnames-transactions.spec.js @@ -5,6 +5,7 @@ const { unlockWallet, defaultGanacheOptions, openActionMenuAndStartSendFlow, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { @@ -49,6 +50,9 @@ describe('Petnames - Transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await openDapp(driver); await createDappSendTransaction(driver); await switchToNotificationWindow(driver, 3); @@ -94,6 +98,8 @@ describe('Petnames - Transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..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,12 +1,12 @@ const { strict: assert } = require('assert'); const FixtureBuilder = require('../../fixture-builder'); - const { defaultGanacheOptions, withFixtures, sendScreenToConfirmScreen, logInWithBalanceValidation, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { mockMultiNetworkBalancePolling, @@ -209,6 +209,8 @@ describe('Simple Send Security Alert - Blockaid @no-mmi', function () { async ({ driver }) => { await logInWithBalanceValidation(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..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 @@ -9,129 +9,246 @@ const { WINDOW_TITLES, defaultGanacheOptions, largeDelayMs, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -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); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // 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 265b28d0f56d..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 @@ -9,169 +9,326 @@ const { unlockWallet, WINDOW_TITLES, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -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); - - // 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); + + // 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 c30d6a73c063..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 @@ -10,163 +10,317 @@ const { WINDOW_TITLES, defaultGanacheOptions, largeDelayMs, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -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); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // 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 5814d8a60a2b..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 @@ -10,148 +10,300 @@ 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 () { - 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); - - // 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', - }); - - 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' }); - }, - ); + async ({ driver }) => { + await unlockWallet(driver); + await tempToggleSettingRedesignedConfirmations(driver); + + // Navigate to extension home screen + await driver.navigate(PAGES.HOME); + + await tempToggleSettingRedesignedTransactionConfirmations(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: '[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 7a212533de4b..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 @@ -1,5 +1,4 @@ const { strict: assert } = require('assert'); - const FixtureBuilder = require('../../fixture-builder'); const { withFixtures, @@ -10,149 +9,247 @@ const { regularDelayMs, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); 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); - - // 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); + + // 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); - // 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); - // Dapp Send Button - await driver.clickElement('#sendButton'); + await driver.waitForSelector({ + text: 'Cancel', + tag: 'button', + }); - // Leave the confirmation pending + await driver.delay(regularDelayMs); - await openDapp(driver, undefined, DAPP_ONE_URL); + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); - const ethRequestAccounts = JSON.stringify({ - jsonrpc: '2.0', - method: 'eth_requestAccounts', - }); + // Leave the confirmation pending + await openDapp(driver, undefined, DAPP_ONE_URL); - const accounts = await driver.executeScript( - `return window.ethereum.request(${ethRequestAccounts})`, - ); + const accountsOnload = await ( + await driver.findElement('#accounts') + ).getText(); + assert.deepStrictEqual(accountsOnload, ''); - assert.deepStrictEqual(accounts, [ - '0x5cfe73b6021e818b776b421b1c4db2474086a7e1', - ]); - }, - ); + 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.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 c98e0eb229c6..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 @@ -7,304 +7,619 @@ const { unlockWallet, WINDOW_TITLES, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); 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); - // Open Dapp One - await openDapp(driver, undefined, DAPP_URL); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // 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); - await editButtons[1].click(); + const editButtons = await driver.findElements('[data-testid="edit"]'); - // Disconnect Localhost 8545 - await driver.clickElement({ - text: 'Localhost 8545', - tag: 'p', - }); + await editButtons[1].click(); - await driver.clickElement('[data-testid="connect-more-chains-button"]'); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + 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.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - // Network Selector - await driver.clickElement('[data-testid="network-display"]'); + // Check correct network on the send confirmation. + await driver.findElement({ + css: '[data-testid="network-display"]', + text: 'Localhost 8546', + }); - // Switch to second network - await driver.clickElement({ - text: 'Localhost 8546', - css: 'p', - }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Confirm', + tag: 'button', + }); - // 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); + // Switch back to the extension + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); - // Connect to dapp 2 - await driver.findClickableElement({ text: 'Connect', tag: 'button' }); - await driver.clickElement('#connectButton'); + await driver.clickElement( + '[data-testid="account-overview__activity-tab"]', + ); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // 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: 'Connect', - tag: 'button', - }); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.switchToWindowWithUrl(DAPP_URL); + // Open Dapp One + await openDapp(driver, undefined, DAPP_URL); - // switchEthereumChain request - const switchEthereumChainRequest = JSON.stringify({ - jsonrpc: '2.0', - method: 'wallet_switchEthereumChain', - params: [{ chainId: '0x539' }], - }); + // Connect to dapp + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - // Initiate switchEthereumChain on Dapp One - await driver.executeScript( - `window.ethereum.request(${switchEthereumChainRequest})`, - ); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.findElement({ - text: 'Use your enabled networks', - tag: 'p', - }); + await editButtons[1].click(); - await driver.switchToWindowWithUrl(DAPP_ONE_URL); + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); - await driver.clickElement('#sendButton'); + 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, + ); - await driver.clickElement({ text: 'Confirm', tag: 'button' }); + // Network Selector + await driver.clickElement('[data-testid="network-display"]'); - await driver.switchToWindowWithUrl(DAPP_ONE_URL); + // Switch to second network + await driver.clickElement({ + text: 'Localhost 8546', + css: 'p', + }); - // 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); + // 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.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // Connect to dapp 2 + await driver.findClickableElement({ text: 'Connect', tag: 'button' }); + await driver.clickElement('#connectButton'); - // 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', - }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); - // Switch back to the extension - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + await driver.switchToWindowWithUrl(DAPP_URL); - await driver.clickElement( - '[data-testid="account-overview__activity-tab"]', - ); + // switchEthereumChain request + const switchEthereumChainRequest = JSON.stringify({ + jsonrpc: '2.0', + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x539' }], + }); - // Check for transaction - await driver.wait(async () => { - const confirmedTxes = await driver.findElements( - '.transaction-list__completed-transactions .activity-list-item', + // Initiate switchEthereumChain on Dapp One + await driver.executeScript( + `window.ethereum.request(${switchEthereumChainRequest})`, ); - return confirmedTxes.length === 1; - }, 10000); - }, - ); + + 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); - // 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); - const editButtons = await driver.findElements('[data-testid="edit"]'); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await editButtons[1].click(); + const editButtons = await driver.findElements('[data-testid="edit"]'); - // Disconnect Localhost 8545 - await driver.clickElement({ - text: 'Localhost 8545', - tag: 'p', - }); + await editButtons[1].click(); - await driver.clickElement('[data-testid="connect-more-chains-button"]'); - await driver.clickElementAndWaitForWindowToClose({ - text: 'Connect', - tag: 'button', - }); + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + await driver.clickElement( + '[data-testid="connect-more-chains-button"]', + ); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); - // Network Selector - await driver.clickElement('[data-testid="network-display"]'); + 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', + }); - // 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})`, + ); - // 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.switchToWindowWithUrl(DAPP_ONE_URL); - await driver.clickElement('#sendButton'); + await driver.clickElement('#sendButton'); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.clickElement({ text: 'Cancel', tag: 'button' }); - 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: '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); + }, + ); + }); + + 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(); + + // 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.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: 'p', + 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); + }, + ); + }); }); }); 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..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 @@ -7,127 +7,247 @@ const { DAPP_ONE_URL, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -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); - - // 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); + + // 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 38fe1d7204d2..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 @@ -8,142 +8,277 @@ const { WINDOW_TITLES, defaultGanacheOptions, largeDelayMs, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); -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); - // Navigate to extension home screen - await driver.navigate(PAGES.HOME); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - // 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 5949800f9840..913bdf459a26 100644 --- a/test/e2e/tests/request-queuing/switch-network.spec.js +++ b/test/e2e/tests/request-queuing/switch-network.spec.js @@ -7,88 +7,178 @@ const { regularDelayMs, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); 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); - // Open dapp - await openDapp(driver, undefined, DAPP_URL); + await tempToggleSettingRedesignedTransactionConfirmations(driver); - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); + // Open dapp + await openDapp(driver, undefined, DAPP_URL); - // Network Selector - await driver.clickElement('[data-testid="network-display"]'); + 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', + }); - // Switch to second network - await driver.clickElement({ - text: 'Localhost 8546', - css: 'p', - }); + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); - await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + // Queue confirm tx should first auto switch network + await driver.clickElement('#sendButton'); - // 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"]', + ); - await driver.delay(regularDelayMs); + await driver.delay(regularDelayMs); - await driver.waitUntilXWindowHandles(3); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + // Switch back to the extension + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); + await driver.navigate(PAGES.HOME); - // Confirm Transaction - await driver.findClickableElement({ text: 'Confirm', tag: 'button' }); - await driver.clickElement('[data-testid="page-container-footer-next"]'); + // 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', + ); + return confirmedTxes.length === 1; + }, 10000); + }, + ); + }); + }); - // Switch back to the extension - await driver.switchToWindowWithTitle( - WINDOW_TITLES.ExtensionInFullScreenView, - ); - await driver.navigate(PAGES.HOME); + 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); - // Check correct network switched and on the correct network - await driver.findElement({ - css: '[data-testid="network-display"]', - text: 'Localhost 8545', - }); + // Open dapp + 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', + 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', + }); + + 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({ text: 'Confirm', tag: 'button' }); + + await driver.delay(regularDelayMs); + + // 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); + }, + ); + }); }); }); diff --git a/test/e2e/tests/request-queuing/ui.spec.js b/test/e2e/tests/request-queuing/ui.spec.js index b857d4307d5b..707c252396b7 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 { @@ -136,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', @@ -143,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' }); } @@ -190,573 +230,1036 @@ 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); - - // 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); + + // 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); - - // 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); + + // 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); - - // 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); + + // 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"]'); - 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, - }, - ], + 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); - - // 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); + + // Open the first dapp which starts on chain '0x539 + await openDappAndSwitchChain(driver, DAPP_URL, '0x539'); - 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 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); - - // 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); + + // 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); + + // 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); - - // 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, + }); + }, + ); + }); }); }); 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..c1ff9f3477ab 100644 --- a/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js +++ b/test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js @@ -6,6 +6,7 @@ const { logInWithBalanceValidation, openActionMenuAndStartSendFlow, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -21,6 +22,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 +131,8 @@ describe('MetaMask Responsive UI', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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..b36f72f0575c 100644 --- a/test/e2e/tests/settings/4byte-directory.spec.js +++ b/test/e2e/tests/settings/4byte-directory.spec.js @@ -6,6 +6,7 @@ const { unlockWallet, withFixtures, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); @@ -27,6 +28,8 @@ describe('4byte setting', function () { ); await logInWithBalanceValidation(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // deploy contract await openDapp(driver, contractAddress); @@ -63,6 +66,8 @@ describe('4byte setting', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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..353847a544b4 100644 --- a/test/e2e/tests/settings/show-hex-data.spec.js +++ b/test/e2e/tests/settings/show-hex-data.spec.js @@ -2,6 +2,7 @@ const { defaultGanacheOptions, withFixtures, logInWithBalanceValidation, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -78,6 +79,9 @@ describe('Check the toggle for hex data', function () { }, async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..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 { clickNestedButton, defaultGanacheOptions, @@ -8,6 +7,7 @@ const { openDapp, WINDOW_TITLES, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); @@ -84,6 +84,8 @@ describe('Create token, approve token and approve token without gas', function ( ); await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // create token await openDapp(driver, contractAddress); @@ -182,6 +184,8 @@ describe('Create token, approve token and approve token without gas', function ( ); await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // create token await openDapp(driver, contractAddress); @@ -317,6 +321,8 @@ describe('Create token, approve token and approve token without gas', function ( ); await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // create token await openDapp(driver, contractAddress); const windowHandles = await driver.getAllWindowHandles(); @@ -398,6 +404,8 @@ describe('Create token, approve token and approve token without gas', function ( ); await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..0c5498a82cca 100644 --- a/test/e2e/tests/tokens/custom-token-send-transfer.spec.js +++ b/test/e2e/tests/tokens/custom-token-send-transfer.spec.js @@ -8,6 +8,8 @@ const { editGasFeeForm, WINDOW_TITLES, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, + veryLargeDelayMs, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); @@ -28,6 +30,8 @@ describe('Transfer custom tokens @no-mmi', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // go to custom tokens view on extension, perform send tokens await driver.clickElement({ css: '[data-testid="multichain-token-list-item-value"]', @@ -115,10 +119,15 @@ describe('Transfer custom tokens @no-mmi', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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 @@ -174,8 +183,11 @@ describe('Transfer custom tokens @no-mmi', function () { ); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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/increase-token-allowance.spec.js b/test/e2e/tests/tokens/increase-token-allowance.spec.js index 7df956e9df43..9ce8db2cc065 100644 --- a/test/e2e/tests/tokens/increase-token-allowance.spec.js +++ b/test/e2e/tests/tokens/increase-token-allowance.spec.js @@ -10,6 +10,7 @@ const { ACCOUNT_2, WINDOW_TITLES, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); @@ -38,6 +39,8 @@ describe('Increase Token Allowance', function () { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..388247bb3fcd 100644 --- a/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js +++ b/test/e2e/tests/tokens/nft/erc1155-interaction.spec.js @@ -7,6 +7,8 @@ const { unlockWallet, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, + veryLargeDelayMs, } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); @@ -38,6 +40,8 @@ describe('ERC1155 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -118,6 +122,8 @@ describe('ERC1155 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await openDapp(driver, contract); await driver.fill('#batchTransferTokenIds', '1, 2, 3'); @@ -170,6 +176,8 @@ describe('ERC1155 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Create a set approval for all erc1155 token request in test dapp await openDapp(driver, contract); await driver.clickElement('#setApprovalForAllERC1155Button'); @@ -254,8 +262,13 @@ describe('ERC1155 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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 diff --git a/test/e2e/tests/tokens/nft/erc721-interaction.spec.js b/test/e2e/tests/tokens/nft/erc721-interaction.spec.js index 35750bae6d2c..8b634ffc3ce3 100644 --- a/test/e2e/tests/tokens/nft/erc721-interaction.spec.js +++ b/test/e2e/tests/tokens/nft/erc721-interaction.spec.js @@ -6,6 +6,7 @@ const { WINDOW_TITLES, defaultGanacheOptions, clickNestedButton, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); @@ -28,6 +29,8 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -91,6 +94,8 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -212,6 +217,8 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -310,6 +317,8 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -357,6 +366,8 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -424,6 +435,8 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Open Dapp and wait for deployed contract await openDapp(driver, contract); await driver.findClickableElement('#deployButton'); @@ -490,6 +503,8 @@ describe('ERC721 NFTs testdapp interaction', function () { const contract = contractRegistry.getContractAddress(smartContract); await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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..13cb310f1416 100644 --- a/test/e2e/tests/tokens/nft/send-nft.spec.js +++ b/test/e2e/tests/tokens/nft/send-nft.spec.js @@ -4,6 +4,7 @@ const { logInWithBalanceValidation, unlockWallet, withFixtures, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); @@ -24,6 +25,8 @@ describe('Send NFT', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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..f6a997c164e9 100644 --- a/test/e2e/tests/transaction/change-assets.spec.js +++ b/test/e2e/tests/transaction/change-assets.spec.js @@ -3,6 +3,7 @@ const { defaultGanacheOptions, withFixtures, logInWithBalanceValidation, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); @@ -22,6 +23,8 @@ describe('Change assets', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Wait for balance to load await driver.delay(500); @@ -100,6 +103,8 @@ describe('Change assets', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Click the Send button await driver.clickElement({ css: '[data-testid="multichain-token-list-button"] span', @@ -179,6 +184,8 @@ describe('Change assets', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Choose the nft await driver.clickElement('[data-testid="account-overview__nfts-tab"]'); await driver.clickElement('[data-testid="nft-default-image"]'); @@ -266,6 +273,8 @@ describe('Change assets', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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..3e7655750594 100644 --- a/test/e2e/tests/transaction/edit-gas-fee.spec.js +++ b/test/e2e/tests/transaction/edit-gas-fee.spec.js @@ -9,6 +9,7 @@ const { unlockWallet, generateGanacheOptions, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -22,6 +23,9 @@ describe('Editing Confirm Transaction', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await createInternalTransaction(driver); await driver.findElement({ @@ -95,6 +99,9 @@ describe('Editing Confirm Transaction', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await createInternalTransaction(driver); await driver.findElement({ @@ -172,6 +179,8 @@ describe('Editing Confirm Transaction', function () { // login to extension await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..f12275ad4d9f 100644 --- a/test/e2e/tests/transaction/gas-estimates.spec.js +++ b/test/e2e/tests/transaction/gas-estimates.spec.js @@ -3,6 +3,7 @@ const { logInWithBalanceValidation, openActionMenuAndStartSendFlow, generateGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { CHAIN_IDS } = require('../../../../shared/constants/network'); @@ -27,6 +28,8 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await openActionMenuAndStartSendFlow(driver); await driver.fill( @@ -69,6 +72,8 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await openActionMenuAndStartSendFlow(driver); await driver.fill( @@ -108,6 +113,8 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await openActionMenuAndStartSendFlow(driver); await driver.fill( @@ -143,6 +150,8 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await openActionMenuAndStartSendFlow(driver); await driver.fill( 'input[placeholder="Enter public address (0x) or domain name"]', @@ -189,6 +198,8 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await openActionMenuAndStartSendFlow(driver); await driver.fill( 'input[placeholder="Enter public address (0x) or domain name"]', @@ -218,6 +229,8 @@ describe('Gas estimates generated by MetaMask', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..b7ad05b3a93d 100644 --- a/test/e2e/tests/transaction/multiple-transactions.spec.js +++ b/test/e2e/tests/transaction/multiple-transactions.spec.js @@ -6,6 +6,7 @@ const { unlockWallet, generateGanacheOptions, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -23,6 +24,8 @@ describe('Multiple transactions', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // initiates a transaction from the dapp await openDapp(driver); // creates first transaction @@ -85,6 +88,8 @@ describe('Multiple transactions', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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..16e8f9374cb5 100644 --- a/test/e2e/tests/transaction/navigate-transactions.spec.js +++ b/test/e2e/tests/transaction/navigate-transactions.spec.js @@ -1,7 +1,6 @@ const { createDappTransaction, } = require('../../page-objects/flows/transaction'); - const { default: ConfirmationNavigation, } = require('../../page-objects/pages/confirmations/legacy/navigation'); @@ -13,6 +12,7 @@ const { unlockWallet, generateGanacheOptions, WINDOW_TITLES, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -32,6 +32,9 @@ describe('Navigate transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await createMultipleTransactions(driver, TRANSACTION_COUNT); const navigation = new ConfirmationNavigation(driver); @@ -73,6 +76,9 @@ describe('Navigate transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await createMultipleTransactions(driver, TRANSACTION_COUNT); const navigation = new ConfirmationNavigation(driver); @@ -107,6 +113,9 @@ describe('Navigate transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await createMultipleTransactions(driver, TRANSACTION_COUNT); // reject transaction @@ -131,6 +140,9 @@ describe('Navigate transactions', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await createMultipleTransactions(driver, TRANSACTION_COUNT); // confirm transaction @@ -155,6 +167,9 @@ describe('Navigate transactions', function () { }, async ({ driver, ganacheServer }) => { await unlockWallet(driver); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..8d19d6d071b1 100644 --- a/test/e2e/tests/transaction/send-edit.spec.js +++ b/test/e2e/tests/transaction/send-edit.spec.js @@ -8,6 +8,7 @@ const { withFixtures, unlockWallet, generateGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -21,6 +22,7 @@ describe('Editing Confirm Transaction', function () { }, async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); await createInternalTransaction(driver); await driver.findElement({ @@ -96,6 +98,8 @@ describe('Editing Confirm Transaction', function () { }, async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..9ee1b58dc170 100644 --- a/test/e2e/tests/transaction/send-eth.spec.js +++ b/test/e2e/tests/transaction/send-eth.spec.js @@ -9,6 +9,7 @@ const { editGasFeeForm, WINDOW_TITLES, defaultGanacheOptions, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -106,6 +107,8 @@ describe('Send ETH', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + await driver.delay(1000); await openActionMenuAndStartSendFlow(driver); @@ -256,6 +259,8 @@ describe('Send ETH', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // initiates a send from the dapp await openDapp(driver); await driver.clickElement({ text: 'Send', tag: 'button' }); @@ -332,6 +337,8 @@ describe('Send ETH', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // initiates a transaction from the dapp await openDapp(driver); await driver.clickElement({ text: 'Create Token', tag: 'button' }); @@ -435,6 +442,8 @@ describe('Send ETH', function () { async ({ driver }) => { await unlockWallet(driver); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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..b6ad969c6735 100644 --- a/test/e2e/tests/transaction/send-hex-address.spec.js +++ b/test/e2e/tests/transaction/send-hex-address.spec.js @@ -3,6 +3,7 @@ const { withFixtures, logInWithBalanceValidation, openActionMenuAndStartSendFlow, + tempToggleSettingRedesignedTransactionConfirmations, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const FixtureBuilder = require('../../fixture-builder'); @@ -120,6 +121,8 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // Send TST await driver.clickElement( '[data-testid="account-overview__asset-tab"]', @@ -181,6 +184,9 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { }, async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + // 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..7d2f4835cdca 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 { 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,9 @@ describe('Simple send eth', function (this: Suite) { ganacheServer?: Ganache; }) => { await loginWithBalanceValidation(driver, ganacheServer); + + await tempToggleSettingRedesignedTransactionConfirmations(driver); + 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'),