Commit 418ee08b authored by Jack Short's avatar Jack Short Committed by GitHub

chore: adds e2e test for when usd quote fetch fails (#7215)

* chore: adds e2e test for when usd quote fetch fails

* Update src/components/CurrencyInputPanel/SwapCurrencyInputPanel.tsx
Co-authored-by: default avatarZach Pomerantz <zzmp@uniswap.org>

* Update cypress/e2e/swap/errors.test.ts
Co-authored-by: default avatarZach Pomerantz <zzmp@uniswap.org>

---------
Co-authored-by: default avatarZach Pomerantz <zzmp@uniswap.org>
parent ebfcd8fb
import { BigNumber } from '@ethersproject/bignumber'
import { InterfaceSectionName } from '@uniswap/analytics-events'
import { CurrencyAmount } from '@uniswap/sdk-core'
import { DEFAULT_DEADLINE_FROM_NOW } from '../../../src/constants/misc'
......@@ -117,7 +118,7 @@ describe('Swap errors', () => {
})
})
it('no liquidity', () => {
it('insufficient liquidity', () => {
// The API response is too variable so stubbing a 404.
cy.intercept('POST', 'https://api.uniswap.org/v2/quote', {
statusCode: 404,
......@@ -128,5 +129,6 @@ describe('Swap errors', () => {
cy.get('#swap-currency-output .token-amount-input').type('100000000000000').should('have.value', '100000000000000') // 100 trillion
cy.contains('Insufficient liquidity for this trade.')
cy.get('#swap-button').should('not.exist')
cy.get(getTestSelector(`fiat-value-${InterfaceSectionName.CURRENCY_OUTPUT_PANEL}`)).contains('-')
})
})
......@@ -18,9 +18,11 @@ const FiatLoadingBubble = styled(LoadingBubble)`
export function FiatValue({
fiatValue,
priceImpact,
testId,
}: {
fiatValue: { data?: number; isLoading: boolean }
priceImpact?: Percent
testId?: string
}) {
const { formatNumber, formatPercent } = useFormatter()
......@@ -39,7 +41,7 @@ export function FiatValue({
return (
<Row gap="sm">
<ThemedText.BodySmall color="neutral2">
<ThemedText.BodySmall color="neutral2" data-testid={testId}>
{fiatValue.data ? (
formatNumber({
input: fiatValue.data,
......
......@@ -382,7 +382,9 @@ const SwapCurrencyInputPanel = forwardRef<HTMLInputElement, SwapCurrencyInputPan
<FiatRow>
<RowBetween>
<LoadingOpacityContainer $loading={loading}>
{fiatValue && <FiatValue fiatValue={fiatValue} priceImpact={priceImpact} />}
{fiatValue && (
<FiatValue fiatValue={fiatValue} priceImpact={priceImpact} testId={`fiat-value-${id}`} />
)}
</LoadingOpacityContainer>
{account ? (
<RowFixed style={{ height: '16px' }}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment