diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 7b5fe2d24..d7a1d8096 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -546,6 +546,12 @@ async function waitForAccountRendered(driver) { ); } +const logInWithBalanceValidation = async (driver, ganacheServer) => { + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); + await assertAccountBalanceForDOM(driver, ganacheServer); +}; + module.exports = { DAPP_URL, DAPP_ONE_URL, @@ -573,6 +579,7 @@ module.exports = { defaultGanacheOptions, sendTransaction, findAnotherAccountFromAccountList, + logInWithBalanceValidation, assertAccountBalanceForDOM, locateAccountBalanceDOM, restartServiceWorker, diff --git a/test/e2e/tests/address-book.spec.js b/test/e2e/tests/address-book.spec.js index 42302b1cb..d730a4fc9 100644 --- a/test/e2e/tests/address-book.spec.js +++ b/test/e2e/tests/address-book.spec.js @@ -2,7 +2,7 @@ const { strict: assert } = require('assert'); const { convertToHexValue, withFixtures, - assertAccountBalanceForDOM, + logInWithBalanceValidation, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); @@ -40,10 +40,8 @@ describe('Address Book', function () { }, async ({ driver, ganacheServer }) => { await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); + await logInWithBalanceValidation(driver, ganacheServer); - await assertAccountBalanceForDOM(driver, ganacheServer); await driver.clickElement('[data-testid="eth-overview-send"]'); const recipientRowTitle = await driver.findElement( '.send__select-recipient-wrapper__group-item__title', diff --git a/test/e2e/tests/from-import-ui.spec.js b/test/e2e/tests/from-import-ui.spec.js index d8fed0d2b..ed6066a0d 100644 --- a/test/e2e/tests/from-import-ui.spec.js +++ b/test/e2e/tests/from-import-ui.spec.js @@ -203,7 +203,6 @@ describe('MetaMask Import UI', function () { // enter private key await driver.findClickableElement('#private-key-box'); await driver.fill('#private-key-box', testPrivateKey1); - await driver.findClickableElement({ text: 'Import', tag: 'button' }); await driver.clickElement({ text: 'Import', tag: 'button' }); // should show the correct account name diff --git a/test/e2e/tests/network-error.spec.js b/test/e2e/tests/network-error.spec.js index f59ff81b6..7a67b814b 100644 --- a/test/e2e/tests/network-error.spec.js +++ b/test/e2e/tests/network-error.spec.js @@ -2,7 +2,7 @@ const { strict: assert } = require('assert'); const { convertToHexValue, withFixtures, - assertAccountBalanceForDOM, + logInWithBalanceValidation, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); @@ -68,10 +68,7 @@ describe('Gas API fallback', function () { }, async ({ driver, ganacheServer }) => { await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); - - await assertAccountBalanceForDOM(driver, ganacheServer); + await logInWithBalanceValidation(driver, ganacheServer); await driver.clickElement('[data-testid="eth-overview-send"]'); await driver.fill( diff --git a/test/e2e/tests/send-eth.spec.js b/test/e2e/tests/send-eth.spec.js index d765be880..81a330085 100644 --- a/test/e2e/tests/send-eth.spec.js +++ b/test/e2e/tests/send-eth.spec.js @@ -5,6 +5,7 @@ const { withFixtures, openDapp, assertAccountBalanceForDOM, + logInWithBalanceValidation, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); @@ -27,10 +28,7 @@ describe('Send ETH from inside MetaMask using default gas', function () { }, async ({ driver, ganacheServer }) => { await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); - - await assertAccountBalanceForDOM(driver, ganacheServer); + await logInWithBalanceValidation(driver, ganacheServer); await driver.clickElement('[data-testid="eth-overview-send"]'); @@ -120,10 +118,7 @@ describe('Send ETH non-contract address with data that matches ERC20 transfer da }, async ({ driver, ganacheServer }) => { await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); - - await assertAccountBalanceForDOM(driver, ganacheServer); + await logInWithBalanceValidation(driver, ganacheServer); await driver.clickElement('[data-testid="eth-overview-send"]'); diff --git a/test/e2e/tests/send-hex-address.spec.js b/test/e2e/tests/send-hex-address.spec.js index 44007b4f1..f4f3c22b5 100644 --- a/test/e2e/tests/send-hex-address.spec.js +++ b/test/e2e/tests/send-hex-address.spec.js @@ -2,7 +2,7 @@ const { strict: assert } = require('assert'); const { convertToHexValue, withFixtures, - assertAccountBalanceForDOM, + logInWithBalanceValidation, } = require('../helpers'); const { SMART_CONTRACTS } = require('../seeder/smart-contracts'); const FixtureBuilder = require('../fixture-builder'); @@ -28,10 +28,9 @@ describe('Send ETH to a 40 character hexadecimal address', function () { title: this.test.title, failOnConsoleError: false, }, - async ({ driver }) => { + async ({ driver, ganacheServer }) => { await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); + await logInWithBalanceValidation(driver, ganacheServer); // Send ETH await driver.clickElement('[data-testid="eth-overview-send"]'); @@ -135,9 +134,7 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { }, async ({ driver, ganacheServer }) => { await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); - await assertAccountBalanceForDOM(driver, ganacheServer); + await logInWithBalanceValidation(driver, ganacheServer); // Send TST await driver.clickElement('[data-testid="home__asset-tab"]'); @@ -198,10 +195,7 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { }, async ({ driver, ganacheServer }) => { await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); - - await assertAccountBalanceForDOM(driver, ganacheServer); + await logInWithBalanceValidation(driver, ganacheServer); // Send TST await driver.clickElement('[data-testid="home__asset-tab"]'); diff --git a/test/e2e/tests/simple-send.spec.js b/test/e2e/tests/simple-send.spec.js index 9e6293b74..e8c582a2c 100644 --- a/test/e2e/tests/simple-send.spec.js +++ b/test/e2e/tests/simple-send.spec.js @@ -2,7 +2,7 @@ const { convertToHexValue, withFixtures, sendTransaction, - assertAccountBalanceForDOM, + logInWithBalanceValidation, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); @@ -25,9 +25,7 @@ describe('Simple send', function () { }, async ({ driver, ganacheServer }) => { await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); - await assertAccountBalanceForDOM(driver, ganacheServer); + await logInWithBalanceValidation(driver, ganacheServer); await sendTransaction( driver,