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 { BigNumber } from '@ethersproject/bignumber'
import { InterfaceSectionName } from '@uniswap/analytics-events'
import { CurrencyAmount } from '@uniswap/sdk-core' import { CurrencyAmount } from '@uniswap/sdk-core'
import { DEFAULT_DEADLINE_FROM_NOW } from '../../../src/constants/misc' import { DEFAULT_DEADLINE_FROM_NOW } from '../../../src/constants/misc'
...@@ -117,7 +118,7 @@ describe('Swap errors', () => { ...@@ -117,7 +118,7 @@ describe('Swap errors', () => {
}) })
}) })
it('no liquidity', () => { it('insufficient liquidity', () => {
// The API response is too variable so stubbing a 404. // The API response is too variable so stubbing a 404.
cy.intercept('POST', 'https://api.uniswap.org/v2/quote', { cy.intercept('POST', 'https://api.uniswap.org/v2/quote', {
statusCode: 404, statusCode: 404,
...@@ -128,5 +129,6 @@ describe('Swap errors', () => { ...@@ -128,5 +129,6 @@ describe('Swap errors', () => {
cy.get('#swap-currency-output .token-amount-input').type('100000000000000').should('have.value', '100000000000000') // 100 trillion cy.get('#swap-currency-output .token-amount-input').type('100000000000000').should('have.value', '100000000000000') // 100 trillion
cy.contains('Insufficient liquidity for this trade.') cy.contains('Insufficient liquidity for this trade.')
cy.get('#swap-button').should('not.exist') 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)` ...@@ -18,9 +18,11 @@ const FiatLoadingBubble = styled(LoadingBubble)`
export function FiatValue({ export function FiatValue({
fiatValue, fiatValue,
priceImpact, priceImpact,
testId,
}: { }: {
fiatValue: { data?: number; isLoading: boolean } fiatValue: { data?: number; isLoading: boolean }
priceImpact?: Percent priceImpact?: Percent
testId?: string
}) { }) {
const { formatNumber, formatPercent } = useFormatter() const { formatNumber, formatPercent } = useFormatter()
...@@ -39,7 +41,7 @@ export function FiatValue({ ...@@ -39,7 +41,7 @@ export function FiatValue({
return ( return (
<Row gap="sm"> <Row gap="sm">
<ThemedText.BodySmall color="neutral2"> <ThemedText.BodySmall color="neutral2" data-testid={testId}>
{fiatValue.data ? ( {fiatValue.data ? (
formatNumber({ formatNumber({
input: fiatValue.data, input: fiatValue.data,
......
...@@ -382,7 +382,9 @@ const SwapCurrencyInputPanel = forwardRef<HTMLInputElement, SwapCurrencyInputPan ...@@ -382,7 +382,9 @@ const SwapCurrencyInputPanel = forwardRef<HTMLInputElement, SwapCurrencyInputPan
<FiatRow> <FiatRow>
<RowBetween> <RowBetween>
<LoadingOpacityContainer $loading={loading}> <LoadingOpacityContainer $loading={loading}>
{fiatValue && <FiatValue fiatValue={fiatValue} priceImpact={priceImpact} />} {fiatValue && (
<FiatValue fiatValue={fiatValue} priceImpact={priceImpact} testId={`fiat-value-${id}`} />
)}
</LoadingOpacityContainer> </LoadingOpacityContainer>
{account ? ( {account ? (
<RowFixed style={{ height: '16px' }}> <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