Commit 666bb798 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

fix: test id based on address & chain instead of ticker (#7167)

* fix: test id based on address instead of ticker

* add chain to test id

* use token address

* lowercase
parent 2736d944
import { ChainId } from '@uniswap/sdk-core'
import { UNI } from 'constants/tokens'
import { getTestSelector } from '../utils'
const UNI_ADDRESS = UNI[ChainId.MAINNET].address.toLowerCase()
describe('Universal search bar', () => {
function openSearch() {
// can't just type "/" because on mobile it doesn't respond to that
......@@ -19,7 +24,7 @@ describe('Universal search bar', () => {
openSearch()
getSearchBar().clear().type('uni')
cy.get(getTestSelector('searchbar-token-row-UNI'))
cy.get(getTestSelector(`searchbar-token-row-ETHEREUM-${UNI_ADDRESS}`))
.should('contain.text', 'Uniswap')
.and('contain.text', 'UNI')
.and('contain.text', '$')
......@@ -30,7 +35,7 @@ describe('Universal search bar', () => {
openSearch()
cy.get(getTestSelector('searchbar-dropdown'))
.contains(getTestSelector('searchbar-dropdown'), 'Recent searches')
.find(getTestSelector('searchbar-token-row-UNI'))
.find(getTestSelector(`searchbar-token-row-ETHEREUM-${UNI_ADDRESS}`))
.should('exist')
})
......@@ -51,13 +56,13 @@ describe('Universal search bar', () => {
// Seed recent results with UNI.
openSearch()
getSearchBar().type('uni')
cy.get(getTestSelector('searchbar-token-row-UNI'))
cy.get(getTestSelector(`searchbar-token-row-ETHEREUM-${UNI_ADDRESS}`))
getSearchBar().clear().type('{esc}')
// Search a different token by name.
openSearch()
getSearchBar().type('eth')
cy.get(getTestSelector('searchbar-token-row-ETH'))
cy.get(getTestSelector('searchbar-token-row-ETHEREUM-NATIVE'))
// Validate that we go to the searched/selected result.
getSearchBar().type('{enter}')
......
......@@ -160,7 +160,7 @@ export const TokenRow = ({ token, isHovered, setHoveredIndex, toggleOpen, index,
return (
<Link
data-testid={`searchbar-token-row-${token.symbol}`}
data-testid={`searchbar-token-row-${token.chain}-${token.address ?? 'NATIVE'}`}
to={tokenDetailsPath}
onClick={handleClick}
onMouseEnter={() => !isHovered && setHoveredIndex(index)}
......
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