1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

feature(19463): fix send-eth flaky test and refactor (#19531)

This commit is contained in:
Danica Shen 2023-06-09 15:01:12 +01:00 committed by GitHub
parent 8eff1fc1ff
commit 95d57b254f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 33 deletions

View File

@ -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 = { module.exports = {
DAPP_URL, DAPP_URL,
DAPP_ONE_URL, DAPP_ONE_URL,
@ -573,6 +579,7 @@ module.exports = {
defaultGanacheOptions, defaultGanacheOptions,
sendTransaction, sendTransaction,
findAnotherAccountFromAccountList, findAnotherAccountFromAccountList,
logInWithBalanceValidation,
assertAccountBalanceForDOM, assertAccountBalanceForDOM,
locateAccountBalanceDOM, locateAccountBalanceDOM,
restartServiceWorker, restartServiceWorker,

View File

@ -2,7 +2,7 @@ const { strict: assert } = require('assert');
const { const {
convertToHexValue, convertToHexValue,
withFixtures, withFixtures,
assertAccountBalanceForDOM, logInWithBalanceValidation,
} = require('../helpers'); } = require('../helpers');
const FixtureBuilder = require('../fixture-builder'); const FixtureBuilder = require('../fixture-builder');
@ -40,10 +40,8 @@ describe('Address Book', function () {
}, },
async ({ driver, ganacheServer }) => { async ({ driver, ganacheServer }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await logInWithBalanceValidation(driver, ganacheServer);
await driver.press('#password', driver.Key.ENTER);
await assertAccountBalanceForDOM(driver, ganacheServer);
await driver.clickElement('[data-testid="eth-overview-send"]'); await driver.clickElement('[data-testid="eth-overview-send"]');
const recipientRowTitle = await driver.findElement( const recipientRowTitle = await driver.findElement(
'.send__select-recipient-wrapper__group-item__title', '.send__select-recipient-wrapper__group-item__title',

View File

@ -203,7 +203,6 @@ describe('MetaMask Import UI', function () {
// enter private key // enter private key
await driver.findClickableElement('#private-key-box'); await driver.findClickableElement('#private-key-box');
await driver.fill('#private-key-box', testPrivateKey1); await driver.fill('#private-key-box', testPrivateKey1);
await driver.findClickableElement({ text: 'Import', tag: 'button' });
await driver.clickElement({ text: 'Import', tag: 'button' }); await driver.clickElement({ text: 'Import', tag: 'button' });
// should show the correct account name // should show the correct account name

View File

@ -2,7 +2,7 @@ const { strict: assert } = require('assert');
const { const {
convertToHexValue, convertToHexValue,
withFixtures, withFixtures,
assertAccountBalanceForDOM, logInWithBalanceValidation,
} = require('../helpers'); } = require('../helpers');
const FixtureBuilder = require('../fixture-builder'); const FixtureBuilder = require('../fixture-builder');
@ -68,10 +68,7 @@ describe('Gas API fallback', function () {
}, },
async ({ driver, ganacheServer }) => { async ({ driver, ganacheServer }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await logInWithBalanceValidation(driver, ganacheServer);
await driver.press('#password', driver.Key.ENTER);
await assertAccountBalanceForDOM(driver, ganacheServer);
await driver.clickElement('[data-testid="eth-overview-send"]'); await driver.clickElement('[data-testid="eth-overview-send"]');
await driver.fill( await driver.fill(

View File

@ -5,6 +5,7 @@ const {
withFixtures, withFixtures,
openDapp, openDapp,
assertAccountBalanceForDOM, assertAccountBalanceForDOM,
logInWithBalanceValidation,
} = require('../helpers'); } = require('../helpers');
const FixtureBuilder = require('../fixture-builder'); const FixtureBuilder = require('../fixture-builder');
@ -27,10 +28,7 @@ describe('Send ETH from inside MetaMask using default gas', function () {
}, },
async ({ driver, ganacheServer }) => { async ({ driver, ganacheServer }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await logInWithBalanceValidation(driver, ganacheServer);
await driver.press('#password', driver.Key.ENTER);
await assertAccountBalanceForDOM(driver, ganacheServer);
await driver.clickElement('[data-testid="eth-overview-send"]'); 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 }) => { async ({ driver, ganacheServer }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await logInWithBalanceValidation(driver, ganacheServer);
await driver.press('#password', driver.Key.ENTER);
await assertAccountBalanceForDOM(driver, ganacheServer);
await driver.clickElement('[data-testid="eth-overview-send"]'); await driver.clickElement('[data-testid="eth-overview-send"]');

View File

@ -2,7 +2,7 @@ const { strict: assert } = require('assert');
const { const {
convertToHexValue, convertToHexValue,
withFixtures, withFixtures,
assertAccountBalanceForDOM, logInWithBalanceValidation,
} = require('../helpers'); } = require('../helpers');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts'); const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
const FixtureBuilder = require('../fixture-builder'); const FixtureBuilder = require('../fixture-builder');
@ -28,10 +28,9 @@ describe('Send ETH to a 40 character hexadecimal address', function () {
title: this.test.title, title: this.test.title,
failOnConsoleError: false, failOnConsoleError: false,
}, },
async ({ driver }) => { async ({ driver, ganacheServer }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await logInWithBalanceValidation(driver, ganacheServer);
await driver.press('#password', driver.Key.ENTER);
// Send ETH // Send ETH
await driver.clickElement('[data-testid="eth-overview-send"]'); 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 }) => { async ({ driver, ganacheServer }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await logInWithBalanceValidation(driver, ganacheServer);
await driver.press('#password', driver.Key.ENTER);
await assertAccountBalanceForDOM(driver, ganacheServer);
// Send TST // Send TST
await driver.clickElement('[data-testid="home__asset-tab"]'); 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 }) => { async ({ driver, ganacheServer }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await logInWithBalanceValidation(driver, ganacheServer);
await driver.press('#password', driver.Key.ENTER);
await assertAccountBalanceForDOM(driver, ganacheServer);
// Send TST // Send TST
await driver.clickElement('[data-testid="home__asset-tab"]'); await driver.clickElement('[data-testid="home__asset-tab"]');

View File

@ -2,7 +2,7 @@ const {
convertToHexValue, convertToHexValue,
withFixtures, withFixtures,
sendTransaction, sendTransaction,
assertAccountBalanceForDOM, logInWithBalanceValidation,
} = require('../helpers'); } = require('../helpers');
const FixtureBuilder = require('../fixture-builder'); const FixtureBuilder = require('../fixture-builder');
@ -25,9 +25,7 @@ describe('Simple send', function () {
}, },
async ({ driver, ganacheServer }) => { async ({ driver, ganacheServer }) => {
await driver.navigate(); await driver.navigate();
await driver.fill('#password', 'correct horse battery staple'); await logInWithBalanceValidation(driver, ganacheServer);
await driver.press('#password', driver.Key.ENTER);
await assertAccountBalanceForDOM(driver, ganacheServer);
await sendTransaction( await sendTransaction(
driver, driver,