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: Zach Pomerantz <zzmp@uniswap.org>

* Update cypress/e2e/swap/errors.test.ts

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>

---------

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
This commit is contained in:
Jack Short 2023-11-08 13:27:10 -05:00 committed by GitHub
parent ebfcd8fbbe
commit 418ee08b00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

@ -1,4 +1,5 @@
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' }}>