2023-07-29 02:36:13 +03:00
|
|
|
import { getTestSelector } from '../utils'
|
|
|
|
|
2023-01-20 02:12:40 +03:00
|
|
|
describe('Universal search bar', () => {
|
2023-07-20 00:58:02 +03:00
|
|
|
function openSearch() {
|
|
|
|
// can't just type "/" because on mobile it doesn't respond to that
|
|
|
|
cy.get('[data-cy="magnifying-icon"]').parent().eq(1).click()
|
|
|
|
}
|
|
|
|
|
2023-06-30 20:28:48 +03:00
|
|
|
beforeEach(() => {
|
2023-01-20 02:12:40 +03:00
|
|
|
cy.visit('/')
|
|
|
|
})
|
|
|
|
|
2023-07-20 00:58:02 +03:00
|
|
|
function getSearchBar() {
|
|
|
|
return cy.get('[data-cy="search-bar-input"]').last()
|
|
|
|
}
|
|
|
|
|
2023-07-29 02:36:13 +03:00
|
|
|
it('should yield clickable result that is then added to recent searches', () => {
|
|
|
|
// Search for UNI token by name.
|
|
|
|
openSearch()
|
2023-07-20 00:58:02 +03:00
|
|
|
getSearchBar().clear().type('uni')
|
2023-07-29 02:36:13 +03:00
|
|
|
|
|
|
|
cy.get(getTestSelector('searchbar-token-row-UNI'))
|
2023-01-20 02:12:40 +03:00
|
|
|
.should('contain.text', 'Uniswap')
|
|
|
|
.and('contain.text', 'UNI')
|
|
|
|
.and('contain.text', '$')
|
|
|
|
.and('contain.text', '%')
|
2023-07-29 02:36:13 +03:00
|
|
|
.click()
|
2023-08-08 01:01:45 +03:00
|
|
|
cy.location('pathname').should('equal', '/tokens/ethereum/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984')
|
2023-07-20 00:58:02 +03:00
|
|
|
|
2023-07-29 02:36:13 +03:00
|
|
|
openSearch()
|
|
|
|
cy.get(getTestSelector('searchbar-dropdown'))
|
|
|
|
.contains(getTestSelector('searchbar-dropdown'), 'Recent searches')
|
|
|
|
.find(getTestSelector('searchbar-token-row-UNI'))
|
2023-01-20 02:12:40 +03:00
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
|
2023-07-29 02:36:13 +03:00
|
|
|
it('should go to the selected result when recent results are shown', () => {
|
|
|
|
// Seed recent results with UNI.
|
|
|
|
openSearch()
|
|
|
|
getSearchBar().type('uni')
|
|
|
|
cy.get(getTestSelector('searchbar-token-row-UNI'))
|
|
|
|
getSearchBar().clear().type('{esc}')
|
|
|
|
|
|
|
|
// Search a different token by name.
|
|
|
|
openSearch()
|
|
|
|
getSearchBar().type('eth')
|
|
|
|
cy.get(getTestSelector('searchbar-token-row-ETH'))
|
|
|
|
|
|
|
|
// Validate that we go to the searched/selected result.
|
|
|
|
getSearchBar().type('{enter}')
|
|
|
|
cy.url().should('contain', 'tokens/ethereum/NATIVE')
|
2023-01-20 02:12:40 +03:00
|
|
|
})
|
|
|
|
})
|