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:
parent
ebfcd8fbbe
commit
418ee08b00
@ -1,4 +1,5 @@
|
|||||||
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', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
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', () => {
|
|||||||
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)`
|
|||||||
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({
|
|||||||
|
|
||||||
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
|
|||||||
<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' }}>
|
||||||
|
Loading…
Reference in New Issue
Block a user