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