Commit f2af4603 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

test(e2e): wallet connection (#6661)

parent 20a06c9b
...@@ -28,6 +28,27 @@ describe('Mini Portfolio account drawer', () => { ...@@ -28,6 +28,27 @@ describe('Mini Portfolio account drawer', () => {
cy.get('@gqlSpy').should('have.been.calledOnce') cy.get('@gqlSpy').should('have.been.calledOnce')
}) })
it('fetches account information', () => {
// Open the mini portfolio
cy.intercept(/graphql/, { fixture: 'mini-portfolio/tokens.json' })
cy.get(getTestSelector('web3-status-connected')).click()
// Verify that wallet state loads correctly
cy.get(getTestSelector('mini-portfolio-navbar')).contains('Tokens')
cy.get(getTestSelector('mini-portfolio-page')).contains('Hidden (201)')
cy.intercept(/graphql/, { fixture: 'mini-portfolio/nfts.json' })
cy.get(getTestSelector('mini-portfolio-navbar')).contains('NFTs').click()
cy.get(getTestSelector('mini-portfolio-page')).contains('I Got Plenty')
cy.get(getTestSelector('mini-portfolio-navbar')).contains('Pools').click()
cy.get(getTestSelector('mini-portfolio-page')).contains('No pools yet')
cy.intercept(/graphql/, { fixture: 'mini-portfolio/activity.json' })
cy.get(getTestSelector('mini-portfolio-navbar')).contains('Activity').click()
cy.get(getTestSelector('mini-portfolio-page')).contains('Contract Interaction')
})
it('refetches balances when account changes', () => { it('refetches balances when account changes', () => {
cy.hardhat().then((hardhat) => { cy.hardhat().then((hardhat) => {
const accountA = hardhat.wallets[0].address const accountA = hardhat.wallets[0].address
......
...@@ -108,7 +108,7 @@ describe('mini-portfolio activity history', () => { ...@@ -108,7 +108,7 @@ describe('mini-portfolio activity history', () => {
// Check activity history tab. // Check activity history tab.
cy.get(getTestSelector('web3-status-connected')).click() cy.get(getTestSelector('web3-status-connected')).click()
cy.get(getTestSelector('mini-portfolio-nav-activity')).click() cy.get(getTestSelector('mini-portfolio-navbar')).contains('Activity').click()
// Assert that the local pending transaction is replaced by a remote transaction with the same nonce. // Assert that the local pending transaction is replaced by a remote transaction with the same nonce.
cy.contains('Swapping').should('not.exist') cy.contains('Swapping').should('not.exist')
......
...@@ -4,11 +4,8 @@ const PUDGY_COLLECTION_ADDRESS = '0xbd3531da5cf5857e7cfaa92426877b022e612cf8' ...@@ -4,11 +4,8 @@ const PUDGY_COLLECTION_ADDRESS = '0xbd3531da5cf5857e7cfaa92426877b022e612cf8'
const BONSAI_COLLECTION_ADDRESS = '0xec9c519d49856fd2f8133a0741b4dbe002ce211b' const BONSAI_COLLECTION_ADDRESS = '0xec9c519d49856fd2f8133a0741b4dbe002ce211b'
describe('Testing nfts', () => { describe('Testing nfts', () => {
beforeEach(() => {
cy.visit('/')
})
it('should load nft leaderboard', () => { it('should load nft leaderboard', () => {
cy.visit('/')
cy.get(getTestSelector('nft-nav')).first().click() cy.get(getTestSelector('nft-nav')).first().click()
cy.get(getTestSelector('nft-nav')).first().should('exist') cy.get(getTestSelector('nft-nav')).first().should('exist')
cy.get(getTestSelector('nft-nav')).first().click() cy.get(getTestSelector('nft-nav')).first().click()
...@@ -49,15 +46,11 @@ describe('Testing nfts', () => { ...@@ -49,15 +46,11 @@ describe('Testing nfts', () => {
cy.get(getTestSelector('nft-bag')).should('exist') cy.get(getTestSelector('nft-bag')).should('exist')
}) })
it('should navigate to the owned nfts page', () => { it('should navigate to and from the owned nfts page', () => {
cy.get(getTestSelector('web3-status-connected')).click() cy.visit('/')
cy.get(getTestSelector('nft-view-self-nfts')).click()
})
it('should close the sidebar when navigating to NFT details', () => {
cy.get(getTestSelector('web3-status-connected')).click() cy.get(getTestSelector('web3-status-connected')).click()
cy.get(getTestSelector('mini-portfolio-nav-nfts')).click() cy.get(getTestSelector('mini-portfolio-navbar')).contains('NFTs').click()
cy.get(getTestSelector('mini-portfolio-nft')).first().click() cy.get(getTestSelector('mini-portfolio-nft')).click()
cy.contains('Buy crypto').should('not.be.visible') cy.get(getTestSelector('mini-portfolio-navbar')).should('not.be.visible')
}) })
}) })
import { getTestSelector } from '../../utils'
describe('disconnect wallet', () => {
it('should clear state', () => {
cy.visit('/swap', { ethereum: 'hardhat' })
cy.get('#swap-currency-input .token-amount-input').clear().type('1')
// Verify wallet is connected
cy.hardhat().then((hardhat) => cy.contains(hardhat.wallet.address.substring(0, 6)))
cy.contains('Balance:')
// Disconnect the wallet
cy.hardhat().then((hardhat) => cy.contains(hardhat.wallet.address.substring(0, 6)).click())
cy.get(getTestSelector('wallet-disconnect')).click()
// Verify wallet has disconnected
cy.contains('Connect a wallet').should('exist')
cy.get(getTestSelector('navbar-connect-wallet')).contains('Connect')
cy.contains('Connect Wallet')
// Verify swap input is cleared
cy.get('#swap-currency-input .token-amount-input').should('have.value', '')
})
})
describe('connect wallet', () => {
it('should load state', () => {
cy.visit('/swap', { ethereum: 'hardhat', userState: {} })
// Connect the wallet
cy.get(getTestSelector('navbar-connect-wallet')).contains('Connect').click()
cy.contains('MetaMask').click()
// Verify wallet is connected
cy.hardhat().then((hardhat) => cy.contains(hardhat.wallet.address.substring(0, 6)))
cy.contains('Balance:')
})
})
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -95,7 +95,7 @@ export default function MiniPortfolio({ account }: { account: string }) { ...@@ -95,7 +95,7 @@ export default function MiniPortfolio({ account }: { account: string }) {
return ( return (
<Trace section={InterfaceSectionName.MINI_PORTFOLIO}> <Trace section={InterfaceSectionName.MINI_PORTFOLIO}>
<Wrapper> <Wrapper>
<Nav> <Nav data-testid="mini-portfolio-navbar">
{Pages.map(({ title, loggingElementName, key }, index) => { {Pages.map(({ title, loggingElementName, key }, index) => {
if (shouldDisableNFTRoutes && loggingElementName.includes('nft')) return null if (shouldDisableNFTRoutes && loggingElementName.includes('nft')) return null
return ( return (
...@@ -105,19 +105,14 @@ export default function MiniPortfolio({ account }: { account: string }) { ...@@ -105,19 +105,14 @@ export default function MiniPortfolio({ account }: { account: string }) {
element={loggingElementName} element={loggingElementName}
key={index} key={index}
> >
<NavItem <NavItem onClick={() => setCurrentPage(index)} active={currentPage === index} key={key}>
data-testid={`mini-portfolio-nav-${key}`}
onClick={() => setCurrentPage(index)}
active={currentPage === index}
key={`Mini Portfolio page ${index}`}
>
{title} {title}
</NavItem> </NavItem>
</TraceEvent> </TraceEvent>
) )
})} })}
</Nav> </Nav>
<PageWrapper> <PageWrapper data-testid="mini-portfolio-page">
<Page account={account} /> <Page account={account} />
</PageWrapper> </PageWrapper>
</Wrapper> </Wrapper>
......
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