Commit 784fbfe7 authored by Kristie Huang's avatar Kristie Huang Committed by GitHub

test: add remove-liquidity interface tests (#7309)

* fix: duplicate or single-token remove-liquidity routes should show error page

* use maxUint256 for nonexistent pool

* move tests back to rem-liq

* rename pooled token id

* nit: use uni address from sdk core

* nit: use maxuint256 from sdk core

* nit: use liqudityValue for doublecurrencylogo

---------
Co-authored-by: default avatarKristie Huang <kristie.huang@uniswap.org>
parent f47d00be
import { ChainId, MaxUint256, UNI_ADDRESSES } from '@uniswap/sdk-core'
const UNI_MAINNET = UNI_ADDRESSES[ChainId.MAINNET]
describe('Remove Liquidity', () => { describe('Remove Liquidity', () => {
it('loads the token pair', () => { it('loads the token pair in v2', () => {
cy.visit('/remove/v2/ETH/0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984') cy.visit(`/remove/v2/ETH/${UNI_MAINNET}`)
cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'ETH') cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'ETH')
cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'UNI') cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'UNI')
}) })
it('loads the token pair in v3', () => {
cy.visit(`/remove/1`)
cy.get('#remove-liquidity-tokens').should('contain.text', 'UNI/ETH')
cy.get('#remove-pooled-tokena-symbol').should('contain.text', 'Pooled UNI')
cy.get('#remove-pooled-tokenb-symbol').should('contain.text', 'Pooled ETH')
})
it('should redirect to error pages if pool does not exist', () => {
// Duplicate-token v2 pools redirect to position unavailable
cy.visit(`/remove/v2/ETH/ETH`)
cy.contains('Position unavailable')
// Single-token pools don't exist
cy.visit('/remove/v2/ETH')
cy.url().should('match', /\/not-found/)
// Nonexistent v3 pool
cy.visit(`/remove/${MaxUint256}`)
cy.contains('Position unavailable')
})
}) })
...@@ -59,11 +59,11 @@ export default function RemoveLiquidityV3() { ...@@ -59,11 +59,11 @@ export default function RemoveLiquidityV3() {
} }
}, [tokenId]) }, [tokenId])
const { position, loading } = useV3PositionFromTokenId(parsedTokenId ?? undefined)
if (parsedTokenId === null || parsedTokenId.eq(0)) { if (parsedTokenId === null || parsedTokenId.eq(0)) {
return <Navigate to={{ ...location, pathname: '/pools' }} replace /> return <Navigate to={{ ...location, pathname: '/pools' }} replace />
} }
if (isSupportedChain(chainId) && (loading || position)) {
if (isSupportedChain(chainId)) {
return <Remove tokenId={parsedTokenId} /> return <Remove tokenId={parsedTokenId} />
} else { } else {
return <PositionPageUnsupportedContent /> return <PositionPageUnsupportedContent />
...@@ -312,15 +312,16 @@ function Remove({ tokenId }: { tokenId: BigNumber }) { ...@@ -312,15 +312,16 @@ function Remove({ tokenId }: { tokenId: BigNumber }) {
<RowBetween> <RowBetween>
<RowFixed> <RowFixed>
<DoubleCurrencyLogo <DoubleCurrencyLogo
currency0={feeValue0?.currency} currency0={liquidityValue0?.currency}
currency1={feeValue1?.currency} currency1={liquidityValue1?.currency}
size={20} size={20}
margin={true} margin={true}
/> />
<ThemedText.DeprecatedLabel <ThemedText.DeprecatedLabel
ml="10px" ml="10px"
fontSize="20px" fontSize="20px"
>{`${feeValue0?.currency?.symbol}/${feeValue1?.currency?.symbol}`}</ThemedText.DeprecatedLabel> id="remove-liquidity-tokens"
>{`${liquidityValue0?.currency?.symbol}/${liquidityValue1?.currency?.symbol}`}</ThemedText.DeprecatedLabel>
</RowFixed> </RowFixed>
<RangeBadge removed={removed} inRange={!outOfRange} /> <RangeBadge removed={removed} inRange={!outOfRange} />
</RowBetween> </RowBetween>
...@@ -354,7 +355,7 @@ function Remove({ tokenId }: { tokenId: BigNumber }) { ...@@ -354,7 +355,7 @@ function Remove({ tokenId }: { tokenId: BigNumber }) {
<LightCard> <LightCard>
<AutoColumn gap="md"> <AutoColumn gap="md">
<RowBetween> <RowBetween>
<Text fontSize={16} fontWeight={535}> <Text fontSize={16} fontWeight={535} id="remove-pooled-tokena-symbol">
<Trans>Pooled {liquidityValue0?.currency?.symbol}:</Trans> <Trans>Pooled {liquidityValue0?.currency?.symbol}:</Trans>
</Text> </Text>
<RowFixed> <RowFixed>
...@@ -365,7 +366,7 @@ function Remove({ tokenId }: { tokenId: BigNumber }) { ...@@ -365,7 +366,7 @@ function Remove({ tokenId }: { tokenId: BigNumber }) {
</RowFixed> </RowFixed>
</RowBetween> </RowBetween>
<RowBetween> <RowBetween>
<Text fontSize={16} fontWeight={535}> <Text fontSize={16} fontWeight={535} id="remove-pooled-tokenb-symbol">
<Trans>Pooled {liquidityValue1?.currency?.symbol}:</Trans> <Trans>Pooled {liquidityValue1?.currency?.symbol}:</Trans>
</Text> </Text>
<RowFixed> <RowFixed>
......
...@@ -52,7 +52,9 @@ const DEFAULT_REMOVE_LIQUIDITY_SLIPPAGE_TOLERANCE = new Percent(5, 100) ...@@ -52,7 +52,9 @@ const DEFAULT_REMOVE_LIQUIDITY_SLIPPAGE_TOLERANCE = new Percent(5, 100)
export default function RemoveLiquidityWrapper() { export default function RemoveLiquidityWrapper() {
const { chainId } = useWeb3React() const { chainId } = useWeb3React()
if (isSupportedChain(chainId)) { const { currencyIdA, currencyIdB } = useParams<{ currencyIdA: string; currencyIdB: string }>()
const [currencyA, currencyB] = [useCurrency(currencyIdA) ?? undefined, useCurrency(currencyIdB) ?? undefined]
if (isSupportedChain(chainId) && currencyA !== currencyB) {
return <RemoveLiquidity /> return <RemoveLiquidity />
} else { } else {
return <PositionPageUnsupportedContent /> return <PositionPageUnsupportedContent />
......
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