2022-01-19 19:34:43 +01:00
|
|
|
const { strict: assert } = require('assert');
|
|
|
|
const {
|
|
|
|
convertToHexValue,
|
|
|
|
getWindowHandles,
|
|
|
|
withFixtures,
|
2023-05-05 15:56:08 +02:00
|
|
|
openDapp,
|
2022-01-19 19:34:43 +01:00
|
|
|
} = require('../helpers');
|
2022-10-28 10:42:12 +02:00
|
|
|
const FixtureBuilder = require('../fixture-builder');
|
2022-01-19 19:34:43 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
describe('Editing Confirm Transaction', function () {
|
|
|
|
it('allows selecting high, medium, low gas estimates on edit gas fee popover', async function () {
|
|
|
|
const ganacheOptions = {
|
|
|
|
hardfork: 'london',
|
|
|
|
accounts: [
|
2022-01-19 19:34:43 +01:00
|
|
|
{
|
2022-02-03 01:28:28 +01:00
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2022-01-19 19:34:43 +01:00
|
|
|
},
|
2022-02-03 01:28:28 +01:00
|
|
|
],
|
|
|
|
};
|
|
|
|
await withFixtures(
|
|
|
|
{
|
2022-10-28 10:42:12 +02:00
|
|
|
fixtures: new FixtureBuilder()
|
|
|
|
.withTransactionControllerTypeTwoTransaction()
|
|
|
|
.build(),
|
2022-02-03 01:28:28 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
const transactionAmounts = await driver.findElements(
|
|
|
|
'.currency-display-component__text',
|
|
|
|
);
|
|
|
|
const transactionAmount = transactionAmounts[0];
|
2022-10-28 10:42:12 +02:00
|
|
|
assert.equal(await transactionAmount.getText(), '1');
|
2022-02-03 01:28:28 +01:00
|
|
|
|
|
|
|
// update estimates to high
|
|
|
|
await driver.clickElement('[data-testid="edit-gas-fee-button"]');
|
2022-03-16 17:05:34 +01:00
|
|
|
await driver.waitForSelector({
|
|
|
|
text: 'sec',
|
|
|
|
tag: 'span',
|
|
|
|
});
|
2022-12-08 15:20:24 +01:00
|
|
|
await driver.clickElement(
|
|
|
|
'[data-testid="edit-gas-fee-item-high"] > span:first-child',
|
|
|
|
);
|
2022-02-03 01:28:28 +01:00
|
|
|
await driver.waitForSelector({ text: '🦍' });
|
|
|
|
await driver.waitForSelector({
|
|
|
|
text: 'Aggressive',
|
|
|
|
});
|
|
|
|
|
|
|
|
// update estimates to medium
|
|
|
|
await driver.clickElement('[data-testid="edit-gas-fee-button"]');
|
2022-12-08 15:20:24 +01:00
|
|
|
await driver.clickElement(
|
|
|
|
'[data-testid="edit-gas-fee-item-medium"] > span:first-child',
|
|
|
|
);
|
2022-02-03 01:28:28 +01:00
|
|
|
await driver.waitForSelector({ text: '🦊' });
|
|
|
|
await driver.waitForSelector({
|
|
|
|
text: 'Market',
|
|
|
|
});
|
|
|
|
|
|
|
|
// update estimates to low
|
|
|
|
await driver.clickElement('[data-testid="edit-gas-fee-button"]');
|
2022-12-08 15:20:24 +01:00
|
|
|
await driver.clickElement(
|
|
|
|
'[data-testid="edit-gas-fee-item-low"] > span:first-child',
|
|
|
|
);
|
2022-02-03 01:28:28 +01:00
|
|
|
await driver.waitForSelector({ text: '🐢' });
|
|
|
|
await driver.waitForSelector({
|
|
|
|
text: 'Low',
|
|
|
|
});
|
|
|
|
await driver.waitForSelector('[data-testid="low-gas-fee-alert"]');
|
|
|
|
|
|
|
|
// 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 19:34:43 +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);
|
2022-10-28 10:42:12 +02:00
|
|
|
assert.ok(/-1\s*ETH/u.test(await txValues[0].getText()));
|
2022-02-03 01:28:28 +01:00
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('allows accessing advance gas fee popover from edit gas fee popover', async function () {
|
|
|
|
const ganacheOptions = {
|
|
|
|
hardfork: 'london',
|
|
|
|
accounts: [
|
2022-01-19 19:34:43 +01:00
|
|
|
{
|
2022-02-03 01:28:28 +01:00
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2022-01-19 19:34:43 +01:00
|
|
|
},
|
2022-02-03 01:28:28 +01:00
|
|
|
],
|
|
|
|
};
|
|
|
|
await withFixtures(
|
|
|
|
{
|
2022-10-28 10:42:12 +02:00
|
|
|
fixtures: new FixtureBuilder()
|
|
|
|
.withTransactionControllerTypeTwoTransaction()
|
|
|
|
.build(),
|
2022-02-03 01:28:28 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
const transactionAmounts = await driver.findElements(
|
|
|
|
'.currency-display-component__text',
|
|
|
|
);
|
|
|
|
const transactionAmount = transactionAmounts[0];
|
2022-10-28 10:42:12 +02:00
|
|
|
assert.equal(await transactionAmount.getText(), '1');
|
2022-02-03 01:28:28 +01:00
|
|
|
|
|
|
|
// update estimates to high
|
|
|
|
await driver.clickElement('[data-testid="edit-gas-fee-button"]');
|
2022-03-16 17:05:34 +01:00
|
|
|
await driver.waitForSelector({
|
|
|
|
text: 'sec',
|
|
|
|
tag: 'span',
|
|
|
|
});
|
2022-02-03 01:28:28 +01:00
|
|
|
await driver.clickElement('[data-testid="edit-gas-fee-item-custom"]');
|
|
|
|
|
|
|
|
// enter max fee
|
2022-10-25 04:55:31 +02:00
|
|
|
await driver.fill('[data-testid="base-fee-input"]', '8.5');
|
2022-02-03 01:28:28 +01:00
|
|
|
|
|
|
|
// enter priority fee
|
2022-10-25 04:55:31 +02:00
|
|
|
await driver.fill('[data-testid="priority-fee-input"]', '8.5');
|
2022-02-03 01:28:28 +01:00
|
|
|
|
|
|
|
// save default values
|
|
|
|
await driver.clickElement('input[type="checkbox"]');
|
|
|
|
|
|
|
|
// edit gas limit
|
|
|
|
await driver.clickElement('[data-testid="advanced-gas-fee-edit"]');
|
2022-05-05 19:51:57 +02:00
|
|
|
await driver.fill('[data-testid="gas-limit-input"]', '100000');
|
2022-02-03 01:28:28 +01:00
|
|
|
|
|
|
|
// Submit gas fee changes
|
|
|
|
await driver.clickElement({ text: 'Save', tag: 'button' });
|
|
|
|
|
|
|
|
// 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)',
|
2022-10-25 04:55:31 +02:00
|
|
|
text: '0.00085 ETH',
|
2022-05-05 19:51:57 +02:00
|
|
|
});
|
|
|
|
await driver.waitForSelector({
|
|
|
|
css: '.transaction-detail-item:nth-of-type(2) h6:nth-of-type(2)',
|
2022-10-28 10:42:12 +02:00
|
|
|
text: '1.00085 ETH',
|
2022-05-05 19:51:57 +02:00
|
|
|
});
|
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 19:34:43 +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);
|
2022-10-28 10:42:12 +02:00
|
|
|
assert.ok(/-1\s*ETH/u.test(await txValues[0].getText()));
|
2022-02-03 01:28:28 +01:00
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
2022-01-19 19:34:43 +01:00
|
|
|
|
2022-02-03 01:28:28 +01:00
|
|
|
it('should use dapp suggested estimates for transaction coming from dapp', async function () {
|
|
|
|
const ganacheOptions = {
|
|
|
|
hardfork: 'london',
|
|
|
|
accounts: [
|
2022-01-19 19:34:43 +01:00
|
|
|
{
|
2022-02-03 01:28:28 +01:00
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2022-01-19 19:34:43 +01:00
|
|
|
},
|
2022-02-03 01:28:28 +01:00
|
|
|
],
|
|
|
|
};
|
|
|
|
await withFixtures(
|
|
|
|
{
|
2022-10-28 10:42:12 +02:00
|
|
|
fixtures: new FixtureBuilder()
|
|
|
|
.withPermissionControllerConnectedToTestDapp()
|
|
|
|
.build(),
|
2022-02-03 01:28:28 +01:00
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
dapp: true,
|
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await driver.navigate();
|
|
|
|
|
|
|
|
// login to extension
|
|
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
|
|
|
|
// open dapp and connect
|
2023-05-05 15:56:08 +02:00
|
|
|
await openDapp(driver);
|
2022-02-09 14:57:05 +01:00
|
|
|
await driver.clickElement({
|
|
|
|
text: 'Send EIP 1559 Transaction',
|
|
|
|
tag: 'button',
|
|
|
|
});
|
2022-02-03 01:28:28 +01:00
|
|
|
|
|
|
|
// check transaction in extension popup
|
|
|
|
const windowHandles = await getWindowHandles(driver, 3);
|
|
|
|
await driver.switchToWindow(windowHandles.popup);
|
|
|
|
await driver.waitForSelector({ text: '🌐' });
|
|
|
|
await driver.waitForSelector({
|
|
|
|
text: 'Site suggested',
|
|
|
|
});
|
|
|
|
|
|
|
|
await driver.clickElement('[data-testid="edit-gas-fee-button"]');
|
2022-03-16 17:05:34 +01:00
|
|
|
await driver.waitForSelector({
|
|
|
|
text: 'sec',
|
|
|
|
tag: 'span',
|
|
|
|
});
|
2022-02-03 01:28:28 +01:00
|
|
|
await driver.clickElement(
|
|
|
|
'[data-testid="edit-gas-fee-item-dappSuggested"]',
|
|
|
|
);
|
|
|
|
|
|
|
|
const transactionAmounts = await driver.findElements(
|
|
|
|
'.currency-display-component__text',
|
|
|
|
);
|
|
|
|
const transactionAmount = transactionAmounts[0];
|
2022-02-09 14:57:05 +01:00
|
|
|
assert.equal(await transactionAmount.getText(), '0');
|
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];
|
2022-02-09 14:57:05 +01:00
|
|
|
assert.equal(await editedTransactionAmount.getText(), '0.00021');
|
2022-02-03 01:28:28 +01:00
|
|
|
|
|
|
|
const editedTransactionFee = editedTransactionAmounts[1];
|
2022-02-09 14:57:05 +01:00
|
|
|
assert.equal(await editedTransactionFee.getText(), '0.00021');
|
2022-02-03 01:28:28 +01:00
|
|
|
|
|
|
|
// confirms the transaction
|
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
|
|
|
|
|
|
// transaction should correct values in activity tab
|
|
|
|
await driver.switchToWindow(windowHandles.extension);
|
|
|
|
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 19:34:43 +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);
|
2022-02-09 14:57:05 +01:00
|
|
|
assert.ok(/-0\s*ETH/u.test(await txValues[0].getText()));
|
2022-02-03 01:28:28 +01:00
|
|
|
},
|
|
|
|
);
|
2022-01-19 19:34:43 +01:00
|
|
|
});
|
2022-02-03 01:28:28 +01:00
|
|
|
});
|