mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
[e2e] Refactor send-hex-address spec using Ganache seeder (#15604)
* Send Hex Address Ganache refactor * Added explanatory comment
This commit is contained in:
parent
0b9424acc1
commit
506d1e74e5
@ -1,5 +1,6 @@
|
|||||||
const { strict: assert } = require('assert');
|
const { strict: assert } = require('assert');
|
||||||
const { convertToHexValue, withFixtures } = require('../helpers');
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
||||||
|
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
|
||||||
|
|
||||||
const hexPrefixedAddress = '0x2f318C334780961FB129D2a6c30D0763d9a5C970';
|
const hexPrefixedAddress = '0x2f318C334780961FB129D2a6c30D0763d9a5C970';
|
||||||
const nonHexPrefixedAddress = hexPrefixedAddress.substring(2);
|
const nonHexPrefixedAddress = hexPrefixedAddress.substring(2);
|
||||||
@ -119,6 +120,7 @@ describe('Send ETH to a 40 character hexadecimal address', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Send ERC20 to a 40 character hexadecimal address', function () {
|
describe('Send ERC20 to a 40 character hexadecimal address', function () {
|
||||||
|
const smartContract = SMART_CONTRACTS.HST;
|
||||||
const ganacheOptions = {
|
const ganacheOptions = {
|
||||||
accounts: [
|
accounts: [
|
||||||
{
|
{
|
||||||
@ -134,39 +136,29 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () {
|
|||||||
dapp: true,
|
dapp: true,
|
||||||
fixtures: 'connected-state',
|
fixtures: 'connected-state',
|
||||||
ganacheOptions,
|
ganacheOptions,
|
||||||
|
smartContract,
|
||||||
title: this.test.title,
|
title: this.test.title,
|
||||||
failOnConsoleError: false,
|
failOnConsoleError: false,
|
||||||
},
|
},
|
||||||
async ({ driver }) => {
|
async ({ driver, contractRegistry }) => {
|
||||||
|
const contractAddress = await contractRegistry.getContractAddress(
|
||||||
|
smartContract,
|
||||||
|
);
|
||||||
await driver.navigate();
|
await driver.navigate();
|
||||||
await driver.fill('#password', 'correct horse battery staple');
|
await driver.fill('#password', 'correct horse battery staple');
|
||||||
await driver.press('#password', driver.Key.ENTER);
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
|
|
||||||
// Create TST
|
await driver.openNewPage(
|
||||||
await driver.openNewPage('http://127.0.0.1:8080/');
|
`http://127.0.0.1:8080/?contract=${contractAddress}`,
|
||||||
await driver.clickElement('#createToken');
|
);
|
||||||
await driver.waitUntilXWindowHandles(3);
|
|
||||||
let windowHandles = await driver.getAllWindowHandles();
|
let windowHandles = await driver.getAllWindowHandles();
|
||||||
const extension = windowHandles[0];
|
const extension = windowHandles[0];
|
||||||
const dapp = await driver.switchToWindowWithTitle(
|
|
||||||
'E2E Test Dapp',
|
// Using the line below to make wait time deterministic and avoid using a delay
|
||||||
windowHandles,
|
// See more here https://github.com/MetaMask/metamask-extension/pull/15604/files#r949300551
|
||||||
);
|
await driver.findClickableElement('#deployButton');
|
||||||
await driver.switchToWindowWithTitle(
|
|
||||||
'MetaMask Notification',
|
|
||||||
windowHandles,
|
|
||||||
);
|
|
||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
||||||
await driver.waitUntilXWindowHandles(2);
|
|
||||||
await driver.switchToWindow(extension);
|
|
||||||
await driver.clickElement('[data-testid="home__activity-tab"]');
|
|
||||||
await driver.waitForSelector(
|
|
||||||
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
|
||||||
{ timeout: 10000 },
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add token
|
// Add token
|
||||||
await driver.switchToWindow(dapp);
|
|
||||||
await driver.clickElement('#watchAsset');
|
await driver.clickElement('#watchAsset');
|
||||||
await driver.waitUntilXWindowHandles(3);
|
await driver.waitUntilXWindowHandles(3);
|
||||||
windowHandles = await driver.getAllWindowHandles();
|
windowHandles = await driver.getAllWindowHandles();
|
||||||
@ -209,7 +201,7 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () {
|
|||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
||||||
await driver.clickElement('[data-testid="home__activity-tab"]');
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
||||||
await driver.waitForSelector(
|
await driver.waitForSelector(
|
||||||
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(2)',
|
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
||||||
{ timeout: 10000 },
|
{ timeout: 10000 },
|
||||||
);
|
);
|
||||||
const sendTransactionListItem = await driver.waitForSelector(
|
const sendTransactionListItem = await driver.waitForSelector(
|
||||||
@ -233,39 +225,28 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () {
|
|||||||
dapp: true,
|
dapp: true,
|
||||||
fixtures: 'connected-state',
|
fixtures: 'connected-state',
|
||||||
ganacheOptions,
|
ganacheOptions,
|
||||||
|
smartContract,
|
||||||
title: this.test.title,
|
title: this.test.title,
|
||||||
failOnConsoleError: false,
|
failOnConsoleError: false,
|
||||||
},
|
},
|
||||||
async ({ driver }) => {
|
async ({ driver, contractRegistry }) => {
|
||||||
|
const contractAddress = await contractRegistry.getContractAddress(
|
||||||
|
smartContract,
|
||||||
|
);
|
||||||
await driver.navigate();
|
await driver.navigate();
|
||||||
await driver.fill('#password', 'correct horse battery staple');
|
await driver.fill('#password', 'correct horse battery staple');
|
||||||
await driver.press('#password', driver.Key.ENTER);
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
|
|
||||||
// Create TST
|
// Create TST
|
||||||
await driver.openNewPage('http://127.0.0.1:8080/');
|
await driver.openNewPage(
|
||||||
await driver.clickElement('#createToken');
|
`http://127.0.0.1:8080/?contract=${contractAddress}`,
|
||||||
await driver.waitUntilXWindowHandles(3);
|
|
||||||
let windowHandles = await driver.getAllWindowHandles();
|
|
||||||
const extension = windowHandles[0];
|
|
||||||
const dapp = await driver.switchToWindowWithTitle(
|
|
||||||
'E2E Test Dapp',
|
|
||||||
windowHandles,
|
|
||||||
);
|
|
||||||
await driver.switchToWindowWithTitle(
|
|
||||||
'MetaMask Notification',
|
|
||||||
windowHandles,
|
|
||||||
);
|
|
||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
||||||
await driver.waitUntilXWindowHandles(2);
|
|
||||||
await driver.switchToWindow(extension);
|
|
||||||
await driver.clickElement('[data-testid="home__activity-tab"]');
|
|
||||||
await driver.waitForSelector(
|
|
||||||
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
|
||||||
{ timeout: 10000 },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let windowHandles = await driver.getAllWindowHandles();
|
||||||
|
const extension = windowHandles[0];
|
||||||
|
|
||||||
// Add token
|
// Add token
|
||||||
await driver.switchToWindow(dapp);
|
await driver.findClickableElement('#deployButton');
|
||||||
await driver.clickElement('#watchAsset');
|
await driver.clickElement('#watchAsset');
|
||||||
await driver.waitUntilXWindowHandles(3);
|
await driver.waitUntilXWindowHandles(3);
|
||||||
windowHandles = await driver.getAllWindowHandles();
|
windowHandles = await driver.getAllWindowHandles();
|
||||||
@ -308,7 +289,7 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () {
|
|||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
||||||
await driver.clickElement('[data-testid="home__activity-tab"]');
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
||||||
await driver.waitForSelector(
|
await driver.waitForSelector(
|
||||||
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(2)',
|
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
||||||
{ timeout: 10000 },
|
{ timeout: 10000 },
|
||||||
);
|
);
|
||||||
const sendTransactionListItem = await driver.waitForSelector(
|
const sendTransactionListItem = await driver.waitForSelector(
|
||||||
|
Loading…
Reference in New Issue
Block a user