Commit d6587205 authored by aballerr's avatar aballerr Committed by GitHub

chore: initial set of cypress tests for nft (#5590)

* initial set of cypress tests for nft
parent bba40846
import { getTestSelector } from '../utils'
const COLLECTION_ADDRESS = '0xbd3531da5cf5857e7cfaa92426877b022e612cf8'
describe('Testing nfts', () => {
before(() => {
cy.visit('/')
})
it('should load nft leaderboard', () => {
cy.get(getTestSelector('nft-nav')).first().click()
cy.get(getTestSelector('nft-nav')).first().should('exist')
cy.get(getTestSelector('nft-nav')).first().click()
cy.get(getTestSelector('nft-trending-collection')).its('length').should('be.gte', 25)
})
it('should load pudgy penguin collection page', () => {
cy.visit(`/#/nfts/collection/${COLLECTION_ADDRESS}`)
cy.get(getTestSelector('nft-collection-asset')).should('exist')
cy.get(getTestSelector('nft-collection-filter-buy-now')).should('not.exist')
cy.get(getTestSelector('nft-filter')).first().click()
cy.get(getTestSelector('nft-collection-filter-buy-now')).should('exist')
})
it('should be able to open bag and open sweep', () => {
cy.get(getTestSelector('nft-sweep-button')).first().click()
cy.get(getTestSelector('nft-empty-bag')).should('exist')
cy.get(getTestSelector('nft-sweep-slider')).should('exist')
})
it('should be able to navigate to activity', () => {
cy.get(getTestSelector('nft-activity')).first().click()
cy.get(getTestSelector('nft-activity-row')).should('exist')
})
})
...@@ -65,6 +65,17 @@ beforeEach(() => { ...@@ -65,6 +65,17 @@ beforeEach(() => {
res.headers['origin'] = 'http://localhost:3000' res.headers['origin'] = 'http://localhost:3000'
res.continue() res.continue()
}) })
// Graphql security policies are based on Origin headers.
// These are stripped by cypress because chromeWebSecurity === false; this adds them back in.
cy.intercept('https://api.uniswap.org/v1/graphql', (res) => {
res.headers['origin'] = 'https://app.uniswap.org'
res.continue()
})
cy.intercept('https://beta.api.uniswap.org/v1/graphql', (res) => {
res.headers['origin'] = 'https://app.uniswap.org'
res.continue()
})
}) })
Cypress.on('uncaught:exception', (_err, _runnable) => { Cypress.on('uncaught:exception', (_err, _runnable) => {
......
...@@ -45,15 +45,17 @@ interface MenuItemProps { ...@@ -45,15 +45,17 @@ interface MenuItemProps {
id?: NavLinkProps['id'] id?: NavLinkProps['id']
isActive?: boolean isActive?: boolean
children: ReactNode children: ReactNode
dataTestId?: string
} }
const MenuItem = ({ href, id, isActive, children }: MenuItemProps) => { const MenuItem = ({ href, dataTestId, id, isActive, children }: MenuItemProps) => {
return ( return (
<NavLink <NavLink
to={href} to={href}
className={isActive ? styles.activeMenuItem : styles.menuItem} className={isActive ? styles.activeMenuItem : styles.menuItem}
id={id} id={id}
style={{ textDecoration: 'none' }} style={{ textDecoration: 'none' }}
data-testid={dataTestId}
> >
{children} {children}
</NavLink> </NavLink>
...@@ -82,7 +84,7 @@ const PageTabs = () => { ...@@ -82,7 +84,7 @@ const PageTabs = () => {
<MenuItem href={`/tokens/${chainName.toLowerCase()}`} isActive={pathname.startsWith('/tokens')}> <MenuItem href={`/tokens/${chainName.toLowerCase()}`} isActive={pathname.startsWith('/tokens')}>
<Trans>Tokens</Trans> <Trans>Tokens</Trans>
</MenuItem> </MenuItem>
<MenuItem href="/nfts" isActive={isNftPage}> <MenuItem dataTestId="nft-nav" href="/nfts" isActive={isNftPage}>
<Trans>NFTs</Trans> <Trans>NFTs</Trans>
</MenuItem> </MenuItem>
<MenuItem href="/pool" id="pool-nav-link" isActive={isPoolActive}> <MenuItem href="/pool" id="pool-nav-link" isActive={isPoolActive}>
......
...@@ -26,7 +26,7 @@ const EmptyState = () => { ...@@ -26,7 +26,7 @@ const EmptyState = () => {
<Center className={subhead}>No NFTs selected</Center> <Center className={subhead}>No NFTs selected</Center>
) : ( ) : (
<Column gap="16"> <Column gap="16">
<Center className={subhead} style={{ lineHeight: '24px' }}> <Center data-testid="nft-empty-bag" className={subhead} style={{ lineHeight: '24px' }}>
Your bag is empty Your bag is empty
</Center> </Center>
<Center fontSize="12" fontWeight="normal" color="textSecondary" style={{ lineHeight: '16px' }}> <Center fontSize="12" fontWeight="normal" color="textSecondary" style={{ lineHeight: '16px' }}>
......
...@@ -159,7 +159,7 @@ export const Activity = ({ contractAddress, rarityVerified, collectionName, chai ...@@ -159,7 +159,7 @@ export const Activity = ({ contractAddress, rarityVerified, collectionName, chai
style={{ overflow: 'unset' }} style={{ overflow: 'unset' }}
> >
{events.map((event, i) => ( {events.map((event, i) => (
<Box as="a" href={baseHref(event)} className={styles.eventRow} key={i}> <Box as="a" data-testid="nft-activity-row" href={baseHref(event)} className={styles.eventRow} key={i}>
<ItemCell <ItemCell
event={event} event={event}
rarityVerified={rarityVerified} rarityVerified={rarityVerified}
......
...@@ -48,6 +48,7 @@ export const ActivitySwitcher = ({ ...@@ -48,6 +48,7 @@ export const ActivitySwitcher = ({
as="button" as="button"
className={!showActivity ? styles.activitySwitcherToggle : styles.selectedActivitySwitcherToggle} className={!showActivity ? styles.activitySwitcherToggle : styles.selectedActivitySwitcherToggle}
onClick={() => !showActivity && toggleActivity()} onClick={() => !showActivity && toggleActivity()}
data-testid="nft-activity"
> >
Activity Activity
</Box> </Box>
......
...@@ -122,7 +122,7 @@ export const CollectionAsset = ({ ...@@ -122,7 +122,7 @@ export const CollectionAsset = ({
removeAssetFromBag={handleRemoveAssetFromBag} removeAssetFromBag={handleRemoveAssetFromBag}
> >
<Card.ImageContainer isDisabled={asset.notForSale}> <Card.ImageContainer isDisabled={asset.notForSale}>
<StyledContainer> <StyledContainer data-testid="nft-collection-asset">
<Tooltip <Tooltip
text={ text={
<Box as="span" className={bodySmall} color="textPrimary"> <Box as="span" className={bodySmall} color="textPrimary">
......
...@@ -528,6 +528,7 @@ export const CollectionNfts = ({ contractAddress, collectionStats, rarityVerifie ...@@ -528,6 +528,7 @@ export const CollectionNfts = ({ contractAddress, collectionStats, rarityVerifie
disabled={hasErc1155s} disabled={hasErc1155s}
className={buttonTextMedium} className={buttonTextMedium}
onClick={handleSweepClick} onClick={handleSweepClick}
data-testid="nft-sweep-button"
> >
<SweepIcon viewBox="0 0 24 24" width="20px" height="20px" /> <SweepIcon viewBox="0 0 24 24" width="20px" height="20px" />
<SweepText fontWeight={600} color="currentColor" lineHeight="20px"> <SweepText fontWeight={600} color="currentColor" lineHeight="20px">
......
...@@ -34,6 +34,7 @@ export const FilterButton = ({ ...@@ -34,6 +34,7 @@ export const FilterButton = ({
height="44" height="44"
whiteSpace="nowrap" whiteSpace="nowrap"
color="white" color="white"
data-testid="nft-filter"
> >
<FilterIcon /> <FilterIcon />
{!isMobile ? ( {!isMobile ? (
......
...@@ -53,7 +53,9 @@ export const Filters = ({ traitsByGroup }: { traitsByGroup: Record<string, Trait ...@@ -53,7 +53,9 @@ export const Filters = ({ traitsByGroup }: { traitsByGroup: Record<string, Trait
onMouseEnter={toggleBuyNowHover} onMouseEnter={toggleBuyNowHover}
onMouseLeave={toggleBuyNowHover} onMouseLeave={toggleBuyNowHover}
> >
<Box className={subhead}>Buy now</Box> <Box data-testid="nft-collection-filter-buy-now" className={subhead}>
Buy now
</Box>
<Checkbox hovered={buyNowHovered} checked={buyNow} onClick={handleBuyNowToggle}> <Checkbox hovered={buyNowHovered} checked={buyNow} onClick={handleBuyNowToggle}>
<span /> <span />
</Checkbox> </Checkbox>
......
...@@ -363,7 +363,7 @@ export const Sweep = ({ contractAddress, minPrice, maxPrice }: SweepProps) => { ...@@ -363,7 +363,7 @@ export const Sweep = ({ contractAddress, minPrice, maxPrice }: SweepProps) => {
} }
return ( return (
<SweepContainer> <SweepContainer data-testid="nft-sweep-slider">
<SweepLeftmostContainer> <SweepLeftmostContainer>
<SweepHeaderContainer> <SweepHeaderContainer>
<ThemedText.SubHeader color="textPrimary" lineHeight="20px" paddingTop="6px" paddingBottom="6px"> <ThemedText.SubHeader color="textPrimary" lineHeight="20px" paddingTop="6px" paddingBottom="6px">
......
...@@ -198,6 +198,7 @@ export function Table<D extends Record<string, unknown>>({ ...@@ -198,6 +198,7 @@ export function Table<D extends Record<string, unknown>>({
{...row.getRowProps()} {...row.getRowProps()}
key={row.id} key={row.id}
onClick={() => navigate(`/nfts/collection/${row.original.collection.address}`)} onClick={() => navigate(`/nfts/collection/${row.original.collection.address}`)}
data-testid="nft-trending-collection"
> >
{row.cells.map((cell, cellIndex) => { {row.cells.map((cell, cellIndex) => {
return ( return (
......
...@@ -112,7 +112,7 @@ export function WelcomeModal({ onDismissed }: { onDismissed: () => void }) { ...@@ -112,7 +112,7 @@ export function WelcomeModal({ onDismissed }: { onDismissed: () => void }) {
Learn more. Learn more.
</Link> </Link>
</Paragraph> </Paragraph>
<CloseButton size={24} onClick={dismiss} /> <CloseButton data-testid="nft-intro-modal" size={24} onClick={dismiss} />
</Content> </Content>
</Container> </Container>
</Modal> </Modal>
......
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