1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/test/e2e/tests/send-edit.spec.js

97 lines
3.3 KiB
JavaScript
Raw Normal View History

const { strict: assert } = require('assert');
const {
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',
balance: 25000000000000000000,
},
],
};
await withFixtures(
{
fixtures: 'send-edit',
ganacheOptions,
title: this.test.title,
},
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);
const transactionAmounts = await driver.findElements(
'.currency-display-component__text',
);
const transactionAmount = transactionAmounts[0];
assert.equal(await transactionAmount.getText(), '1');
const transactionFee = transactionAmounts[1];
assert.equal(await transactionFee.getText(), '0.00025');
await driver.clickElement(
'.confirm-page-container-header__back-button',
);
2021-04-12 17:32:38 +02:00
await driver.fill('.unit-input__input', '2.2');
await driver.clickElement('.advanced-gas-options-btn');
await driver.delay(regularDelayMs);
// wait for gas modal to be visible
const gasModal = await driver.findVisibleElement('span .modal');
const [gasPriceInput, gasLimitInput] = await driver.findElements(
'.advanced-gas-inputs__gas-edit-row__input',
);
2021-04-12 17:32:38 +02:00
await gasPriceInput.fill('8');
await driver.delay(tinyDelayMs);
2021-04-12 17:32:38 +02:00
await gasLimitInput.fill('100000');
await driver.delay(largeDelayMs);
await driver.clickElement({ text: 'Save', tag: 'button' });
// Wait for gas modal to be removed from DOM
await gasModal.waitForElementState('hidden');
await driver.clickElement({ text: 'Next', tag: 'button' });
// has correct updated value on the confirm screen the transaction
const editedTransactionAmounts = await driver.findElements(
'.currency-display-component__text',
);
const editedTransactionAmount = editedTransactionAmounts[0];
assert.equal(await editedTransactionAmount.getText(), '2.2');
const editedTransactionFee = editedTransactionAmounts[1];
assert.equal(await editedTransactionFee.getText(), '0.0008');
// 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',
);
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()));
},
);
});
});