Commit 614c1524 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

fix: tokens with same name brake cypress test (#6890)

* fix: tokens with same name brake cypress test

* lowercase
parent 082db213
import { SupportedChainId, WETH9 } from '@uniswap/sdk-core' import { SupportedChainId, WETH9 } from '@uniswap/sdk-core'
import { UNI } from '../../src/constants/tokens' import { ARB, UNI } from '../../src/constants/tokens'
import { getTestSelector } from '../utils' import { getTestSelector } from '../utils'
const UNI_MAINNET = UNI[SupportedChainId.MAINNET] const UNI_MAINNET = UNI[SupportedChainId.MAINNET]
...@@ -149,7 +149,7 @@ describe('Token details', () => { ...@@ -149,7 +149,7 @@ describe('Token details', () => {
cy.get(getTestSelector('tokens-network-filter-selected')).click() cy.get(getTestSelector('tokens-network-filter-selected')).click()
cy.get(getTestSelector('tokens-network-filter-option-arbitrum')).click() cy.get(getTestSelector('tokens-network-filter-option-arbitrum')).click()
cy.get(getTestSelector('tokens-network-filter-selected')).should('contain', 'Arbitrum') cy.get(getTestSelector('tokens-network-filter-selected')).should('contain', 'Arbitrum')
cy.get(getTestSelector('token-table-row-ARB')).click() cy.get(getTestSelector(`token-table-row-${ARB.address.toLowerCase()}`)).click()
cy.get(`#swap-currency-output .token-symbol-container`).should('contain.text', 'ARB') cy.get(`#swap-currency-output .token-symbol-container`).should('contain.text', 'ARB')
cy.get(getTestSelector('open-settings-dialog-button')).should('be.disabled') cy.get(getTestSelector('open-settings-dialog-button')).should('be.disabled')
cy.contains('Connect to Arbitrum').should('exist') cy.contains('Connect to Arbitrum').should('exist')
......
...@@ -10,11 +10,11 @@ describe('Token explore', () => { ...@@ -10,11 +10,11 @@ describe('Token explore', () => {
cy.get(getTestSelectorStartsWith('token-table')).its('length').should('be.greaterThan', 0) cy.get(getTestSelectorStartsWith('token-table')).its('length').should('be.greaterThan', 0)
// check sorted svg icon is present in volume cell, since tokens are sorted by volume by default // check sorted svg icon is present in volume cell, since tokens are sorted by volume by default
cy.get(getTestSelector('header-row')).find(getTestSelector('volume-cell')).find('svg').should('exist') cy.get(getTestSelector('header-row')).find(getTestSelector('volume-cell')).find('svg').should('exist')
cy.get(getTestSelector('token-table-row-ETH')).find(getTestSelector('name-cell')).should('include.text', 'Ether') cy.get(getTestSelector('token-table-row-NATIVE')).find(getTestSelector('name-cell')).should('include.text', 'Ether')
cy.get(getTestSelector('token-table-row-ETH')).find(getTestSelector('volume-cell')).should('include.text', '$') cy.get(getTestSelector('token-table-row-NATIVE')).find(getTestSelector('volume-cell')).should('include.text', '$')
cy.get(getTestSelector('token-table-row-ETH')).find(getTestSelector('price-cell')).should('include.text', '$') cy.get(getTestSelector('token-table-row-NATIVE')).find(getTestSelector('price-cell')).should('include.text', '$')
cy.get(getTestSelector('token-table-row-ETH')).find(getTestSelector('tvl-cell')).should('include.text', '$') cy.get(getTestSelector('token-table-row-NATIVE')).find(getTestSelector('tvl-cell')).should('include.text', '$')
cy.get(getTestSelector('token-table-row-ETH')) cy.get(getTestSelector('token-table-row-NATIVE'))
.find(getTestSelector('percent-change-cell')) .find(getTestSelector('percent-change-cell'))
.should('include.text', '%') .should('include.text', '%')
cy.get(getTestSelector('header-row')).find(getTestSelector('price-cell')).click() cy.get(getTestSelector('header-row')).find(getTestSelector('price-cell')).click()
...@@ -24,14 +24,14 @@ describe('Token explore', () => { ...@@ -24,14 +24,14 @@ describe('Token explore', () => {
it('should update when time window toggled', () => { it('should update when time window toggled', () => {
cy.visit('/tokens/ethereum') cy.visit('/tokens/ethereum')
cy.get(getTestSelector('time-selector')).should('contain', '1D') cy.get(getTestSelector('time-selector')).should('contain', '1D')
cy.get(getTestSelector('token-table-row-ETH')) cy.get(getTestSelector('token-table-row-NATIVE'))
.find(getTestSelector('volume-cell')) .find(getTestSelector('volume-cell'))
.then(function ($elem) { .then(function ($elem) {
cy.wrap($elem.text()).as('dailyEthVol') cy.wrap($elem.text()).as('dailyEthVol')
}) })
cy.get(getTestSelector('time-selector')).click() cy.get(getTestSelector('time-selector')).click()
cy.get(getTestSelector('1Y')).click() cy.get(getTestSelector('1Y')).click()
cy.get(getTestSelector('token-table-row-ETH')) cy.get(getTestSelector('token-table-row-NATIVE'))
.find(getTestSelector('volume-cell')) .find(getTestSelector('volume-cell'))
.then(function ($elem) { .then(function ($elem) {
cy.wrap($elem.text()).as('yearlyEthVol') cy.wrap($elem.text()).as('yearlyEthVol')
...@@ -41,7 +41,7 @@ describe('Token explore', () => { ...@@ -41,7 +41,7 @@ describe('Token explore', () => {
it('should navigate to token detail page when row clicked', () => { it('should navigate to token detail page when row clicked', () => {
cy.visit('/tokens/ethereum') cy.visit('/tokens/ethereum')
cy.get(getTestSelector('token-table-row-ETH')).click() cy.get(getTestSelector('token-table-row-NATIVE')).click()
cy.get(getTestSelector('token-details-about-section')).should('exist') cy.get(getTestSelector('token-details-about-section')).should('exist')
cy.get(getTestSelector('token-details-stats')).should('exist') cy.get(getTestSelector('token-details-stats')).should('exist')
cy.get(getTestSelector('token-info-container')).should('exist') cy.get(getTestSelector('token-info-container')).should('exist')
...@@ -53,13 +53,15 @@ describe('Token explore', () => { ...@@ -53,13 +53,15 @@ describe('Token explore', () => {
it('should update when global network changed', () => { it('should update when global network changed', () => {
cy.visit('/tokens/ethereum') cy.visit('/tokens/ethereum')
cy.get(getTestSelector('tokens-network-filter-selected')).should('contain', 'Ethereum') cy.get(getTestSelector('tokens-network-filter-selected')).should('contain', 'Ethereum')
cy.get(getTestSelector('token-table-row-ETH')).should('exist') cy.get(getTestSelector('token-table-row-NATIVE')).should('exist')
// note: cannot switch global chain via UI because we cannot approve the network switch // note: cannot switch global chain via UI because we cannot approve the network switch
// in metamask modal using plain cypress. this is a workaround. // in metamask modal using plain cypress. this is a workaround.
cy.visit('/tokens/polygon') cy.visit('/tokens/polygon')
cy.get(getTestSelector('tokens-network-filter-selected')).should('contain', 'Polygon') cy.get(getTestSelector('tokens-network-filter-selected')).should('contain', 'Polygon')
cy.get(getTestSelector('token-table-row-MATIC')).should('exist') cy.get(getTestSelector('token-table-row-NATIVE'))
.find(getTestSelector('name-cell'))
.should('include.text', 'Polygon Matic')
}) })
it('should update when token explore table network changed', () => { it('should update when token explore table network changed', () => {
......
...@@ -458,7 +458,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT ...@@ -458,7 +458,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
// TODO: currency logo sizing mobile (32px) vs. desktop (24px) // TODO: currency logo sizing mobile (32px) vs. desktop (24px)
return ( return (
<div ref={ref} data-testid={`token-table-row-${token.symbol}`}> <div ref={ref} data-testid={`token-table-row-${token.address}`}>
<StyledLink <StyledLink
to={getTokenDetailsURL(token)} to={getTokenDetailsURL(token)}
onClick={() => onClick={() =>
......
...@@ -327,7 +327,7 @@ exports[`LoadedRow.tsx renders a row 1`] = ` ...@@ -327,7 +327,7 @@ exports[`LoadedRow.tsx renders a row 1`] = `
} }
<div <div
data-testid="token-table-row-USDC" data-testid="token-table-row-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
> >
<a <a
class="c0" class="c0"
......
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