1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +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 = {
DAPP_URL,
DAPP_ONE_URL,
@ -573,6 +579,7 @@ module.exports = {
defaultGanacheOptions,
sendTransaction,
findAnotherAccountFromAccountList,
logInWithBalanceValidation,
assertAccountBalanceForDOM,
locateAccountBalanceDOM,
restartServiceWorker,

View File

@ -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',

View File

@ -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

View File

@ -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(

View File

@ -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"]');

View File

@ -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"]');

View File

@ -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,