diff --git a/test/e2e/metamask-ui.spec.js b/test/e2e/metamask-ui.spec.js index eed712736e1b..27699537546f 100644 --- a/test/e2e/metamask-ui.spec.js +++ b/test/e2e/metamask-ui.spec.js @@ -494,8 +494,6 @@ describe('MetaMask', function () { await delay(50) - await gasPriceInput.sendKeys(Key.BACK_SPACE) - await delay(50) await gasPriceInput.sendKeys(Key.BACK_SPACE) await delay(50) await gasPriceInput.sendKeys('10') @@ -504,9 +502,9 @@ describe('MetaMask', function () { await delay(50) await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a')) await delay(50) - await gasLimitInput.sendKeys('25000') - await delay(largeDelayMs * 2) + + await delay(1000) const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`), 10000) await confirmButton.click() @@ -792,14 +790,12 @@ describe('MetaMask', function () { await modalTabs[1].click() await delay(regularDelayMs) - const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) + const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-gas-inputs__gas-edit-row__input')) const gasLimitValue = await gasLimitInput.getAttribute('value') assert(Number(gasLimitValue) < 100000, 'Gas Limit too high') await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a')) await delay(50) - await gasPriceInput.sendKeys(Key.BACK_SPACE) - await delay(50) await gasPriceInput.sendKeys(Key.BACK_SPACE) await delay(50) await gasPriceInput.sendKeys('10') @@ -808,18 +804,9 @@ describe('MetaMask', function () { await delay(50) await gasLimitInput.sendKeys(Key.BACK_SPACE) await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) await gasLimitInput.sendKeys('60001') - await delay(50) - await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'e')) - await delay(50) + + await delay(1000) const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`)) await save.click() @@ -914,7 +901,7 @@ describe('MetaMask', function () { await advancedTabButton.click() await delay(tinyDelayMs) - const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) + const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-gas-inputs__gas-edit-row__input')) assert(gasPriceInput.getAttribute('value'), 20) assert(gasLimitInput.getAttribute('value'), 4700000) @@ -1103,12 +1090,10 @@ describe('MetaMask', function () { await modalTabs[1].click() await delay(regularDelayMs) - const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) + const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-gas-inputs__gas-edit-row__input')) await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a')) await delay(50) - await gasPriceInput.sendKeys(Key.BACK_SPACE) - await delay(50) await gasPriceInput.sendKeys(Key.BACK_SPACE) await delay(50) await gasPriceInput.sendKeys('10') @@ -1117,18 +1102,9 @@ describe('MetaMask', function () { await delay(50) await gasLimitInput.sendKeys(Key.BACK_SPACE) await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) await gasLimitInput.sendKeys('60000') - await delay(50) - await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'e')) - await delay(50) + + await delay(1000) const save = await findElement(driver, By.css('.page-container__footer-button')) await save.click() @@ -1246,12 +1222,10 @@ describe('MetaMask', function () { await modalTabs[1].click() await delay(regularDelayMs) - const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) + const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-gas-inputs__gas-edit-row__input')) await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a')) await delay(50) - await gasPriceInput.sendKeys(Key.BACK_SPACE) - await delay(50) await gasPriceInput.sendKeys(Key.BACK_SPACE) await delay(50) await gasPriceInput.sendKeys('10') @@ -1260,18 +1234,9 @@ describe('MetaMask', function () { await delay(50) await gasLimitInput.sendKeys(Key.BACK_SPACE) await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) - await gasLimitInput.sendKeys(Key.BACK_SPACE) - await delay(50) await gasLimitInput.sendKeys('60001') - await delay(50) - await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'e')) - await delay(50) + + await delay(1000) const save = await findElement(driver, By.css('.page-container__footer-button')) await save.click() diff --git a/test/e2e/send-edit.spec.js b/test/e2e/send-edit.spec.js index 3f12aaaf2c1b..039c14d9b369 100644 --- a/test/e2e/send-edit.spec.js +++ b/test/e2e/send-edit.spec.js @@ -113,7 +113,7 @@ describe('Using MetaMask with an existing account', function () { const gasModal = await driver.findElement(By.css('span .modal')) - const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) + const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-gas-inputs__gas-edit-row__input')) await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a')) await delay(50) @@ -131,6 +131,8 @@ describe('Using MetaMask with an existing account', function () { await gasLimitInput.sendKeys('25000') + await delay(1000) + const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`)) await save.click() await driver.wait(until.stalenessOf(gasModal)) @@ -170,7 +172,7 @@ describe('Using MetaMask with an existing account', function () { const gasModal = await driver.findElement(By.css('span .modal')) - const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) + const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-gas-inputs__gas-edit-row__input')) await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a')) await delay(50) @@ -187,6 +189,8 @@ describe('Using MetaMask with an existing account', function () { await gasLimitInput.sendKeys('100000') + await delay(1000) + const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`)) await save.click() await driver.wait(until.stalenessOf(gasModal)) diff --git a/ui/app/components/app/gas-customization/advanced-gas-inputs/advanced-gas-inputs.component.js b/ui/app/components/app/gas-customization/advanced-gas-inputs/advanced-gas-inputs.component.js index 7b87b3033960..51f3df74accb 100644 --- a/ui/app/components/app/gas-customization/advanced-gas-inputs/advanced-gas-inputs.component.js +++ b/ui/app/components/app/gas-customization/advanced-gas-inputs/advanced-gas-inputs.component.js @@ -3,22 +3,11 @@ import PropTypes from 'prop-types' import classnames from 'classnames' import debounce from 'lodash.debounce' -export default class AdvancedTabContent extends Component { +export default class AdvancedGasInputs extends Component { static contextTypes = { t: PropTypes.func, } - constructor (props) { - super(props) - this.state = { - gasPrice: this.props.customGasPrice, - gasLimit: this.props.customGasLimit, - } - this.changeGasPrice = debounce(this.changeGasPrice, 500) - this.changeGasLimit = debounce(this.changeGasLimit, 500) - } - - static propTypes = { updateCustomGasPrice: PropTypes.func, updateCustomGasLimit: PropTypes.func, @@ -31,6 +20,16 @@ export default class AdvancedTabContent extends Component { showGasLimitInfoModal: PropTypes.func, } + constructor (props) { + super(props) + this.state = { + gasPrice: this.props.customGasPrice, + gasLimit: this.props.customGasLimit, + } + this.changeGasPrice = debounce(this.changeGasPrice, 500) + this.changeGasLimit = debounce(this.changeGasLimit, 500) + } + componentDidUpdate (prevProps) { const { customGasPrice: prevCustomGasPrice, customGasLimit: prevCustomGasLimit } = prevProps const { customGasPrice, customGasLimit } = this.props @@ -50,12 +49,7 @@ export default class AdvancedTabContent extends Component { } changeGasLimit = (e) => { - if (e.target.value < 21000) { - this.setState({ gasLimit: 21000 }) - this.props.updateCustomGasLimit(21000) - } else { - this.props.updateCustomGasLimit(Number(e.target.value)) - } + this.props.updateCustomGasLimit(Number(e.target.value)) } onChangeGasPrice = (e) => { @@ -67,89 +61,83 @@ export default class AdvancedTabContent extends Component { this.props.updateCustomGasPrice(Number(e.target.value)) } - gasInputError ({ labelKey, insufficientBalance, customPriceIsSafe, isSpeedUp, value }) { + gasPriceError ({ insufficientBalance, customPriceIsSafe, isSpeedUp, gasPrice }) { const { t } = this.context - let errorText - let errorType - let isInError = true - if (insufficientBalance) { - errorText = t('insufficientBalance') - errorType = 'error' - } else if (labelKey === 'gasPrice' && isSpeedUp && value === 0) { - errorText = t('zeroGasPriceOnSpeedUpError') - errorType = 'error' - } else if (labelKey === 'gasPrice' && !customPriceIsSafe) { - errorText = t('gasPriceExtremelyLow') - errorType = 'warning' - } else { - isInError = false + return { + errorText: t('insufficientBalance'), + errorType: 'error', + } + } else if (isSpeedUp && gasPrice === 0) { + return { + errorText: t('zeroGasPriceOnSpeedUpError'), + errorType: 'error', + } + } else if (!customPriceIsSafe) { + return { + errorText: t('gasPriceExtremelyLow'), + errorType: 'warning', + } } - return { - isInError, - errorText, - errorType, - } + return {} } - gasInput ({ labelKey, value, onChange, insufficientBalance, customPriceIsSafe, isSpeedUp }) { - const { - isInError, - errorText, - errorType, - } = this.gasInputError({ labelKey, insufficientBalance, customPriceIsSafe, isSpeedUp, value }) + gasLimitError ({ insufficientBalance, gasLimit }) { + const { t } = this.context - return ( -