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
|
|
|
openSearch()
|
2023-01-20 02:12:40 +03:00
|
|
|
})
|
|
|
|
|
2023-07-20 00:58:02 +03:00
|
|
|
function getSearchBar() {
|
|
|
|
return cy.get('[data-cy="search-bar-input"]').last()
|
|
|
|
}
|
|
|
|
|
2023-01-20 02:12:40 +03:00
|
|
|
it('should yield clickable result for regular token or nft collection search term', () => {
|
|
|
|
// Search for uni token by name.
|
2023-07-20 00:58:02 +03:00
|
|
|
getSearchBar().clear().type('uni')
|
2023-01-20 02:12:40 +03:00
|
|
|
cy.get('[data-cy="searchbar-token-row-UNI"]')
|
|
|
|
.should('contain.text', 'Uniswap')
|
|
|
|
.and('contain.text', 'UNI')
|
|
|
|
.and('contain.text', '$')
|
|
|
|
.and('contain.text', '%')
|
2023-04-26 00:24:57 +03:00
|
|
|
cy.get('[data-cy="searchbar-token-row-UNI"]').first().click()
|
2023-06-30 20:28:48 +03:00
|
|
|
cy.location('hash').should('equal', '#/tokens/ethereum/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984')
|
2023-01-20 02:12:40 +03:00
|
|
|
})
|
|
|
|
|
2023-07-20 00:58:02 +03:00
|
|
|
it('should go to the selected result when recent results are shown', () => {
|
|
|
|
// Search for uni token by name.
|
|
|
|
getSearchBar().type('uni')
|
|
|
|
cy.get('[data-cy="searchbar-token-row-UNI"]')
|
|
|
|
|
|
|
|
// Clear search
|
|
|
|
getSearchBar().clear()
|
|
|
|
|
|
|
|
// Close search
|
|
|
|
getSearchBar().type('{esc}')
|
|
|
|
|
|
|
|
openSearch()
|
|
|
|
|
|
|
|
// Search a different token by name.
|
|
|
|
getSearchBar().type('eth')
|
|
|
|
|
|
|
|
// Validate ETH result now exists.
|
|
|
|
cy.get('[data-cy="searchbar-token-row-ETH"]')
|
|
|
|
|
|
|
|
// Hit enter
|
|
|
|
getSearchBar().type('{enter}')
|
|
|
|
|
|
|
|
// Validate we went to ethereum address
|
|
|
|
cy.url().should('contain', 'tokens/ethereum/NATIVE')
|
|
|
|
})
|
|
|
|
|
2023-03-03 22:20:41 +03:00
|
|
|
it.skip('should show recent tokens and popular tokens with empty search term', () => {
|
2023-01-20 02:12:40 +03:00
|
|
|
cy.get('[data-cy="magnifying-icon"]')
|
|
|
|
.parent()
|
|
|
|
.then(($navIcon) => {
|
|
|
|
$navIcon.click()
|
|
|
|
})
|
|
|
|
// Recently searched UNI token should exist.
|
2023-07-20 00:58:02 +03:00
|
|
|
getSearchBar().clear()
|
2023-01-20 02:12:40 +03:00
|
|
|
cy.get('[data-cy="searchbar-dropdown"]')
|
|
|
|
.contains('[data-cy="searchbar-dropdown"]', 'Recent searches')
|
|
|
|
.find('[data-cy="searchbar-token-row-UNI"]')
|
|
|
|
.should('exist')
|
|
|
|
|
|
|
|
// Most popular 3 tokens should be shown.
|
|
|
|
cy.get('[data-cy="searchbar-dropdown"]')
|
|
|
|
.contains('[data-cy="searchbar-dropdown"]', 'Popular tokens')
|
|
|
|
.find('[data-cy^="searchbar-token-row"]')
|
|
|
|
.its('length')
|
|
|
|
.should('be.eq', 3)
|
|
|
|
})
|
|
|
|
|
2023-01-24 20:57:08 +03:00
|
|
|
it.skip('should show blocked badge when blocked token is searched for', () => {
|
2023-01-20 02:12:40 +03:00
|
|
|
// Search for mTSLA, which is a blocked token.
|
2023-07-20 00:58:02 +03:00
|
|
|
getSearchBar().clear().type('mtsla')
|
2023-01-20 02:12:40 +03:00
|
|
|
cy.get('[data-cy="searchbar-token-row-mTSLA"]').find('[data-cy="blocked-icon"]').should('exist')
|
|
|
|
})
|
|
|
|
})
|