2021-04-04 21:06:26 +02:00
|
|
|
const { strict: assert } = require('assert');
|
2022-05-05 19:51:57 +02:00
|
|
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
2021-04-04 21:06:26 +02:00
|
|
|
|
|
|
|
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(
|
|
|
|
{
|
2022-11-15 16:00:02 +01:00
|
|
|
fixtures: 'send-edit',
|
2021-04-04 21:06:26 +02:00
|
|
|
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' });
|
|
|
|
|
|
|
|
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');
|
|
|
|
await gasLimitInput.fill('100000');
|
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
|
2022-05-05 19:51:57 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.transaction-detail-item:nth-of-type(1) h6:nth-of-type(2)',
|
|
|
|
text: '0.0008 ETH',
|
|
|
|
});
|
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.transaction-detail-item:nth-of-type(2) h6:nth-of-type(2)',
|
|
|
|
text: '2.2008 ETH',
|
|
|
|
});
|
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
|
|
|
|
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(
|
|
|
|
{
|
2022-11-15 16:00:02 +01:00
|
|
|
fixtures: 'send-edit-v2',
|
2022-02-03 01:28:28 +01:00
|
|
|
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
|
|
|
// enter max fee
|
2022-05-05 19:51:57 +02:00
|
|
|
await driver.fill('[data-testid="base-fee-input"]', '8');
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// enter priority fee
|
2022-05-05 19:51:57 +02:00
|
|
|
await driver.fill('[data-testid="priority-fee-input"]', '8');
|
2022-01-19 00:08:41 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
// edit gas limit
|
2022-05-05 19:51:57 +02:00
|
|
|
await driver.clickElement('[data-testid="advanced-gas-fee-edit"]');
|
|
|
|
await driver.fill('[data-testid="gas-limit-input"]', '100000');
|
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"]');
|
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
|
2022-05-05 19:51:57 +02:00
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.transaction-detail-item:nth-of-type(1) h6:nth-of-type(2)',
|
|
|
|
text: '0.0008 ETH',
|
|
|
|
});
|
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.transaction-detail-item:nth-of-type(2) h6:nth-of-type(2)',
|
|
|
|
text: '2.2008 ETH',
|
|
|
|
});
|
2022-02-03 01:28:28 +01:00
|
|
|
|
|
|
|
// confirms the transaction
|
|
|
|
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',
|
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
|
|
|
});
|