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

feature(19493): eliminate e2e flakyness for eth-sign (#19606)

This commit is contained in:
Danica Shen 2023-06-15 13:13:54 +01:00 committed by GitHub
parent 1fca9255c1
commit 74d365cbaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 31 deletions

View File

@ -546,9 +546,13 @@ async function waitForAccountRendered(driver) {
);
}
const logInWithBalanceValidation = async (driver, ganacheServer) => {
const login = async (driver) => {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
};
const logInWithBalanceValidation = async (driver, ganacheServer) => {
await login(driver);
await assertAccountBalanceForDOM(driver, ganacheServer);
};
@ -579,6 +583,7 @@ module.exports = {
defaultGanacheOptions,
sendTransaction,
findAnotherAccountFromAccountList,
login,
logInWithBalanceValidation,
assertAccountBalanceForDOM,
locateAccountBalanceDOM,

View File

@ -1,22 +1,13 @@
const { strict: assert } = require('assert');
const {
convertToHexValue,
withFixtures,
openDapp,
DAPP_URL,
login,
defaultGanacheOptions,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
const ganacheOptions = {
accounts: [
{
secretKey:
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
balance: convertToHexValue(25000000000000000000),
},
],
};
describe('Eth sign', function () {
it('will detect if eth_sign is disabled', async function () {
await withFixtures(
@ -25,13 +16,12 @@ describe('Eth sign', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions,
ganacheOptions: defaultGanacheOptions,
title: this.test.title,
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await login(driver);
await openDapp(driver);
await driver.clickElement('#ethSign');
@ -61,13 +51,12 @@ describe('Eth sign', function () {
})
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions,
ganacheOptions: defaultGanacheOptions,
title: this.test.title,
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await login(driver);
await openDapp(driver);
await driver.clickElement('#ethSign');
@ -80,18 +69,20 @@ describe('Eth sign', function () {
windowHandles,
);
const title = await driver.findElement(
'.request-signature__content__title',
);
const origin = await driver.findElement('.request-signature__origin');
assert.equal(await title.getText(), 'Signature request');
assert.equal(await origin.getText(), DAPP_URL);
await driver.findElement({
css: '.request-signature__content__title',
text: 'Signature request',
});
const personalMessageRow = await driver.findElement(
'.request-signature__row-value',
);
const personalMessage = await personalMessageRow.getText();
assert.equal(personalMessage, expectedPersonalMessage);
await driver.findElement({
css: '.request-signature__origin',
text: DAPP_URL,
});
await driver.findElement({
css: '.request-signature__row-value',
text: expectedPersonalMessage,
});
await driver.clickElement('[data-testid="page-container-footer-next"]');
await driver.clickElement(
@ -103,8 +94,10 @@ describe('Eth sign', function () {
await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles);
// Verify
const result = await driver.findElement('#ethSignResult');
assert.equal(await result.getText(), expectedEthSignResult);
await driver.findElement({
css: '#ethSignResult',
text: expectedEthSignResult,
});
},
);
});