2021-06-16 22:59:10 +02:00
|
|
|
const { strict: assert } = require('assert');
|
2022-01-19 00:08:41 +01:00
|
|
|
const {
|
|
|
|
convertToHexValue,
|
|
|
|
withFixtures,
|
|
|
|
regularDelayMs,
|
|
|
|
} = require('../helpers');
|
2021-06-16 22:59:10 +02:00
|
|
|
|
|
|
|
describe('Send ETH from inside MetaMask using default gas', function () {
|
|
|
|
const ganacheOptions = {
|
|
|
|
accounts: [
|
|
|
|
{
|
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
2022-01-19 00:08:41 +01:00
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2021-06-16 22:59:10 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
|
|
|
await withFixtures(
|
|
|
|
{
|
|
|
|
fixtures: 'imported-account',
|
|
|
|
ganacheOptions,
|
|
|
|
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 driver.clickElement('[data-testid="eth-overview-send"]');
|
|
|
|
|
|
|
|
await driver.fill(
|
|
|
|
'input[placeholder="Search, public address (0x), or ENS"]',
|
|
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
|
|
);
|
|
|
|
|
|
|
|
const inputAmount = await driver.findElement('.unit-input__input');
|
|
|
|
await inputAmount.fill('1000');
|
|
|
|
|
|
|
|
const errorAmount = await driver.findElement('.send-v2__error-amount');
|
|
|
|
assert.equal(
|
|
|
|
await errorAmount.getText(),
|
|
|
|
'Insufficient funds.',
|
|
|
|
'send screen should render an insufficient fund error message',
|
|
|
|
);
|
|
|
|
|
|
|
|
await inputAmount.press(driver.Key.BACK_SPACE);
|
|
|
|
await inputAmount.press(driver.Key.BACK_SPACE);
|
|
|
|
await inputAmount.press(driver.Key.BACK_SPACE);
|
2021-06-23 23:35:25 +02:00
|
|
|
await driver.delay(regularDelayMs);
|
2021-06-16 22:59:10 +02:00
|
|
|
|
|
|
|
await driver.assertElementNotPresent('.send-v2__error-amount');
|
|
|
|
|
|
|
|
const amountMax = await driver.findClickableElement(
|
|
|
|
'.send-v2__amount-max',
|
|
|
|
);
|
|
|
|
await amountMax.click();
|
|
|
|
|
2021-12-02 19:28:24 +01:00
|
|
|
let inputValue = await inputAmount.getProperty('value');
|
2021-06-16 22:59:10 +02:00
|
|
|
|
|
|
|
assert(Number(inputValue) > 24);
|
|
|
|
|
|
|
|
await amountMax.click();
|
|
|
|
|
|
|
|
assert.equal(await inputAmount.isEnabled(), true);
|
|
|
|
|
|
|
|
await inputAmount.fill('1');
|
|
|
|
|
2021-12-02 19:28:24 +01:00
|
|
|
inputValue = await inputAmount.getProperty('value');
|
2021-06-16 22:59:10 +02:00
|
|
|
assert.equal(inputValue, '1');
|
|
|
|
|
|
|
|
// Continue to next screen
|
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
|
|
|
|
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
|
|
|
|
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
|
|
|
await driver.wait(async () => {
|
|
|
|
const confirmedTxes = await driver.findElements(
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item',
|
|
|
|
);
|
|
|
|
return confirmedTxes.length === 1;
|
|
|
|
}, 10000);
|
|
|
|
|
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.transaction-list-item__primary-currency',
|
|
|
|
text: '-1 ETH',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
Refactor ESLint config (#13482)
We would like to insert TypeScript into the ESLint configuration, and
because of the way that the current config is organized, that is not
easy to do.
Most files are assumed to be files that are suited for running in a
browser context. This isn't correct, as we should expect most files to
work in a Node context instead. This is because all browser-based files
will be run through a transpiler that is able to make use of
Node-specific variables anyway.
There are a couple of important ways we can categories files which our
ESLint config should be capable of handling well:
* Is the file a script or a module? In other words, does the file run
procedurally or is the file intended to be brought into an existing
file?
* If the file is a module, does it use the CommonJS syntax (`require()`)
or does it use the ES syntax (`import`/`export`)?
When we introduce TypeScript, this set of questions will become:
* Is the file a script or a module?
* If the file is a module, is it a JavaScript module or a TypeScript
module?
* If the file is a JavaScript module, does it use the CommonJS syntax
(`require()`) or does it use the ES syntax (`import`/`export`)?
To represent these divisions, this commit removes global rules — so now
all of the rules are kept in `overrides` for explicitness — and sets up
rules for CommonJS- and ES-module-compatible files that intentionally do
not overlap with each other. This way TypeScript (which has its own set
of rules independent from JavaScript and therefore shouldn't overlap
with the other rules either) can be easily added later.
Finally, this commit splits up the ESLint config into separate files and
adds documentation to each section. This way sets of rules which are
connected to a particular plugin (`jsdoc`, `@babel`, etc.) can be easily
understood instead of being obscured.
2022-02-28 18:42:09 +01:00
|
|
|
/* eslint-disable-next-line mocha/max-top-level-suites */
|
2021-06-16 22:59:10 +02:00
|
|
|
describe('Send ETH from inside MetaMask using advanced gas modal', function () {
|
|
|
|
const ganacheOptions = {
|
|
|
|
accounts: [
|
|
|
|
{
|
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
2022-01-19 00:08:41 +01:00
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2021-06-16 22:59:10 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
|
|
|
await withFixtures(
|
|
|
|
{
|
|
|
|
fixtures: 'imported-account',
|
|
|
|
ganacheOptions,
|
|
|
|
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 driver.clickElement('[data-testid="eth-overview-send"]');
|
|
|
|
|
|
|
|
await driver.fill(
|
|
|
|
'input[placeholder="Search, public address (0x), or ENS"]',
|
|
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
|
|
);
|
|
|
|
|
|
|
|
const inputAmount = await driver.findElement('.unit-input__input');
|
|
|
|
await inputAmount.fill('1');
|
|
|
|
|
2021-12-02 19:28:24 +01:00
|
|
|
const inputValue = await inputAmount.getProperty('value');
|
2021-06-16 22:59:10 +02:00
|
|
|
assert.equal(inputValue, '1');
|
|
|
|
|
|
|
|
// Continue to next screen
|
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
|
|
|
|
|
|
|
const transactionAmounts = await driver.findElements(
|
|
|
|
'.currency-display-component__text',
|
|
|
|
);
|
|
|
|
const transactionAmount = transactionAmounts[0];
|
|
|
|
assert.equal(await transactionAmount.getText(), '1');
|
|
|
|
|
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
|
|
|
|
|
|
await driver.wait(async () => {
|
|
|
|
const confirmedTxes = await driver.findElements(
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item',
|
|
|
|
);
|
|
|
|
return confirmedTxes.length === 1;
|
|
|
|
}, 10000);
|
|
|
|
|
|
|
|
await driver.waitForSelector(
|
|
|
|
{
|
|
|
|
css: '.transaction-list-item__primary-currency',
|
|
|
|
text: '-1 ETH',
|
|
|
|
},
|
|
|
|
{ timeout: 10000 },
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-07-05 13:56:37 +02:00
|
|
|
|
|
|
|
describe('Send ETH from dapp using advanced gas controls', function () {
|
|
|
|
let windowHandles;
|
|
|
|
let extension;
|
|
|
|
let popup;
|
|
|
|
let dapp;
|
|
|
|
const ganacheOptions = {
|
|
|
|
accounts: [
|
|
|
|
{
|
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
2022-01-19 00:08:41 +01:00
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2021-07-05 13:56:37 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2021-07-31 03:29:21 +02:00
|
|
|
|
2021-07-05 13:56:37 +02:00
|
|
|
it('should display the correct gas price on the transaction', async function () {
|
|
|
|
await withFixtures(
|
|
|
|
{
|
|
|
|
dapp: true,
|
|
|
|
fixtures: 'imported-account',
|
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await driver.navigate();
|
|
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
|
|
|
|
// goes to the settings screen
|
|
|
|
await driver.clickElement('.account-menu__icon');
|
|
|
|
await driver.clickElement({ text: 'Settings', tag: 'div' });
|
2022-02-09 18:49:41 +01:00
|
|
|
await driver.clickElement({ text: 'Advanced', tag: 'div' });
|
2021-07-05 13:56:37 +02:00
|
|
|
await driver.clickElement(
|
2022-03-18 16:16:11 +01:00
|
|
|
'[data-testid="advanced-setting-show-testnet-conversion"] .settings-page__content-item-col > label > div',
|
2021-07-05 13:56:37 +02:00
|
|
|
);
|
|
|
|
const advancedGasTitle = await driver.findElement({
|
|
|
|
text: 'Advanced gas controls',
|
|
|
|
tag: 'span',
|
|
|
|
});
|
|
|
|
await driver.scrollToElement(advancedGasTitle);
|
|
|
|
await driver.clickElement(
|
2022-03-18 16:16:11 +01:00
|
|
|
'[data-testid="advanced-setting-advanced-gas-inline"] .settings-page__content-item-col > label > div',
|
2021-07-05 13:56:37 +02:00
|
|
|
);
|
|
|
|
windowHandles = await driver.getAllWindowHandles();
|
|
|
|
extension = windowHandles[0];
|
|
|
|
await driver.closeAllWindowHandlesExcept([extension]);
|
|
|
|
await driver.clickElement('.app-header__logo-container');
|
|
|
|
|
|
|
|
// connects the dapp
|
|
|
|
await driver.openNewPage('http://127.0.0.1:8080/');
|
|
|
|
await driver.clickElement({ text: 'Connect', tag: 'button' });
|
|
|
|
await driver.waitUntilXWindowHandles(3);
|
|
|
|
windowHandles = await driver.getAllWindowHandles();
|
|
|
|
extension = windowHandles[0];
|
|
|
|
dapp = await driver.switchToWindowWithTitle(
|
|
|
|
'E2E Test Dapp',
|
|
|
|
windowHandles,
|
|
|
|
);
|
|
|
|
popup = windowHandles.find(
|
|
|
|
(handle) => handle !== extension && handle !== dapp,
|
|
|
|
);
|
|
|
|
await driver.switchToWindow(popup);
|
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
|
|
|
await driver.clickElement({ text: 'Connect', tag: 'button' });
|
|
|
|
await driver.waitUntilXWindowHandles(2);
|
|
|
|
await driver.switchToWindow(dapp);
|
|
|
|
|
|
|
|
// initiates a send from the dapp
|
2022-02-04 16:39:48 +01:00
|
|
|
await driver.clickElement({ text: 'Send', tag: 'button' });
|
2021-07-05 13:56:37 +02:00
|
|
|
await driver.delay(2000);
|
|
|
|
windowHandles = await driver.getAllWindowHandles();
|
|
|
|
await driver.switchToWindowWithTitle(
|
|
|
|
'MetaMask Notification',
|
|
|
|
windowHandles,
|
|
|
|
);
|
|
|
|
await driver.assertElementNotPresent({ text: 'Data', tag: 'li' });
|
2021-07-31 03:29:21 +02:00
|
|
|
await driver.clickElement({ text: 'Edit', tag: 'button' });
|
|
|
|
await driver.delay(1000);
|
|
|
|
await driver.clickElement(
|
|
|
|
{ text: 'Edit suggested gas fee', tag: 'button' },
|
|
|
|
10000,
|
2021-07-05 13:56:37 +02:00
|
|
|
);
|
|
|
|
await driver.delay(1000);
|
2021-07-31 03:29:21 +02:00
|
|
|
const inputs = await driver.findElements('input[type="number"]');
|
|
|
|
const gasPriceInput = inputs[1];
|
|
|
|
await gasPriceInput.fill('100');
|
|
|
|
await driver.delay(1000);
|
2022-02-04 16:39:48 +01:00
|
|
|
await driver.clickElement({ text: 'Save', tag: 'button' });
|
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-07-05 13:56:37 +02:00
|
|
|
await driver.waitUntilXWindowHandles(2);
|
|
|
|
await driver.switchToWindow(extension);
|
|
|
|
|
|
|
|
// finds the transaction in the transactions list
|
|
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
|
|
|
await driver.waitForSelector(
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
|
|
|
{ timeout: 10000 },
|
|
|
|
);
|
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.transaction-list-item__primary-currency',
|
2022-02-09 14:57:05 +01:00
|
|
|
text: '-0 ETH',
|
2021-07-05 13:56:37 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// the transaction has the expected gas price
|
|
|
|
const txValue = await driver.findClickableElement(
|
|
|
|
'.transaction-list-item__primary-currency',
|
|
|
|
);
|
|
|
|
await txValue.click();
|
|
|
|
const gasPrice = await driver.waitForSelector({
|
|
|
|
css: '[data-testid="transaction-breakdown__gas-price"]',
|
2021-07-31 03:29:21 +02:00
|
|
|
text: '100',
|
2021-07-05 13:56:37 +02:00
|
|
|
});
|
2021-07-31 03:29:21 +02:00
|
|
|
assert.equal(await gasPrice.getText(), '100');
|
2021-07-05 13:56:37 +02:00
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|