1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Fix gas price intermittent test failure (#8728)

The "the transaction has the expected gas price" test was assuming the
fifth element with the `transaction-breakdown__value` class was the
element with the gas price. In practice that was sometimes not the
case, because some transaction detail fields would not be present, or
would appear after the first render.

The field is now looked up with a test id, ensuring it always finds the
correct field.
This commit is contained in:
Mark Stacey 2020-06-03 10:54:55 -03:00 committed by GitHub
parent 56b157f692
commit 171704d980
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -472,10 +472,8 @@ describe('MetaMask', function () {
const txValue = await driver.findClickableElement(By.css('.transaction-list-item__primary-currency'))
await txValue.click()
const popoverCloseButton = await driver.findClickableElement(By.css('.popover-header__button'))
const txGasPrices = await driver.findElements(By.css('.transaction-breakdown__value'))
const txGasPriceLabels = await driver.findElements(By.css('.transaction-breakdown-row__title'))
await driver.wait(until.elementTextMatches(txGasPrices[4], /^10$/), 10000)
assert(txGasPriceLabels[2])
const txGasPrice = await driver.findElement(By.css('[data-testid="transaction-breakdown__gas-price"]'))
await driver.wait(until.elementTextMatches(txGasPrice, /^10$/), 10000)
await popoverCloseButton.click()
})
})

View File

@ -85,6 +85,7 @@ export default class TransactionBreakdown extends PureComponent {
? (
<CurrencyDisplay
className="transaction-breakdown__value"
data-testid="transaction-breakdown__gas-price"
currency={nativeCurrency}
denomination={GWEI}
value={gasPrice}

View File

@ -7,6 +7,7 @@ import { useCurrencyDisplay } from '../../../hooks/useCurrencyDisplay'
export default function CurrencyDisplay ({
value,
displayValue,
'data-testid': dataTestId,
style,
className,
prefix,
@ -30,6 +31,7 @@ export default function CurrencyDisplay ({
return (
<div
className={classnames('currency-display-component', className)}
data-testid={dataTestId}
style={style}
title={(!hideTitle && title) || null}
>
@ -49,6 +51,7 @@ export default function CurrencyDisplay ({
CurrencyDisplay.propTypes = {
className: PropTypes.string,
currency: PropTypes.string,
'data-testid': PropTypes.string,
denomination: PropTypes.oneOf([GWEI]),
displayValue: PropTypes.string,
hideLabel: PropTypes.bool,