mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
c54f9b3097
* Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * This is a combination of 76 commits. normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> enforce that only the properties for the specific methid can be updated via the method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more parameters to updateSwapTransaction approvalTxId estimatedBaseFee Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas fees in edit-gas-popover. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove dup;icated method from rebase. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> unrelated change Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Force re-run workflow Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> UpdateTransaction should be renamed to updateGasFees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateGasFees in gas-modal-page-container. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> fix: update previous gas params update method add types to the jsdoc comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateTransactionGasFees should have been updatePreviousGasParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Previous gas fees can be updated for confirmed transactions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add updatePreviousGasParams to mocked functions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * we need to await the first dispatch before we call the second Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * update values to make tests pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * More changes to make e2e pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Need to wait a bit after save for changes to take effect. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove merge comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Await one dispatch before calling another Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * We don't need goHome anymore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Tests must use async...await syntax too since we have await in the useTranasctionFunction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add delay after button click for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait a moment after clicking save for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait after clicking save... Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Merge update transaction gas fees and transaction user settings Show loading indicator on edit gas popover Fix tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix JSDoc Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * updatePreviousGasParams should also return updated transaction meta. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
278 lines
9.4 KiB
JavaScript
278 lines
9.4 KiB
JavaScript
const { strict: assert } = require('assert');
|
|
const {
|
|
convertToHexValue,
|
|
withFixtures,
|
|
regularDelayMs,
|
|
} = require('../helpers');
|
|
|
|
describe('Send ETH from inside MetaMask using default gas', function () {
|
|
const ganacheOptions = {
|
|
accounts: [
|
|
{
|
|
secretKey:
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
balance: convertToHexValue(25000000000000000000),
|
|
},
|
|
],
|
|
};
|
|
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);
|
|
await driver.delay(regularDelayMs);
|
|
|
|
await driver.assertElementNotPresent('.send-v2__error-amount');
|
|
|
|
const amountMax = await driver.findClickableElement(
|
|
'.send-v2__amount-max',
|
|
);
|
|
await amountMax.click();
|
|
|
|
let inputValue = await inputAmount.getProperty('value');
|
|
|
|
assert(Number(inputValue) > 24);
|
|
|
|
await amountMax.click();
|
|
|
|
assert.equal(await inputAmount.isEnabled(), true);
|
|
|
|
await inputAmount.fill('1');
|
|
|
|
inputValue = await inputAmount.getProperty('value');
|
|
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',
|
|
});
|
|
},
|
|
);
|
|
});
|
|
});
|
|
|
|
/* eslint-disable-next-line mocha/max-top-level-suites */
|
|
describe('Send ETH from inside MetaMask using advanced gas modal', function () {
|
|
const ganacheOptions = {
|
|
accounts: [
|
|
{
|
|
secretKey:
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
balance: convertToHexValue(25000000000000000000),
|
|
},
|
|
],
|
|
};
|
|
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');
|
|
|
|
const inputValue = await inputAmount.getProperty('value');
|
|
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 },
|
|
);
|
|
},
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('Send ETH from dapp using advanced gas controls', function () {
|
|
let windowHandles;
|
|
let extension;
|
|
let popup;
|
|
let dapp;
|
|
const ganacheOptions = {
|
|
accounts: [
|
|
{
|
|
secretKey:
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
balance: convertToHexValue(25000000000000000000),
|
|
},
|
|
],
|
|
};
|
|
|
|
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' });
|
|
await driver.clickElement({ text: 'Advanced', tag: 'div' });
|
|
await driver.clickElement(
|
|
'[data-testid="advanced-setting-show-testnet-conversion"] .settings-page__content-item-col > label > div',
|
|
);
|
|
const advancedGasTitle = await driver.findElement({
|
|
text: 'Advanced gas controls',
|
|
tag: 'span',
|
|
});
|
|
await driver.scrollToElement(advancedGasTitle);
|
|
await driver.clickElement(
|
|
'[data-testid="advanced-setting-advanced-gas-inline"] .settings-page__content-item-col > label > div',
|
|
);
|
|
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
|
|
await driver.clickElement({ text: 'Send', tag: 'button' });
|
|
await driver.delay(2000);
|
|
windowHandles = await driver.getAllWindowHandles();
|
|
await driver.switchToWindowWithTitle(
|
|
'MetaMask Notification',
|
|
windowHandles,
|
|
);
|
|
await driver.assertElementNotPresent({ text: 'Data', tag: 'li' });
|
|
await driver.clickElement({ text: 'Edit', tag: 'button' });
|
|
await driver.delay(1000);
|
|
await driver.clickElement(
|
|
{ text: 'Edit suggested gas fee', tag: 'button' },
|
|
10000,
|
|
);
|
|
await driver.delay(1000);
|
|
const inputs = await driver.findElements('input[type="number"]');
|
|
const gasPriceInput = inputs[1];
|
|
await gasPriceInput.fill('100');
|
|
await driver.delay(1000);
|
|
await driver.clickElement({ text: 'Save', tag: 'button' });
|
|
await driver.delay(1000);
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
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',
|
|
text: '-0 ETH',
|
|
});
|
|
|
|
// 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"]',
|
|
text: '100',
|
|
});
|
|
assert.equal(await gasPrice.getText(), '100');
|
|
},
|
|
);
|
|
});
|
|
});
|