2021-04-04 21:06:26 +02:00
|
|
|
const { strict: assert } = require('assert');
|
|
|
|
const {
|
2022-01-19 00:08:41 +01:00
|
|
|
convertToHexValue,
|
2021-04-04 21:06:26 +02:00
|
|
|
withFixtures,
|
|
|
|
tinyDelayMs,
|
|
|
|
regularDelayMs,
|
|
|
|
largeDelayMs,
|
|
|
|
} = require('../helpers');
|
|
|
|
|
|
|
|
describe('Editing Confirm Transaction', function () {
|
|
|
|
it('goes back from confirm page to edit eth value, gas price and gas limit', async function () {
|
|
|
|
const ganacheOptions = {
|
|
|
|
accounts: [
|
|
|
|
{
|
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
2022-01-19 00:08:41 +01:00
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2021-04-04 21:06:26 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
await withFixtures(
|
|
|
|
{
|
|
|
|
fixtures: 'send-edit',
|
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
2022-02-03 01:28:28 +01:00
|
|
|
failOnConsoleError: false,
|
2021-04-04 21:06:26 +02:00
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await driver.navigate();
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
|
|
await driver.press('#password', driver.Key.ENTER);
|
2021-04-04 21:06:26 +02:00
|
|
|
|
|
|
|
const transactionAmounts = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.currency-display-component__text',
|
2021-04-04 21:06:26 +02:00
|
|
|
);
|
|
|
|
const transactionAmount = transactionAmounts[0];
|
|
|
|
assert.equal(await transactionAmount.getText(), '1');
|
|
|
|
|
|
|
|
const transactionFee = transactionAmounts[1];
|
|
|
|
assert.equal(await transactionFee.getText(), '0.00025');
|
|
|
|
|
|
|
|
await driver.clickElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.confirm-page-container-header__back-button',
|
2021-04-04 21:06:26 +02:00
|
|
|
);
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill('.unit-input__input', '2.2');
|
2021-04-04 21:06:26 +02:00
|
|
|
|
2021-08-03 01:53:13 +02:00
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
|
|
|
|
2021-04-04 21:06:26 +02:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
|
2021-08-03 01:53:13 +02:00
|
|
|
await driver.clickElement({ text: 'Edit', tag: 'button' });
|
2021-04-04 21:06:26 +02:00
|
|
|
|
2021-08-03 01:53:13 +02:00
|
|
|
const [gasLimitInput, gasPriceInput] = await driver.findElements(
|
|
|
|
'input[type="number"]',
|
2021-04-04 21:06:26 +02:00
|
|
|
);
|
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await gasPriceInput.fill('8');
|
2021-04-04 21:06:26 +02:00
|
|
|
await driver.delay(tinyDelayMs);
|
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await gasLimitInput.fill('100000');
|
2021-04-04 21:06:26 +02:00
|
|
|
await driver.delay(largeDelayMs);
|
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Save', tag: 'button' });
|
2021-04-04 21:06:26 +02:00
|
|
|
|
|
|
|
// has correct updated value on the confirm screen the transaction
|
|
|
|
const editedTransactionAmounts = await driver.findElements(
|
2021-11-22 18:19:29 +01:00
|
|
|
'.transaction-detail-item__row .transaction-detail-item__detail-values .currency-display-component__text:last-of-type',
|
2021-04-04 21:06:26 +02:00
|
|
|
);
|
|
|
|
const editedTransactionAmount = editedTransactionAmounts[0];
|
2021-08-03 01:53:13 +02:00
|
|
|
assert.equal(await editedTransactionAmount.getText(), '0.0008');
|
2021-04-04 21:06:26 +02:00
|
|
|
|
|
|
|
const editedTransactionFee = editedTransactionAmounts[1];
|
2021-08-03 01:53:13 +02:00
|
|
|
assert.equal(await editedTransactionFee.getText(), '2.2008');
|
2021-04-04 21:06:26 +02:00
|
|
|
|
|
|
|
// confirms the transaction
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-04-04 21:06:26 +02:00
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
2021-04-04 21:06:26 +02:00
|
|
|
await driver.wait(async () => {
|
|
|
|
const confirmedTxes = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.transaction-list__completed-transactions .transaction-list-item',
|
2021-04-04 21:06:26 +02:00
|
|
|
);
|
|
|
|
return confirmedTxes.length === 1;
|
|
|
|
}, 10000);
|
|
|
|
|
|
|
|
const txValues = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.transaction-list-item__primary-currency',
|
2021-04-04 21:06:26 +02:00
|
|
|
);
|
|
|
|
assert.equal(txValues.length, 1);
|
|
|
|
assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText()));
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
it('goes back from confirm page to edit eth value, baseFee, priorityFee and gas limit - 1559 V2', async function () {
|
|
|
|
const ganacheOptions = {
|
|
|
|
hardfork: 'london',
|
|
|
|
accounts: [
|
2022-01-19 00:08:41 +01:00
|
|
|
{
|
2022-02-03 01:28:28 +01:00
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2022-01-19 00:08:41 +01:00
|
|
|
},
|
2022-02-03 01:28:28 +01:00
|
|
|
],
|
|
|
|
};
|
|
|
|
await withFixtures(
|
|
|
|
{
|
|
|
|
fixtures: 'send-edit-v2',
|
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
failOnConsoleError: false,
|
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await driver.navigate();
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
|
|
await driver.press('#password', driver.Key.ENTER);
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
const transactionAmounts = await driver.findElements(
|
|
|
|
'.currency-display-component__text',
|
|
|
|
);
|
|
|
|
const transactionAmount = transactionAmounts[0];
|
|
|
|
assert.equal(await transactionAmount.getText(), '1');
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
const transactionFee = transactionAmounts[1];
|
|
|
|
assert.equal(await transactionFee.getText(), '0.0000375');
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
await driver.clickElement(
|
|
|
|
'.confirm-page-container-header__back-button',
|
|
|
|
);
|
|
|
|
await driver.fill('.unit-input__input', '2.2');
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// open gas fee popover
|
|
|
|
await driver.clickElement({ text: 'Edit', tag: 'button' });
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// show gas limit
|
|
|
|
await driver.clickElement('[data-testid="advanced-gas-fee-edit"]');
|
|
|
|
await driver.delay(largeDelayMs);
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// enter max fee
|
|
|
|
const maxBaseFee = await driver.findElement(
|
|
|
|
'[data-testid="base-fee-input"]',
|
|
|
|
);
|
|
|
|
await maxBaseFee.clear();
|
|
|
|
await maxBaseFee.sendKeys('8');
|
|
|
|
await driver.delay(regularDelayMs);
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// enter priority fee
|
|
|
|
const priorityFee = await driver.findElement(
|
|
|
|
'[data-testid="priority-fee-input"]',
|
|
|
|
);
|
|
|
|
await priorityFee.clear();
|
|
|
|
await priorityFee.sendKeys('8');
|
|
|
|
await driver.delay(regularDelayMs);
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// edit gas limit
|
|
|
|
const gasLimit = await driver.findElement(
|
|
|
|
'[data-testid="gas-limit-input"]',
|
|
|
|
);
|
|
|
|
await gasLimit.clear();
|
|
|
|
await gasLimit.sendKeys('100000');
|
|
|
|
await driver.delay(regularDelayMs);
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// save default values
|
|
|
|
await driver.clickElement('input[type="checkbox"]');
|
|
|
|
await driver.delay(regularDelayMs);
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// Submit gas fee changes
|
|
|
|
await driver.clickElement({ text: 'Save', tag: 'button' });
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// has correct updated value on the confirm screen the transaction
|
|
|
|
const editedTransactionAmounts = await driver.findElements(
|
|
|
|
'.transaction-detail-item__row .transaction-detail-item__detail-values .currency-display-component__text:last-of-type',
|
|
|
|
);
|
|
|
|
const editedTransactionAmount = editedTransactionAmounts[0];
|
|
|
|
assert.equal(await editedTransactionAmount.getText(), '0.0008');
|
|
|
|
|
|
|
|
const editedTransactionFee = editedTransactionAmounts[1];
|
|
|
|
assert.equal(await editedTransactionFee.getText(), '2.2008');
|
|
|
|
|
|
|
|
// confirms the transaction
|
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
|
|
await driver.delay(regularDelayMs);
|
|
|
|
|
|
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
|
|
|
await driver.wait(async () => {
|
|
|
|
const confirmedTxes = await driver.findElements(
|
|
|
|
'.transaction-list__completed-transactions .transaction-list-item',
|
2022-01-19 00:08:41 +01:00
|
|
|
);
|
2022-02-03 01:28:28 +01:00
|
|
|
return confirmedTxes.length === 1;
|
|
|
|
}, 10000);
|
|
|
|
|
|
|
|
const txValues = await driver.findElements(
|
|
|
|
'.transaction-list-item__primary-currency',
|
|
|
|
);
|
|
|
|
assert.equal(txValues.length, 1);
|
|
|
|
assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText()));
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
2021-04-04 21:06:26 +02:00
|
|
|
});
|