Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA-61 | E2E - Add wallet connection tests #2355

Merged
merged 17 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/pages/cross-chain.po.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const CrossChain = {
},

checkLoadedPage() {
return cy.get(CrossChainLocators.rechartsSurface, { timeout: 20000 }).should(() => { }).then($obj => {
return cy.get(CrossChainLocators.rechartsSurface, { timeout: 20000 }).should('be.visible').then($obj => {
if ($obj.length > 0) {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/pages/swap-page.po.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class TokenCatalog {
}

getWhitelistTokens(list: myCallbackType<string[]>) {
cy.getList(TokenCatalogLocators.lblRowInWhiteList, list)
cy.getList(TokenCatalogLocators.lblTokenSymbol, list)
}

getNoResultsFound(text: myCallbackType<string>) {
Expand Down
10 changes: 5 additions & 5 deletions cypress/e2e/selectors/constants.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export enum TAG {
}

export const TOKEN_SYMBOLS = {
'Ethereum': ['BAND', 'DAI', 'USDT', 'USDC', '1INCH'],
'Arbitrum': ['ANGLE', 'DAI', 'USDT', 'USDC.e', 'MAI'],
'Optimism': ['BOB', 'DAI', 'USDT', 'USDC', 'MAI'],
'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e', 'MAI'],
'BNB': ['RICE', 'DAI', 'USDT', 'USDC', 'MAI']
'Ethereum': ['BAND', 'ETH', 'USDT', 'USDC', '1INCH'],
'Arbitrum': ['ANGLE', 'ARB', 'USDT', 'USDC.e', 'BOB'],
'Optimism': ['BOND', 'ETH', 'USDT', 'USDC', 'BOB'],
'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e', 'BUSD.e'],
'BNB': ['RICE', 'BUSD', 'USDT', 'USDC', 'BOB']
}

export const NETWORK_LIST = ['Ethereum', 'Arbitrum', 'Optimism', 'Avalanche', 'BNB Chain', 'Polygon PoS', 'Fantom', 'Linea', 'Base']
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/selectors/selectors.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const TokenCatalogLocators = {
txtToken: '[data-testid=token-search-input]',
lblFavoriteToken: '[data-testid=favorite-token]',
lblRowInWhiteList: '[data-testid=token-item]',
lblTokenSymbol: '[data-testid=token-symbol]',
lblNotFound: '[data-testid=no-token-result]',
iconFavorite: '[data-testid=button-favorite-token]',
iconRemoveImportedToken: '[data-testid=button-remove-import-token]',
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/specs/connect-wallet.e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Metamask Extension tests', { tags: TAG.regression }, () => {
SwapPage.connectWallet()
})

it('Redirects to swap page when a user has already connected a wallet', () => {
it('Redirects to swap page when a user has already connected a wallet', { tags: TAG.smoke }, () => {
cy.acceptMetamaskAccess()
SwapPage.getStatusConnectedWallet()
cy.url().should('include', '/swap')
Expand Down
16 changes: 14 additions & 2 deletions cypress/e2e/specs/cross-chain.e2e.cy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { CrossChain } from "../pages/cross-chain.po.cy"
import { SwapPage } from "../pages/swap-page.po.cy"
import { DEFAULT_URL, NETWORK, TAG } from "../selectors/constants.cy"

import { DEFAULT_NETWORK, DEFAULT_URL, NETWORK, TAG } from "../selectors/constants.cy"

describe(`Cross-chain on ${NETWORK}`, { tags: TAG.regression }, () => {
beforeEach(() => {
SwapPage.open(DEFAULT_URL)
SwapPage.connectWallet()
SwapPage.getStatusConnectedWallet()

SwapPage.goToCrossChain()
CrossChain.checkLoadedPage().then((checked) => {
if (checked === true) {
Expand All @@ -18,6 +20,16 @@ describe(`Cross-chain on ${NETWORK}`, { tags: TAG.regression }, () => {
it('The network should be changed successfully', () => {
const networkIn = CrossChain.changeNetwork([NETWORK])
CrossChain.selectNetworkIn(networkIn)
if (networkIn != DEFAULT_NETWORK) {
cy.allowMetamaskToAddAndSwitchNetwork().then(approved => {
expect(approved).to.be.true
})
}
else {
cy.allowMetamaskToSwitchNetwork().then(approved => {
expect(approved).to.be.true
})
}
CrossChain.getCurrentNetworkIn().then((currentNetworkIn) => {
expect(currentNetworkIn).to.equal(networkIn)
})
Expand Down
48 changes: 33 additions & 15 deletions cypress/e2e/specs/limit-order.e2e.cy.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
import { LimitOder } from "../pages/limit-order.po.cy"
import { SwapPage, TokenCatalog } from "../pages/swap-page.po.cy"
import { DEFAULT_URL, NETWORK, NORESULTS_TEXT, NOTOKENS_TEXT, TAG, TOKEN_SYMBOLS, UNWHITELIST_SYMBOL_TOKENS, UNWHITELIST_TOKENS } from "../selectors/constants.cy"
import { Network, SwapPage, TokenCatalog } from "../pages/swap-page.po.cy"
import { DEFAULT_URL, NETWORK, NORESULTS_TEXT, TAG, TOKEN_SYMBOLS, UNWHITELIST_SYMBOL_TOKENS } from "../selectors/constants.cy"

const tokenSymbols = TOKEN_SYMBOLS[NETWORK]

const tokenCatalog = new TokenCatalog();

const netw = new Network()

describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => {
beforeEach(() => {
SwapPage.open(DEFAULT_URL)
SwapPage.goToLimitOrder()
LimitOder.checkGetStartedDisplay().then((checked) => {
if (checked === true) {
LimitOder.clickGetStarted()
}
})
SwapPage.connectWallet()
SwapPage.getStatusConnectedWallet()
})

describe('Add/remove/select token with favorite tokens list', () => {
beforeEach(() => {
if (NETWORK === 'BNB' || NETWORK === 'Ethereum') {
netw.selectNetwork(NETWORK)
cy.allowMetamaskToSwitchNetwork().then(approved => {
expect(approved).to.be.true
})
} else {
cy.changeMetamaskNetwork(NETWORK)
}
SwapPage.goToLimitOrder()
LimitOder.checkGetStartedDisplay().then((checked) => {
if (checked === true) {
LimitOder.clickGetStarted()
}
})
})
it('Should be added, selected and removed favorite token sell', () => {
LimitOder.selectTokenSell().addFavoriteToken([tokenSymbols[0], tokenSymbols[4]])
tokenCatalog.getFavoriteTokens((list) => {
Expand All @@ -34,7 +48,16 @@ describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => {
expect(list).not.to.include.members([tokenSymbols[0]])
})
})

})
describe('Add/remove/select token with favorite tokens list', () => {
beforeEach(() => {
SwapPage.goToLimitOrder()
LimitOder.checkGetStartedDisplay().then((checked) => {
if (checked === true) {
LimitOder.clickGetStarted()
}
})
})
it('Should be added, selected and removed favorite token buy', () => {
LimitOder.selectTokenBuy().addFavoriteToken([tokenSymbols[0], tokenSymbols[4]])
tokenCatalog.getFavoriteTokens((list) => {
Expand All @@ -51,9 +74,7 @@ describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => {
expect(list).not.to.include.members([tokenSymbols[0]])
})
})
})

describe('Select token by symbol', () => {
it('Should be selected token sell by symbol successfully', () => {
LimitOder.selectTokenSell().selectTokenBySymbol(tokenSymbols[0])
LimitOder.getCurrentTokenSell((text) => {
Expand Down Expand Up @@ -81,18 +102,15 @@ describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => {
expect(text).to.equal(NORESULTS_TEXT)
})
})
})

describe('Sell rate', () => {
it('Able to set selling rate by number', () => {
LimitOder.setSellingRate('1.2345..67')
LimitOder.getSellingRate().then((value) => {
cy.wrap(value).should('eq', '1.234567')
})
})
})

describe('Messages', () => {

it('Verify error message when insufficient balance', () => {
LimitOder.getBalanceIn((text) => {
LimitOder.setAmountIn(String(Number(text) + 1))
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/specs/swap-page.e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const tokenCatalog = new TokenCatalog();
describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => {
beforeEach(() => {
SwapPage.open(DEFAULT_URL)
SwapPage.connectWallet()
SwapPage.getStatusConnectedWallet()
})

describe('Select token in favorite tokens list', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/connectWalletCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ declare global {

Cypress.Commands.add('connectWallet', () => {
// feature changed => temporary comment
// cy.get(WalletLocators.chkAcceptTerm).click()
cy.get(WalletLocators.chkAcceptTerm).click()
cy.get(WalletLocators.btnMetaMask).click()
})
2 changes: 1 addition & 1 deletion src/components/SearchModal/CurrencyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function CurrencyRow({
<Flex alignItems="center" style={{ gap: 8 }}>
<CurrencyLogo currency={currency} size={'24px'} />
<Column gap="2px">
<Text title={currency.name} fontWeight={500}>
<Text title={currency.name} fontWeight={500} data-testid="token-symbol">
{customName || symbol}
</Text>
<DescText>{showImported ? balanceComponent : nativeCurrency?.name}</DescText>
Expand Down
Loading