Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ltthienn committed Aug 16, 2023
1 parent 742940e commit ee49f1a
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 146 deletions.
1 change: 1 addition & 0 deletions .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
network: ['Ethereum', 'Arbitrum','Optimism', 'Avalanche', 'BNB']
steps:
Expand Down
3 changes: 2 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import synpressPlugins from '@synthetixio/synpress/plugins'
import { defineConfig } from 'cypress'

export default defineConfig({
projectId: '4x4jf8',
component: {
devServer: {
framework: 'create-react-app',
Expand All @@ -22,6 +23,6 @@ export default defineConfig({
require('@cypress/grep/src/plugin')(config)
synpressPlugins(on, config)
},
specPattern: 'cypress/e2e/specs/*.e2e.cy.ts',
specPattern: 'cypress/e2e/specs/*.e2e.cy.ts'
},
})
110 changes: 18 additions & 92 deletions cypress/e2e/pages/swap-page.po.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SwapPageLocators, TokenCatalogLocators } from "../selectors/selectors.cy"
import { NetworkLocators, SwapPageLocators, TokenCatalogLocators, WalletLocators } from "../selectors/selectors.cy"

export interface myCallbackType<T> {
(myArgument: T): void
Expand Down Expand Up @@ -28,6 +28,22 @@ export const SwapPage = {
cy.getContent(SwapPageLocators.dropdownTokenOut, text)
},

connectWallet() {
cy.get(WalletLocators.btnConnectWallet).should('be.visible').click()
cy.connectWallet()
},

getStatusConnectedWallet() {
cy.get(WalletLocators.statusConnected, { timeout: 10000 }).should('be.visible')
}

}

export class Network {
selectNetwork(network: string) {
cy.get(NetworkLocators.btnSelectNetwork, { timeout: 30000 }).should('be.visible').click()
cy.get(NetworkLocators.btnNetwork).contains(network).click({ force: true })
}
}

export class TokenCatalog {
Expand Down Expand Up @@ -86,94 +102,4 @@ export class TokenCatalog {
cy.getContent(TokenCatalogLocators.lblNotFound, text)
}

}

export enum tag {
smoke = 'smoke',
regression = 'regression',
}

export const TOKEN_SYMBOLS = {
'Ethereum': ['BAND', 'DAI', 'USDT', 'USDC'],
'Arbitrum': ['ANGLE', 'DAI', 'USDT', 'USDC.e'],
'Optimism': ['BOB', 'DAI', 'USDT', 'USDC'],
'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e'],
'BNB': ['RICE', 'DAI', 'USDT', 'USDC']
}

export const UNWHITE_LIST_TOKENS = {
"Ethereum":
[
{
name: 'SCOOBY',
address: '0xAd497eE6a70aCcC3Cbb5eB874e60d87593B86F2F',
},
{
name: 'UNIBOT',
address: '0x25127685dc35d4dc96c7feac7370749d004c5040',
},
{
name: 'BGB',
address: '0x19de6b897ed14a376dda0fe53a5420d2ac828a28',
},
],
"Arbitrum": [
{
name: 'OHM',
address: '0xf0cb2dc0db5e6c66b9a70ac27b06b878da017028',
},
{
name: 'GBL',
address: '0xe9a264e9d45ff72e1b4a85d77643cdbd4c950207',
},
{
name: 'Y2K',
address: '0x65c936f008bc34fe819bce9fa5afd9dc2d49977f',
},
],
"Optimism":
[
{
name: 'CHI',
address: '0xca0e54b636db823847b29f506bffee743f57729d',
},
{
name: 'ACX',
address: '0xFf733b2A3557a7ed6697007ab5D11B79FdD1b76B',
},
{
name: 'PSP',
address: '0xd3594e879b358f430e20f82bea61e83562d49d48',
},
],
"Avalanche":
[
{
name: 'RADIO',
address: '0x02bfd11499847003de5f0f5aa081c43854d48815',
},
{
name: 'EUROC',
address: '0xc891eb4cbdeff6e073e859e987815ed1505c2acd',
},
{
name: 'MELD',
address: '0x333000333b26ee30214b4af6419d9ab07a450400',
},
],
"BNB":
[
{
name: 'TUSD',
address: '0x40af3827f39d0eacbf4a168f8d4ee67c121d11c9',
},
{
name: 'ARA',
address: '0x5542958fa9bd89c96cb86d1a6cb7a3e644a3d46e',
},
{
name: 'FLASH',
address: '0xc3111096b3b46873393055dea14036ea603cfa95',
}
],
}
}
93 changes: 93 additions & 0 deletions cypress/e2e/selectors/constants.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
export const unListedToken = ['KNNC', 'KCCN']
export const noResultsText = "No results found."
export const noTokensText = "Select a token"

export enum TAG {
smoke = 'smoke',
regression = 'regression',
}

export const TOKEN_SYMBOLS = {
'Ethereum': ['BAND', 'DAI', 'USDT', 'USDC'],
'Arbitrum': ['ANGLE', 'DAI', 'USDT', 'USDC.e'],
'Optimism': ['BOB', 'DAI', 'USDT', 'USDC'],
'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e'],
'BNB': ['RICE', 'DAI', 'USDT', 'USDC']
}

export const UNWHITE_LIST_TOKENS = {
"Ethereum":
[
{
name: 'SCOOBY',
address: '0xAd497eE6a70aCcC3Cbb5eB874e60d87593B86F2F',
},
{
name: 'UNIBOT',
address: '0x25127685dc35d4dc96c7feac7370749d004c5040',
},
{
name: 'BGB',
address: '0x19de6b897ed14a376dda0fe53a5420d2ac828a28',
},
],
"Arbitrum": [
{
name: 'OHM',
address: '0xf0cb2dc0db5e6c66b9a70ac27b06b878da017028',
},
{
name: 'GBL',
address: '0xe9a264e9d45ff72e1b4a85d77643cdbd4c950207',
},
{
name: 'Y2K',
address: '0x65c936f008bc34fe819bce9fa5afd9dc2d49977f',
},
],
"Optimism":
[
{
name: 'CHI',
address: '0xca0e54b636db823847b29f506bffee743f57729d',
},
{
name: 'ACX',
address: '0xFf733b2A3557a7ed6697007ab5D11B79FdD1b76B',
},
{
name: 'PSP',
address: '0xd3594e879b358f430e20f82bea61e83562d49d48',
},
],
"Avalanche":
[
{
name: 'RADIO',
address: '0x02bfd11499847003de5f0f5aa081c43854d48815',
},
{
name: 'EUROC',
address: '0xc891eb4cbdeff6e073e859e987815ed1505c2acd',
},
{
name: 'MELD',
address: '0x333000333b26ee30214b4af6419d9ab07a450400',
},
],
"BNB":
[
{
name: 'TUSD',
address: '0x40af3827f39d0eacbf4a168f8d4ee67c121d11c9',
},
{
name: 'ARA',
address: '0x5542958fa9bd89c96cb86d1a6cb7a3e644a3d46e',
},
{
name: 'FLASH',
address: '0xc3111096b3b46873393055dea14036ea603cfa95',
}
],
}
50 changes: 24 additions & 26 deletions cypress/e2e/specs/connect-wallet.e2e.cy.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
import { tag } from '../pages/swap-page.po.cy'
import { NetworkLocators, SwapPageLocators, WalletLocators } from '../selectors/selectors.cy'
import { Network, SwapPage } from '../pages/swap-page.po.cy'
import { TAG } from '../selectors/constants.cy'

const network_env = Cypress.env('NETWORK')
const mainPage = `swap/${network_env}`.toLowerCase()
const url = `swap/${network_env}`.toLowerCase()

describe('Metamask Extension tests', { tags: tag.regression }, () => {
beforeEach(() => {
cy.visit('/' + mainPage)
cy.get(SwapPageLocators.btnSkipTutorial, { timeout: 30000 }).should('be.visible').click()
cy.get(WalletLocators.btnConnectWallet).should('be.visible').click()
cy.connectWallet()
})
const wallet = new Network()

it('Redirects to swap page when a user has already connected a wallet', () => {
cy.acceptMetamaskAccess()
cy.get(WalletLocators.statusConnected, { timeout: 10000 }).should('be.visible')
cy.url().should('include', '/swap')
})
describe('Metamask Extension tests', { tags: TAG.regression }, () => {
beforeEach(() => {
SwapPage.open(url)
SwapPage.connectWallet()
})

it('Should approve permission to switch network', () => {
if (network_env !== 'Ethereum') {
cy.get(WalletLocators.statusConnected, { timeout: 10000 }).should('be.visible')
cy.get(NetworkLocators.btnSelectNetwork, { timeout: 30000 }).should('be.visible').click()
cy.get(NetworkLocators.btnNetwork).contains(network_env).click({ force: true })
cy.allowMetamaskToAddAndSwitchNetwork().then(approved => {
expect(approved).to.be.true
})
}
cy.url().should('include', mainPage)
})
it('Redirects to swap page when a user has already connected a wallet', () => {
cy.acceptMetamaskAccess()
SwapPage.getStatusConnectedWallet()
cy.url().should('include', '/swap')
})

it('Should approve permission to switch network', () => {
if (network_env !== 'Ethereum') {
SwapPage.getStatusConnectedWallet()
wallet.selectNetwork(network_env)
cy.allowMetamaskToAddAndSwitchNetwork().then(approved => {
expect(approved).to.be.true
})
}
})
})
13 changes: 7 additions & 6 deletions cypress/e2e/specs/intercept.e2e.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import { SwapPage, tag } from "../pages/swap-page.po.cy"
import { SwapPage } from "../pages/swap-page.po.cy"
import { TAG } from "../selectors/constants.cy"
import { HeaderLocators } from "../selectors/selectors.cy"

const network_env = Cypress.env('NETWORK')
const url = `swap/${network_env}`.toLowerCase()

describe('Intercept', { tags: tag.regression }, () => {
describe('Intercept', { tags: TAG.regression }, () => {
beforeEach(() => {
SwapPage.open(url)
})
describe('Swap', { tags: tag.smoke }, () => {
describe('Swap', { tags: TAG.smoke }, () => {
it('Should get route successfully', () => {
cy.intercept('GET', '**/routes?**').as('get-route')
cy.wait('@get-route', { timeout: 20000 }).its('response.statusCode').should('be.oneOf', [200, 404, 408])
Expand All @@ -25,7 +26,7 @@ describe('Intercept', { tags: tag.regression }, () => {
cy.get(HeaderLocators.lblPools).click({ force: true })
cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-pool-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-block', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-block', { timeout: 60000 }).its('response.statusCode').should('equal', 200)
})
})

Expand All @@ -52,8 +53,8 @@ describe('Intercept', { tags: tag.regression }, () => {
cy.wait('@get-pool-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
}
cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-block', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-block', { timeout: 60000 }).its('response.statusCode').should('equal', 200)
})
})
})
})
})
Loading

0 comments on commit ee49f1a

Please sign in to comment.