uniswap-interface-uncensored/cypress/e2e/token-details.test.ts

157 lines
7.0 KiB
TypeScript
Raw Normal View History

feat: upgrade sdk-core to 3.2.6 and add AVAX (#6757) * init refactor * upgrade to 3.2.6 and refactor more uses of chainid * cleaned up lock file * remove console log and add placeholder * use supported chains type for switch fn * allow passing of all chainIds to switcher * additional typecast * better casting solution * yarn.lock cleanup * prettier * better casting for rpc * prettier * deprecate no longer needed addresses * better isSupported checking * deprecate redundant fn * cleanup toSupportedChainId * address initial ocmments * pretier * includes testnet * remove unused export * merge conflicts * spread for mutable copy * explorer text * check is supported before activating chain * remove extra uses of mumbai * remove cast to MockChainId * retain var name supportedChainId * updated prettier * use t for explorer translation * use mockchainid for test * feat: Add Avalanche support (#6776) * init avax * add most avax props * add logo * correct subgraph * update avax blocksPerFetch * add square logo * upgrade ur sdk * version syntax * correct tokens * remove unused token * remove unused token * update token list and add coming soon to searchbar * add coming soon to token explore page * names to ids * cleaned up routing * usdc token * upgrade default token list * update SOR * upgrade SOR * merge conflicts * snowtrace * upgrade SOR * handle be avax support * temp hide avax * show pool positions * whole * spotprice update * not yet supported * BACKEND_SUPPORTED_CHAINS * add avax to BE not supported * update multicall blocks to 5 * add todo * updated prettier --------- Co-authored-by: Charles Bachmeier <charlie@genie.xyz> * be added avax token balances * validateUrlChainParam should return eth for backend unsupported chain * readonly * respond to comments --------- Co-authored-by: Charles Bachmeier <charlie@genie.xyz>
2023-07-07 07:44:06 +03:00
import { ChainId, WETH9 } from '@uniswap/sdk-core'
import { ARB, UNI } from '../../src/constants/tokens'
import { getTestSelector } from '../utils'
feat: upgrade sdk-core to 3.2.6 and add AVAX (#6757) * init refactor * upgrade to 3.2.6 and refactor more uses of chainid * cleaned up lock file * remove console log and add placeholder * use supported chains type for switch fn * allow passing of all chainIds to switcher * additional typecast * better casting solution * yarn.lock cleanup * prettier * better casting for rpc * prettier * deprecate no longer needed addresses * better isSupported checking * deprecate redundant fn * cleanup toSupportedChainId * address initial ocmments * pretier * includes testnet * remove unused export * merge conflicts * spread for mutable copy * explorer text * check is supported before activating chain * remove extra uses of mumbai * remove cast to MockChainId * retain var name supportedChainId * updated prettier * use t for explorer translation * use mockchainid for test * feat: Add Avalanche support (#6776) * init avax * add most avax props * add logo * correct subgraph * update avax blocksPerFetch * add square logo * upgrade ur sdk * version syntax * correct tokens * remove unused token * remove unused token * update token list and add coming soon to searchbar * add coming soon to token explore page * names to ids * cleaned up routing * usdc token * upgrade default token list * update SOR * upgrade SOR * merge conflicts * snowtrace * upgrade SOR * handle be avax support * temp hide avax * show pool positions * whole * spotprice update * not yet supported * BACKEND_SUPPORTED_CHAINS * add avax to BE not supported * update multicall blocks to 5 * add todo * updated prettier --------- Co-authored-by: Charles Bachmeier <charlie@genie.xyz> * be added avax token balances * validateUrlChainParam should return eth for backend unsupported chain * readonly * respond to comments --------- Co-authored-by: Charles Bachmeier <charlie@genie.xyz>
2023-07-07 07:44:06 +03:00
const UNI_MAINNET = UNI[ChainId.MAINNET]
const UNI_ADDRESS = '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'
describe('Token details', () => {
beforeEach(() => {
cy.viewport(1440, 900)
})
it('Uniswap token should have all information populated', () => {
// Uniswap token
cy.visit(`/tokens/ethereum/${UNI_ADDRESS}`)
// Price chart should be filled in
cy.get('[data-cy="chart-header"]').should('include.text', '$')
cy.get('[data-cy="price-chart"]').should('exist')
// Stats should have: TVL, 24H Volume, 52W low, 52W high
cy.get(getTestSelector('token-details-stats')).should('exist')
cy.get(getTestSelector('token-details-stats')).within(() => {
cy.get('[data-cy="tvl"]').should('include.text', '$')
cy.get('[data-cy="volume-24h"]').should('include.text', '$')
cy.get('[data-cy="52w-low"]').should('include.text', '$')
cy.get('[data-cy="52w-high"]').should('include.text', '$')
})
// About section should have description of token
cy.get(getTestSelector('token-details-about-section')).should('exist')
cy.contains('UNI is the governance token for Uniswap').should('exist')
// Links section should link out to Etherscan, More analytics, Website, Twitter
cy.get('[data-cy="resources-container"]').within(() => {
cy.contains('Etherscan').should('have.attr', 'href').and('include', `etherscan.io/address/${UNI_ADDRESS}`)
cy.contains('More analytics')
.should('have.attr', 'href')
.and('include', `info.uniswap.org/#/tokens/${UNI_ADDRESS}`)
cy.contains('Website').should('have.attr', 'href').and('include', 'uniswap.org')
cy.contains('Twitter').should('have.attr', 'href').and('include', 'twitter.com/Uniswap')
})
// Contract address should be displayed
cy.contains(UNI_ADDRESS).should('exist')
})
it('token with warning and low trading volume should have all information populated', () => {
// Shiba predator token, low trading volume and also has warning modal
cy.visit('/tokens/ethereum/0xa71d0588EAf47f12B13cF8eC750430d21DF04974')
// Should have missing price chart when price unavailable (expected for this token)
if (cy.get('[data-cy="chart-header"]').contains('Price Unavailable')) {
cy.get('[data-cy="missing-chart"]').should('exist')
}
// Stats should have: TVL, 24H Volume, 52W low, 52W high
cy.get(getTestSelector('token-details-stats')).should('exist')
cy.get(getTestSelector('token-details-stats')).within(() => {
cy.get('[data-cy="tvl"]').should('exist')
cy.get('[data-cy="volume-24h"]').should('exist')
cy.get('[data-cy="52w-low"]').should('exist')
cy.get('[data-cy="52w-high"]').should('exist')
})
// About section should have description of token
cy.get(getTestSelector('token-details-about-section')).should('exist')
cy.contains('QOM is the Shiba Predator').should('exist')
// Links section should link out to Etherscan, More analytics, Website, Twitter
cy.get('[data-cy="resources-container"]').within(() => {
cy.contains('Etherscan')
.should('have.attr', 'href')
.and('include', 'etherscan.io/address/0xa71d0588EAf47f12B13cF8eC750430d21DF04974')
cy.contains('More analytics')
.should('have.attr', 'href')
.and('include', 'info.uniswap.org/#/tokens/0xa71d0588EAf47f12B13cF8eC750430d21DF04974')
cy.contains('Website').should('have.attr', 'href').and('include', 'qom')
cy.contains('Twitter').should('have.attr', 'href').and('include', 'twitter.com/ShibaPredator1')
})
// Contract address should be displayed
cy.contains('0xa71d0588EAf47f12B13cF8eC750430d21DF04974').should('exist')
// Warning label should show if relevant ([spec](https://www.notion.so/3f7fce6f93694be08a94a6984d50298e))
cy.get('[data-cy="token-safety-message"]')
.should('include.text', 'Warning')
.and('include.text', "This token isn't traded on leading U.S. centralized exchanges")
})
describe('swapping', () => {
beforeEach(() => {
// On mobile widths, we just link back to /swap instead of rendering the swap component.
cy.viewport(1200, 800)
cy.visit(`/tokens/ethereum/${UNI_MAINNET.address}`).then(() => {
cy.wait('@eth_blockNumber')
cy.scrollTo('top')
})
})
it('should have the expected output for a tokens detail page', () => {
cy.get(`#swap-currency-input .token-amount-input`).should('have.value', '')
cy.get(`#swap-currency-input .token-symbol-container`).should('contain.text', 'Select token')
cy.get(`#swap-currency-output .token-amount-input`).should('not.have.value')
cy.get(`#swap-currency-output .token-symbol-container`).should('contain.text', 'UNI')
})
it('should automatically navigate to the new TDP', () => {
cy.get(`#swap-currency-output .open-currency-select-button`).click()
feat: Spore colors refresh (#7118) * Add colors and type and fix everywhere * fix text.tsx * Color and text adjustments * Further tweaks * Removed promotional gradient Changed to pink * Add new icons and tweak broken colors * Kill shadows Removes shadows from NFT cards, Pools and Tokens tables * Update icons Update filled and info icons to filled versions * Update bag icon Changed to fill style * Change share icon Changed to the new filled arrow * Fix merge errors * update tests * Complete find and replace old colors * Fix colors on pool pages * Update index.test.tsx.snap * fix header hover states * update test * Update connect button hover state * Update styles design bash * Update tests * Update fonts * fix buy button font weight * update tests * fix jumping input boxes * lint * lints * update tests * redo auth header * fix issues * fix snapshots * use individual weights instead of variable for nicer $ signn * update tests * make dark mode glow distinct * remove commented out code * icons in react * update textSecondary * fix feedback * port over token test fix * lint * fix: make popups appear above drawer and near top conditionally only when drawer is open * Revert "fix: make popups appear above drawer and near top conditionally only when drawer is open" This reverts commit 994697144374ae3fc0cdf9275bce538fda5fc8de. --------- Co-authored-by: Callil Capuozzo <callil.capuozzo@gmail.com> Co-authored-by: pp-hh-ii-ll <111304124+pp-hh-ii-ll@users.noreply.github.com> Co-authored-by: Callil Capuozzo <callil@uniswap.org>
2023-08-25 06:14:24 +03:00
cy.get('[data-reach-dialog-content]').contains('WETH').click()
cy.url().should('include', `${WETH9[1].address}`)
cy.url().should('not.include', `${UNI_MAINNET.address}`)
})
it('should not share swap state with the main swap page', () => {
cy.get(`#swap-currency-output .token-symbol-container`).should('contain.text', 'UNI')
cy.get(`#swap-currency-input .open-currency-select-button`).click()
cy.contains('WETH').click()
cy.visit('/swap')
cy.contains('UNI').should('not.exist')
cy.contains('WETH').should('not.exist')
})
it('can enter an amount into input', () => {
cy.get('#swap-currency-input .token-amount-input').clear().type('0.001').should('have.value', '0.001')
})
it('zero swap amount', () => {
cy.get('#swap-currency-input .token-amount-input').clear().type('0.0').should('have.value', '0.0')
})
it('invalid swap amount', () => {
cy.get('#swap-currency-input .token-amount-input').clear().type('\\').should('have.value', '')
})
it('can enter an amount into output', () => {
cy.get('#swap-currency-output .token-amount-input').clear().type('0.001').should('have.value', '0.001')
})
it('zero output amount', () => {
cy.get('#swap-currency-output .token-amount-input').clear().type('0.0').should('have.value', '0.0')
})
it('should show a L2 token even if the user is connected to a different network', () => {
cy.visit('/tokens')
cy.get(getTestSelector('tokens-network-filter-selected')).click()
cy.get(getTestSelector('tokens-network-filter-option-arbitrum')).click()
cy.get(getTestSelector('tokens-network-filter-selected')).should('contain', 'Arbitrum')
cy.get(getTestSelector(`token-table-row-${ARB.address.toLowerCase()}`)).click()
cy.get(`#swap-currency-output .token-symbol-container`).should('contain.text', 'ARB')
cy.get(getTestSelector('open-settings-dialog-button')).should('be.disabled')
cy.contains('Connect to Arbitrum').should('exist')
})
})
})