From 8d51d704d36252f3942dc15e2f2219a166aa2d54 Mon Sep 17 00:00:00 2001 From: ltthienn Date: Tue, 1 Aug 2023 10:44:06 +0700 Subject: [PATCH] update e2e tests --- .github/workflows/cypress.yml | 2 +- .github/workflows/schedule.yml | 5 +- cypress.config.ts | 8 +- cypress/e2e/pages/swap-page.po.cy.ts | 93 +++++++-- .../specs/arbitrum/intercept.e2e-spec.cy.ts | 58 ------ .../specs/arbitrum/swap-page.e2e-spec.cy.ts | 195 ------------------ cypress/e2e/specs/connect-wallet.e2e.cy.ts | 32 +++ cypress/e2e/specs/intercept.e2e.cy.ts | 61 ++++++ .../specs/optimism/intercept.e2e-spec.cy.ts | 58 ------ .../specs/optimism/swap-page.e2e-spec.cy.ts | 195 ------------------ cypress/e2e/specs/swap-page.e2e-spec.cy.ts | 190 ----------------- cypress/e2e/specs/swap-page.e2e.cy.ts | 185 +++++++++++++++++ cypress/support/selectTokenCommands.ts | 15 +- package.json | 4 +- 14 files changed, 372 insertions(+), 729 deletions(-) delete mode 100644 cypress/e2e/specs/arbitrum/intercept.e2e-spec.cy.ts delete mode 100644 cypress/e2e/specs/arbitrum/swap-page.e2e-spec.cy.ts create mode 100644 cypress/e2e/specs/connect-wallet.e2e.cy.ts create mode 100644 cypress/e2e/specs/intercept.e2e.cy.ts delete mode 100644 cypress/e2e/specs/optimism/intercept.e2e-spec.cy.ts delete mode 100644 cypress/e2e/specs/optimism/swap-page.e2e-spec.cy.ts delete mode 100644 cypress/e2e/specs/swap-page.e2e-spec.cy.ts create mode 100644 cypress/e2e/specs/swap-page.e2e.cy.ts diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 3dff9aea03..c72a026cf8 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -110,7 +110,7 @@ jobs: run: |+ #!/bin/bash yarn preview & - yarn test-e2e + yarn test-e2e -e grepTags=smoke,NETWORK=Ethereum env: DISPLAY: :0.0 diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index dca4577415..ef062b839d 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -8,6 +8,9 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + network: ['Ethereum', 'Arbitrum','Optimism', 'Avalanche', 'BNB'] steps: - name: Trigger Code Checkout uses: actions/checkout@v3 @@ -42,7 +45,7 @@ jobs: - name: Run Cypress Test run: |+ #!/bin/bash - yarn test-schedule + yarn test-schedule -e grepTags=regression,NETWORK=${{ matrix.network }} env: DISPLAY: :0.0 diff --git a/cypress.config.ts b/cypress.config.ts index a3ba380d9f..48c4883b89 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -12,12 +12,16 @@ export default defineConfig({ chromeWebSecurity: true, viewportWidth: 1920, viewportHeight: 1080, + env: { + grepFilterSpecs:true, + grepOmitFiltered:true + }, e2e: { setupNodeEvents(on, config) { + // eslint-disable-next-line @typescript-eslint/no-var-requires require('@cypress/grep/src/plugin')(config) synpressPlugins(on, config) }, - // specPattern: 'cypress/e2e/**/avalanche/*.e2e-spec.cy.ts', - specPattern: 'cypress/e2e/specs/swap-page.e2e-spec.cy.ts', + specPattern: 'cypress/e2e/specs/*.e2e.cy.ts', }, }) diff --git a/cypress/e2e/pages/swap-page.po.cy.ts b/cypress/e2e/pages/swap-page.po.cy.ts index 9798720cb6..9abcce4445 100644 --- a/cypress/e2e/pages/swap-page.po.cy.ts +++ b/cypress/e2e/pages/swap-page.po.cy.ts @@ -11,7 +11,7 @@ export function getText(selector: string, callback: any) { } export function getTokenList(selector: string, callback: any) { - let arr: string[] = [] + const arr: string[] = [] const listToken = cy.get(selector) listToken .each(item => { @@ -22,24 +22,32 @@ export function getTokenList(selector: string, callback: any) { }) } +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 = { - "bnb": - [ - { - name: 'TUSD', - address: '0x40af3827f39d0eacbf4a168f8d4ee67c121d11c9', - }, - { - name: 'ARA', - address: '0x5542958fa9bd89c96cb86d1a6cb7a3e644a3d46e', - }, + "Ethereum": + [ + { + name: 'SCOOBY', + address: '0xAd497eE6a70aCcC3Cbb5eB874e60d87593B86F2F', + }, + { + name: 'UNIBOT', + address: '0x25127685dc35d4dc96c7feac7370749d004c5040', + }, + { + name: 'BGB', + address: '0x19de6b897ed14a376dda0fe53a5420d2ac828a28', + }, + ], + "Arbitrum": [ { - name: 'FLASH', - address: '0xc3111096b3b46873393055dea14036ea603cfa95', - } - ], - "arbitrum": [ - { name: 'OHM', address: '0xf0cb2dc0db5e6c66b9a70ac27b06b878da017028', }, @@ -51,7 +59,50 @@ export const UNWHITE_LIST_TOKENS = { 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', + } + ], +} \ No newline at end of file diff --git a/cypress/e2e/specs/arbitrum/intercept.e2e-spec.cy.ts b/cypress/e2e/specs/arbitrum/intercept.e2e-spec.cy.ts deleted file mode 100644 index 010a76d894..0000000000 --- a/cypress/e2e/specs/arbitrum/intercept.e2e-spec.cy.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { tag } from '../../pages/swap-page.po.cy' -import { homePage, menu, network } from '../../selectors/selectors.cy' - -const mainPage = 'swap/arbitrum' -describe('Intercept', { tags: tag.regression }, () => { - beforeEach(() => { - cy.visit('/' + mainPage) - cy.url().should('include', mainPage) - cy.clickButton(homePage.skipTutorial) - }) - describe('Swap', () => { - 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]) - }) - }) - - describe('Pools', () => { - it('Should get pool, farm list successfully', () => { - cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') - cy.intercept('GET', '**/pools?**').as('get-pool-list') - cy.intercept('GET', '**/block?**').as('get-block') - cy.get(menu.earnMenu).click({ force: true }) - cy.get(menu.poolMenu).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) - }) - }) - - describe('My Pools', () => { - it('Should get farm list successfully', () => { - cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') - cy.get(menu.earnMenu).click({ force: true }) - cy.get(menu.myPoolMenu).click({ force: true }) - cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200) - }) - }) - - describe('Farms', () => { - it('Should get pool, farm list successfully', () => { - cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') - cy.intercept('GET', '**/pools?**').as('get-pool-list') - cy.intercept('GET', '**/block?**').as('get-block') - cy.get(menu.earnMenu).click({ force: true }) - cy.get(menu.farmMenu).click({ force: true }) - cy.get('[data-testid=farm-block]') - .should(_ => {}) - .then($list => { - if ($list.length) { - 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) - }) - }) - }) -}) diff --git a/cypress/e2e/specs/arbitrum/swap-page.e2e-spec.cy.ts b/cypress/e2e/specs/arbitrum/swap-page.e2e-spec.cy.ts deleted file mode 100644 index 9d223919ee..0000000000 --- a/cypress/e2e/specs/arbitrum/swap-page.e2e-spec.cy.ts +++ /dev/null @@ -1,195 +0,0 @@ -import { homePage, tab, token } from '../../selectors/selectors.cy' - -const mainPage = 'swap/arbitrum' -const tokenSymbol = ['ARB', 'DAI', 'USDT', 'USDC.e'] -const unListedToken = ['KNNC', 'KCCN'] - -const unWhiteListedToken = { - OHM: { - name: 'OHM', - address: '0xf0cb2dc0db5e6c66b9a70ac27b06b878da017028', - }, - GBL: { - name: 'GBL', - address: '0xe9a264e9d45ff72e1b4a85d77643cdbd4c950207', - }, - Y2K: { - name: 'Y2K', - address: '0x65c936f008bc34fe819bce9fa5afd9dc2d49977f', - }, -} - -describe('Token Catalog', { tags: 'regression' }, () => { - beforeEach(() => { - cy.visit('/' + mainPage) - cy.url().should('include', mainPage) - cy.clickButton(homePage.skipTutorial) - }) - describe('Select token in favorite tokens list', () => { - it('Should be selected tokenIn in favorite tokens list successfully', () => { - cy.clickButton(token.tokenIn) - cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenIn, tokenSymbol[1]) - cy.verifyURL(tokenSymbol[1], '') - }) - - it('Should be selected tokenOut in favorite tokens list successfully', () => { - cy.clickButton(token.tokenOut) - cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenOut, tokenSymbol[1]) - cy.verifyURL('', tokenSymbol[1]) - }) - }) - - describe('Remove/add token with favorite tokens list', () => { - it('Should be removed tokenIn from favorite tokens list', () => { - cy.clickButton(token.tokenIn) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], true) - cy.removeTokenInFavoriteTokensList(tokenSymbol[3]) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], false) - cy.input(token.inputToken, tokenSymbol[3]) - cy.verifyIcon('false') - }) - - it('Should be added tokenIn to favorite tokens list', () => { - cy.clickButton(token.tokenIn) - cy.addTokenToFavoriteTokensList(tokenSymbol[0]) - cy.verifyIcon('true') - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[0]], true) - }) - - it('Should be removed tokenOut from favorite tokens list', () => { - cy.clickButton(token.tokenOut) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], true) - cy.removeTokenInFavoriteTokensList(tokenSymbol[2]) - cy.wait(2000) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], false) - cy.input(token.inputToken, tokenSymbol[2]) - cy.verifyIcon('false') - }) - - it('Should be added tokenOut to favorite tokens list', () => { - cy.clickButton(token.tokenOut) - cy.addTokenToFavoriteTokensList(tokenSymbol[0]) - cy.wait(2000) - cy.verifyIcon('true') - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[0]], true) - }) - }) - - describe('Select token by symbol', () => { - it('Should be selected tokenIn by symbol successfully', () => { - cy.clickButton(token.tokenIn) - cy.selectTokenBySymbol(token.inputToken, tokenSymbol[0]) - cy.verifySelectedToken(token.tokenIn, tokenSymbol[0]) - cy.verifyURL(tokenSymbol[0], '') - }) - - it('Should be selected tokenOut by symbol successfully', () => { - cy.clickButton(token.tokenOut) - cy.selectTokenBySymbol(token.inputToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenOut, tokenSymbol[1]) - cy.verifyURL('', tokenSymbol[1]) - }) - - it('Should be unselected tokenIn not exist in whitelist', () => { - cy.clickButton(token.tokenIn) - cy.input(token.inputToken, unListedToken[0]) - cy.verifyNoResultFound() - }) - - it('Should be unselected tokenOut not exist in whitelist', () => { - cy.clickButton(token.tokenOut) - cy.input(token.inputToken, unListedToken[1]) - cy.verifyNoResultFound() - }) - }) - - describe('Import token', () => { - it('Should be imported tokenIn successfully', () => { - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.OHM.address) - cy.verifySelectedToken(token.tokenIn, unWhiteListedToken.OHM.name) - cy.clickButton(token.tokenIn) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.OHM.name], true) - }) - - it('Should be imported tokenOut successfully', () => { - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.GBL.address) - cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.GBL.name) - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.GBL.name], true) - }) - }) - - describe('Delete token', () => { - it('Should be deleted the imported tokenIn successfully', () => { - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.OHM.address) - cy.clickButton(token.tokenIn) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.OHM.name], true) - cy.deleteImportedToken(unWhiteListedToken.OHM.address) - cy.verifyNoResultFound() - }) - - it('Should be deleted the imported tokenOut successfully', () => { - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.OHM.address) - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.OHM.name], true) - cy.deleteImportedToken(unWhiteListedToken.OHM.address) - cy.verifyNoResultFound() - }) - - it('Should be cleared all the imported tokenIn successfully', () => { - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.OHM.address) - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.GBL.address) - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.Y2K.address) - cy.clickButton(token.tokenIn) - cy.clickButton(tab.import) - cy.verifyValueInList( - token.rowInWhiteList, - [unWhiteListedToken.OHM.name, unWhiteListedToken.GBL.name, unWhiteListedToken.Y2K.name], - true, - ) - cy.clearAllImportedTokens() - cy.verifyNoResultFound() - }) - - it('Should be cleared all the imported tokenOut successfully', () => { - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.OHM.address) - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.GBL.address) - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.Y2K.address) - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList( - token.rowInWhiteList, - [unWhiteListedToken.OHM.name, unWhiteListedToken.GBL.name, unWhiteListedToken.Y2K.name], - true, - ) - cy.clearAllImportedTokens() - cy.verifyNoResultFound() - }) - }) - - describe('E2E Token Catalog', () => { - it('Should be selected tokenIn and tokenOut to swap', () => { - //select tokenIn - cy.clickButton(token.tokenIn) - cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenIn, tokenSymbol[1]) - //select tokenOut - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.OHM.address) - cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.OHM.name) - cy.verifyURL(tokenSymbol[1], unWhiteListedToken.OHM.name) - //delete imported tokenOut - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.OHM.name], true) - cy.deleteImportedToken(unWhiteListedToken.OHM.address) - cy.verifyNoResultFound() - cy.get(token.tokenOut).should('include.text', 'Select a token') - }) - }) -}) diff --git a/cypress/e2e/specs/connect-wallet.e2e.cy.ts b/cypress/e2e/specs/connect-wallet.e2e.cy.ts new file mode 100644 index 0000000000..430dd91362 --- /dev/null +++ b/cypress/e2e/specs/connect-wallet.e2e.cy.ts @@ -0,0 +1,32 @@ +import { tag } from '../pages/swap-page.po.cy' +import { homePage, network, wallet } from '../selectors/selectors.cy' + +const network_env = Cypress.env('NETWORK') +const mainPage = `swap/${network_env}`.toLowerCase() + +describe('Metamask Extension tests', { tags: tag.regression }, () => { + beforeEach(() => { + cy.visit('/' + mainPage) + cy.clickButton(homePage.skipTutorial) + cy.get(wallet.btnConnectWallet).should('be.visible').click() + cy.connectWallet() + }) + + it('Redirects to swap page when a user has already connected a wallet', () => { + cy.acceptMetamaskAccess() + cy.get(wallet.statusConnected, { timeout: 10000 }).should('be.visible') + cy.url().should('include', '/swap') + }) + + it('Should approve permission to switch network', () => { + if (network_env !== 'Ethereum') { + cy.get(wallet.statusConnected, { timeout: 10000 }).should('be.visible') + cy.clickButton(network.btnSelectNetwork) + cy.get(network.btnNetwork).contains(network_env).click({ force: true }) + cy.allowMetamaskToAddAndSwitchNetwork().then(approved => { + expect(approved).to.be.true + }) + } + cy.url().should('include', mainPage) + }) +}) diff --git a/cypress/e2e/specs/intercept.e2e.cy.ts b/cypress/e2e/specs/intercept.e2e.cy.ts new file mode 100644 index 0000000000..c4d78faea6 --- /dev/null +++ b/cypress/e2e/specs/intercept.e2e.cy.ts @@ -0,0 +1,61 @@ +/* eslint-disable @typescript-eslint/no-empty-function */ +import { tag } from "../pages/swap-page.po.cy" +import { homePage, menu } from "../selectors/selectors.cy" + +const network_env = Cypress.env('NETWORK') +const mainPage = `swap/${network_env}`.toLowerCase() + +describe('Intercept', { tags: tag.regression }, () => { + beforeEach(() => { + cy.visit('/' + mainPage) + cy.url().should('include', mainPage) + cy.clickButton(homePage.skipTutorial) + }) + 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]) + }) + }) + + describe('Pools', () => { + it('Should get pool, farm list successfully', () => { + cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') + cy.intercept('GET', '**/pools?**').as('get-pool-list') + cy.intercept('GET', '**/block?**').as('get-block') + cy.get(menu.earnMenu).click({ force: true }) + cy.get(menu.poolMenu).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) + }) + }) + + describe('My Pools', () => { + it('Should get farm list successfully', () => { + cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') + cy.get(menu.earnMenu).click({ force: true }) + cy.get(menu.myPoolMenu).click({ force: true }) + cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200) + }) + }) + + describe('Farms', () => { + it('Should get pool, farm list successfully', () => { + cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') + cy.intercept('GET', '**/pools?**').as('get-pool-list') + cy.intercept('GET', '**/block?**').as('get-block') + cy.get(menu.earnMenu).click({ force: true }) + cy.get(menu.farmMenu).click({ force: true }) + cy.get('[data-testid=farm-block]') + .should(_ => {}) + .then($list => { + if ($list.length) { + 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) + }) + }) + }) +}) diff --git a/cypress/e2e/specs/optimism/intercept.e2e-spec.cy.ts b/cypress/e2e/specs/optimism/intercept.e2e-spec.cy.ts deleted file mode 100644 index 35725f3ba8..0000000000 --- a/cypress/e2e/specs/optimism/intercept.e2e-spec.cy.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { tag } from '../../pages/swap-page.po.cy' -import { homePage, menu, network } from '../../selectors/selectors.cy' - -const mainPage = 'swap/optimism' -describe('Intercept', { tags: tag.regression }, () => { - beforeEach(() => { - cy.visit('/' + mainPage) - cy.url().should('include', mainPage) - cy.clickButton(homePage.skipTutorial) - }) - 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]) - }) - }) - - describe('Pools', () => { - it('Should get pool, farm list successfully', () => { - cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') - cy.intercept('GET', '**/pools?**').as('get-pool-list') - cy.intercept('GET', '**/block?**').as('get-block') - cy.get(menu.earnMenu).click({ force: true }) - cy.get(menu.poolMenu).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) - }) - }) - - describe('My Pools', () => { - it('Should get farm list successfully', () => { - cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') - cy.get(menu.earnMenu).click({ force: true }) - cy.get(menu.myPoolMenu).click({ force: true }) - cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200) - }) - }) - - describe('Farms', () => { - it('Should get pool, farm list successfully', () => { - cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') - cy.intercept('GET', '**/pools?**').as('get-pool-list') - cy.intercept('GET', '**/block?**').as('get-block') - cy.get(menu.earnMenu).click({ force: true }) - cy.get(menu.farmMenu).click({ force: true }) - cy.get('[data-testid=farm-block]') - .should(_ => {}) - .then($list => { - if ($list.length) { - 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) - }) - }) - }) -}) diff --git a/cypress/e2e/specs/optimism/swap-page.e2e-spec.cy.ts b/cypress/e2e/specs/optimism/swap-page.e2e-spec.cy.ts deleted file mode 100644 index 16c33c7eaa..0000000000 --- a/cypress/e2e/specs/optimism/swap-page.e2e-spec.cy.ts +++ /dev/null @@ -1,195 +0,0 @@ -import { homePage, tab, token } from '../../selectors/selectors.cy' - -const mainPage = 'swap/optimism' -const tokenSymbol = ['BOB', 'DAI', 'USDT', 'USDC'] -const unListedToken = ['KNNC', 'KCCN'] - -const unWhiteListedToken = { - CHI: { - name: 'CHI', - address: '0xca0e54b636db823847b29f506bffee743f57729d', - }, - ACX: { - name: 'ACX', - address: '0xFf733b2A3557a7ed6697007ab5D11B79FdD1b76B', - }, - PSP: { - name: 'PSP', - address: '0xd3594e879b358f430e20f82bea61e83562d49d48', - }, -} - -describe('Token Catalog', { tags: 'regression' }, () => { - beforeEach(() => { - cy.visit('/optimism') - cy.url().should('include', mainPage) - cy.clickButton(homePage.skipTutorial) - }) - describe('Select token in favorite tokens list', () => { - it('Should be selected tokenIn in favorite tokens list successfully', { tags: 'regression' }, () => { - cy.clickButton(token.tokenIn) - cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenIn, tokenSymbol[1]) - cy.verifyURL(tokenSymbol[1], '') - }) - - it('Should be selected tokenOut in favorite tokens list successfully', { tags: 'regression' }, () => { - cy.clickButton(token.tokenOut) - cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenOut, tokenSymbol[1]) - cy.verifyURL('', tokenSymbol[1]) - }) - }) - - describe('Remove/add token with favorite tokens list', () => { - it('Should be removed tokenIn from favorite tokens list', { tags: 'regression' }, () => { - cy.clickButton(token.tokenIn) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], true) - cy.removeTokenInFavoriteTokensList(tokenSymbol[3]) - cy.wait(2000) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], false) - cy.input(token.inputToken, tokenSymbol[3]) - cy.verifyIcon('false') - }) - - it('Should be added tokenIn to favorite tokens list', { tags: 'regression' }, () => { - cy.clickButton(token.tokenIn) - cy.addTokenToFavoriteTokensList(tokenSymbol[0]) - cy.verifyIcon('true') - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[0]], true) - }) - - it('Should be removed tokenOut from favorite tokens list', { tags: 'regression' }, () => { - cy.clickButton(token.tokenOut) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], true) - cy.removeTokenInFavoriteTokensList(tokenSymbol[2]) - cy.wait(2000) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], false) - cy.input(token.inputToken, tokenSymbol[2]) - cy.verifyIcon('false') - }) - - it('Should be added tokenOut to favorite tokens list', { tags: 'regression' }, () => { - cy.clickButton(token.tokenOut) - cy.addTokenToFavoriteTokensList(tokenSymbol[0]) - cy.verifyIcon('true') - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[0]], true) - }) - }) - - describe('Select token by symbol', () => { - it('Should be selected tokenIn by symbol successfully', { tags: 'regression' }, () => { - cy.clickButton(token.tokenIn) - cy.selectTokenBySymbol(token.inputToken, tokenSymbol[0]) - cy.verifySelectedToken(token.tokenIn, tokenSymbol[0]) - cy.verifyURL(tokenSymbol[0], '') - }) - - it('Should be selected tokenOut by symbol successfully', { tags: 'regression' }, () => { - cy.clickButton(token.tokenOut) - cy.selectTokenBySymbol(token.inputToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenOut, tokenSymbol[1]) - cy.verifyURL('', tokenSymbol[1]) - }) - - it('Should be unselected tokenIn not exist in whitelist', { tags: 'regression' }, () => { - cy.clickButton(token.tokenIn) - cy.input(token.inputToken, unListedToken[0]) - cy.verifyNoResultFound() - }) - - it('Should be unselected tokenOut not exist in whitelist', { tags: 'regression' }, () => { - cy.clickButton(token.tokenOut) - cy.input(token.inputToken, unListedToken[1]) - cy.verifyNoResultFound() - }) - }) - - describe('Import token', () => { - it('Should be imported tokenIn successfully', { tags: 'regression' }, () => { - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.CHI.address) - cy.verifySelectedToken(token.tokenIn, unWhiteListedToken.CHI.name) - cy.clickButton(token.tokenIn) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.CHI.name], true) - }) - - it('Should be imported tokenOut successfully', { tags: 'regression' }, () => { - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.ACX.address) - cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.ACX.name) - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.ACX.name], true) - }) - }) - - describe('Delete token', () => { - it('Should be deleted the imported tokenIn successfully', { tags: 'regression' }, () => { - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.CHI.address) - cy.clickButton(token.tokenIn) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.CHI.name], true) - cy.deleteImportedToken(unWhiteListedToken.CHI.address) - cy.verifyNoResultFound() - }) - - it('Should be deleted the imported tokenOut successfully', { tags: 'regression' }, () => { - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.CHI.address) - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.CHI.name], true) - cy.deleteImportedToken(unWhiteListedToken.CHI.address) - cy.verifyNoResultFound() - }) - - it('Should be cleared all the imported tokenIn successfully', { tags: 'regression' }, () => { - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.CHI.address) - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.ACX.address) - cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.PSP.address) - cy.clickButton(token.tokenIn) - cy.clickButton(tab.import) - cy.verifyValueInList( - token.rowInWhiteList, - [unWhiteListedToken.CHI.name, unWhiteListedToken.ACX.name, unWhiteListedToken.PSP.name], - true, - ) - cy.clearAllImportedTokens() - cy.verifyNoResultFound() - }) - - it('Should be cleared all the imported tokenOut successfully', { tags: 'regression' }, () => { - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.CHI.address) - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.ACX.address) - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.PSP.address) - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList( - token.rowInWhiteList, - [unWhiteListedToken.CHI.name, unWhiteListedToken.ACX.name, unWhiteListedToken.ACX.name], - true, - ) - cy.clearAllImportedTokens() - cy.verifyNoResultFound() - }) - }) - - describe('E2E Token Catalog', () => { - it('Should be selected tokenIn and tokenOut to swap', { tags: ['smoke', 'regression'] }, () => { - //select tokenIn - cy.clickButton(token.tokenIn) - cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenIn, tokenSymbol[1]) - //select tokenOut - cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.CHI.address) - cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.CHI.name) - cy.verifyURL(tokenSymbol[1], unWhiteListedToken.CHI.name) - //delete imported tokenOut - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.CHI.name], true) - cy.deleteImportedToken(unWhiteListedToken.CHI.address) - cy.verifyNoResultFound() - cy.get(token.tokenOut).should('include.text', 'Select a token') - }) - }) -}) diff --git a/cypress/e2e/specs/swap-page.e2e-spec.cy.ts b/cypress/e2e/specs/swap-page.e2e-spec.cy.ts deleted file mode 100644 index 463a051ca3..0000000000 --- a/cypress/e2e/specs/swap-page.e2e-spec.cy.ts +++ /dev/null @@ -1,190 +0,0 @@ -import { UNWHITE_LIST_TOKENS } from "../pages/swap-page.po.cy" -import { homePage, tab, token } from "../selectors/selectors.cy" - - -const mainPage = 'swap/arbitrum' -const tokenSymbol = ['ARB', 'DAI', 'USDT', 'USDC.e'] -const unListedToken = ['KNNC', 'KCCN'] -require('dotenv').config() - -const network = process.env.NETWORK || 'ethereum' -const unWhitelistTokens = UNWHITE_LIST_TOKENS[network] - - - -describe('Token Catalog', { tags: 'regression' }, () => { - beforeEach(() => { - cy.visit('/' + mainPage) - cy.url().should('include', mainPage) - cy.clickButton(homePage.skipTutorial) - }) - describe('Select token in favorite tokens list', () => { - it('Should be selected tokenIn in favorite tokens list successfully', () => { - cy.clickButton(token.tokenIn) - cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenIn, tokenSymbol[1]) - cy.verifyURL(tokenSymbol[1], '') - }) - - it('Should be selected tokenOut in favorite tokens list successfully', () => { - cy.clickButton(token.tokenOut) - cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenOut, tokenSymbol[1]) - cy.verifyURL('', tokenSymbol[1]) - }) - }) - - describe('Remove/add token with favorite tokens list', () => { - it('Should be removed tokenIn from favorite tokens list', () => { - cy.clickButton(token.tokenIn) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], true) - cy.removeTokenInFavoriteTokensList(tokenSymbol[3]) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], false) - cy.input(token.inputToken, tokenSymbol[3]) - cy.verifyIcon('false') - }) - - it('Should be added tokenIn to favorite tokens list', () => { - cy.clickButton(token.tokenIn) - cy.addTokenToFavoriteTokensList(tokenSymbol[0]) - cy.verifyIcon('true') - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[0]], true) - }) - - it('Should be removed tokenOut from favorite tokens list', () => { - cy.clickButton(token.tokenOut) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], true) - cy.removeTokenInFavoriteTokensList(tokenSymbol[2]) - cy.wait(2000) - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], false) - cy.input(token.inputToken, tokenSymbol[2]) - cy.verifyIcon('false') - }) - - it('Should be added tokenOut to favorite tokens list', () => { - cy.clickButton(token.tokenOut) - cy.addTokenToFavoriteTokensList(tokenSymbol[0]) - cy.wait(2000) - cy.verifyIcon('true') - cy.verifyValueInList(token.favoriteToken, [tokenSymbol[0]], true) - }) - }) - - describe('Select token by symbol', () => { - it('Should be selected tokenIn by symbol successfully', () => { - cy.clickButton(token.tokenIn) - cy.selectTokenBySymbol(token.inputToken, tokenSymbol[0]) - cy.verifySelectedToken(token.tokenIn, tokenSymbol[0]) - cy.verifyURL(tokenSymbol[0], '') - }) - - it('Should be selected tokenOut by symbol successfully', () => { - cy.clickButton(token.tokenOut) - cy.selectTokenBySymbol(token.inputToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenOut, tokenSymbol[1]) - cy.verifyURL('', tokenSymbol[1]) - }) - - it('Should be unselected tokenIn not exist in whitelist', () => { - cy.clickButton(token.tokenIn) - cy.input(token.inputToken, unListedToken[0]) - cy.verifyNoResultFound() - }) - - it('Should be unselected tokenOut not exist in whitelist', () => { - cy.clickButton(token.tokenOut) - cy.input(token.inputToken, unListedToken[1]) - cy.verifyNoResultFound() - }) - }) - - describe('Import token', () => { - it('Should be imported tokenIn successfully', () => { - cy.importNewTokenByAddress(token.tokenIn, unWhitelistTokens[0].address) - cy.verifySelectedToken(token.tokenIn, unWhitelistTokens[0].name) - cy.clickButton(token.tokenIn) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[0].name], true) - }) - - it('Should be imported tokenOut successfully', () => { - cy.importNewTokenByAddress(token.tokenOut, unWhitelistTokens[1].address) - cy.verifySelectedToken(token.tokenOut, unWhitelistTokens[1].name) - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[1].name], true) - }) - }) - - describe('Delete token', () => { - it('Should be deleted the imported tokenIn successfully', () => { - cy.importNewTokenByAddress(token.tokenIn, unWhitelistTokens[0].address) - cy.clickButton(token.tokenIn) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[0].name], true) - cy.deleteImportedToken(unWhitelistTokens[0].address) - cy.verifyNoResultFound() - }) - - it('Should be deleted the imported tokenOut successfully', () => { - cy.importNewTokenByAddress(token.tokenOut, unWhitelistTokens[0].address) - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[0].name], true) - cy.deleteImportedToken(unWhitelistTokens[0].address) - cy.verifyNoResultFound() - }) - - it('Should be cleared all the imported tokenIn successfully', () => { - cy.importNewTokenByAddress(token.tokenIn, unWhitelistTokens[0].address) - cy.importNewTokenByAddress(token.tokenIn, unWhitelistTokens[1].address) - cy.importNewTokenByAddress(token.tokenIn, unWhitelistTokens[2].address) - cy.clickButton(token.tokenIn) - cy.clickButton(tab.import) - cy.verifyValueInList( - token.rowInWhiteList, - [unWhitelistTokens[0].name, unWhitelistTokens[1].name, unWhitelistTokens[2].name], - true, - ) - cy.clearAllImportedTokens() - cy.verifyNoResultFound() - }) - - it('Should be cleared all the imported tokenOut successfully', () => { - cy.importNewTokenByAddress(token.tokenOut, unWhitelistTokens[0].address) - cy.importNewTokenByAddress(token.tokenOut, unWhitelistTokens[1].address) - cy.importNewTokenByAddress(token.tokenOut, unWhitelistTokens[2].address) - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList( - token.rowInWhiteList, - [unWhitelistTokens[0].name, unWhitelistTokens[1].name, unWhitelistTokens[2].name], - true, - ) - cy.clearAllImportedTokens() - cy.verifyNoResultFound() - }) - }) - - describe('E2E Token Catalog', () => { - it.only('Should be selected tokenIn and tokenOut to swap', () => { - console.log('test token: ', network) - - // select tokenIn - cy.clickButton(token.tokenIn) - cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1]) - cy.verifySelectedToken(token.tokenIn, tokenSymbol[1]) - //select tokenOut - cy.importNewTokenByAddress(token.tokenOut, unWhitelistTokens[0].address) - cy.verifySelectedToken(token.tokenOut, unWhitelistTokens[0].name) - cy.verifyURL(tokenSymbol[1], unWhitelistTokens[0].name) - //delete imported tokenOut - cy.clickButton(token.tokenOut) - cy.clickButton(tab.import) - cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[0].name], true) - cy.deleteImportedToken(unWhitelistTokens[0].address) - cy.verifyNoResultFound() - cy.get(token.tokenOut).should('include.text', 'Select a token') - }) - }) -}) diff --git a/cypress/e2e/specs/swap-page.e2e.cy.ts b/cypress/e2e/specs/swap-page.e2e.cy.ts new file mode 100644 index 0000000000..1ec638cc02 --- /dev/null +++ b/cypress/e2e/specs/swap-page.e2e.cy.ts @@ -0,0 +1,185 @@ + +import { TOKEN_SYMBOLS, UNWHITE_LIST_TOKENS, tag } from "../pages/swap-page.po.cy" +import { homePage, tab, token } from "../selectors/selectors.cy" + +const network_env = Cypress.env('NETWORK') +const unWhitelistTokens = UNWHITE_LIST_TOKENS[network_env] + +const tokenSymbols = TOKEN_SYMBOLS[network_env] +const unListedToken = ['KNNC', 'KCCN'] + +const mainPage = `swap/${network_env}`.toLowerCase() + +describe(`Token Catalog on ${network_env}`, { tags: 'regression' }, () => { + beforeEach(() => { + cy.visit('/' + mainPage) + cy.url().should('include', mainPage) + cy.clickButton(homePage.skipTutorial) + }) + describe('Select token in favorite tokens list', () => { + it('Should be selected tokenIn in favorite tokens list successfully', () => { + cy.clickButton(token.tokenIn) + cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbols[1]) + cy.verifySelectedToken(token.tokenIn, tokenSymbols[1]) + cy.verifyURL(tokenSymbols[1], '') + }) + + it('Should be selected tokenOut in favorite tokens list successfully', () => { + cy.clickButton(token.tokenOut) + cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbols[1]) + cy.verifySelectedToken(token.tokenOut, tokenSymbols[1]) + cy.verifyURL('', tokenSymbols[1]) + }) + }) + + describe('Remove/add token with favorite tokens list', () => { + it('Should be removed tokenIn from favorite tokens list', () => { + cy.clickButton(token.tokenIn) + cy.verifyValueInList(token.favoriteToken, [tokenSymbols[3]], true) + cy.removeTokenInFavoriteTokensList(tokenSymbols[3]) + cy.verifyValueInList(token.favoriteToken, [tokenSymbols[3]], false) + cy.input(token.inputToken, tokenSymbols[3]) + cy.verifyIcon('false') + }) + + it('Should be added tokenIn to favorite tokens list', () => { + cy.clickButton(token.tokenIn) + cy.addTokenToFavoriteTokensList(tokenSymbols[0]) + cy.verifyIcon('true') + cy.verifyValueInList(token.favoriteToken, [tokenSymbols[0]], true) + }) + + it('Should be removed tokenOut from favorite tokens list', () => { + cy.clickButton(token.tokenOut) + cy.verifyValueInList(token.favoriteToken, [tokenSymbols[2]], true) + cy.removeTokenInFavoriteTokensList(tokenSymbols[2]) + cy.wait(2000) + cy.verifyValueInList(token.favoriteToken, [tokenSymbols[2]], false) + cy.input(token.inputToken, tokenSymbols[2]) + cy.verifyIcon('false') + }) + + it('Should be added tokenOut to favorite tokens list', () => { + cy.clickButton(token.tokenOut) + cy.addTokenToFavoriteTokensList(tokenSymbols[0]) + cy.verifyIcon('true') + cy.verifyValueInList(token.favoriteToken, [tokenSymbols[0]], true) + }) + }) + + describe('Select token by symbol', () => { + it('Should be selected tokenIn by symbol successfully', () => { + cy.clickButton(token.tokenIn) + cy.selectTokenBySymbol(token.inputToken, tokenSymbols[0]) + cy.verifySelectedToken(token.tokenIn, tokenSymbols[0]) + cy.verifyURL(tokenSymbols[0], '') + }) + + it('Should be selected tokenOut by symbol successfully', () => { + cy.clickButton(token.tokenOut) + cy.selectTokenBySymbol(token.inputToken, tokenSymbols[1]) + cy.verifySelectedToken(token.tokenOut, tokenSymbols[1]) + cy.verifyURL('', tokenSymbols[1]) + }) + + it('Should be unselected tokenIn not exist in whitelist', () => { + cy.clickButton(token.tokenIn) + cy.input(token.inputToken, unListedToken[0]) + cy.verifyNoResultFound() + }) + + it('Should be unselected tokenOut not exist in whitelist', () => { + cy.clickButton(token.tokenOut) + cy.input(token.inputToken, unListedToken[1]) + cy.verifyNoResultFound() + }) + }) + + describe('Import token', () => { + it('Should be imported tokenIn successfully', () => { + cy.importNewTokenByAddress(token.tokenIn, [unWhitelistTokens[0].address]) + cy.verifySelectedToken(token.tokenIn, unWhitelistTokens[0].name) + cy.clickButton(token.tokenIn) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[0].name], true) + }) + + it('Should be imported tokenOut successfully', () => { + cy.importNewTokenByAddress(token.tokenOut, [unWhitelistTokens[1].address]) + cy.verifySelectedToken(token.tokenOut, unWhitelistTokens[1].name) + cy.clickButton(token.tokenOut) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[1].name], true) + }) + }) + + describe('Delete token', () => { + it('Should be deleted the imported tokenIn successfully', () => { + cy.importNewTokenByAddress(token.tokenIn, [unWhitelistTokens[0].address]) + cy.clickButton(token.tokenIn) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[0].name], true) + cy.deleteImportedToken(unWhitelistTokens[0].address) + cy.verifyNoResultFound() + }) + + it('Should be deleted the imported tokenOut successfully', () => { + cy.importNewTokenByAddress(token.tokenOut, [unWhitelistTokens[0].address]) + cy.clickButton(token.tokenOut) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[0].name], true) + cy.deleteImportedToken(unWhitelistTokens[0].address) + cy.verifyNoResultFound() + }) + + it('Should be cleared all the imported tokenIn successfully', () => { + cy.importNewTokenByAddress(token.tokenIn, [unWhitelistTokens[0].address, unWhitelistTokens[1].address, unWhitelistTokens[2].address]) + cy.clickButton(token.tokenIn) + cy.clickButton(tab.import) + cy.verifyValueInList( + token.rowInWhiteList, + [unWhitelistTokens[0].name, unWhitelistTokens[1].name, unWhitelistTokens[2].name], + true, + ) + cy.clearAllImportedTokens() + cy.verifyNoResultFound() + }) + + it('Should be cleared all the imported tokenOut successfully', () => { + cy.importNewTokenByAddress(token.tokenOut, [unWhitelistTokens[0].address, unWhitelistTokens[1].address, unWhitelistTokens[2].address]) + cy.clickButton(token.tokenOut) + cy.clickButton(tab.import) + cy.verifyValueInList( + token.rowInWhiteList, + [unWhitelistTokens[0].name, unWhitelistTokens[1].name, unWhitelistTokens[2].name], + true, + ) + cy.clearAllImportedTokens() + cy.verifyNoResultFound() + }) + }) + + describe(`E2E Token Catalog`, () => { + let tagName = [tag.regression]; + if (network_env === 'Ethereum') { + tagName = [tag.regression, tag.smoke] + } + it('Should be selected tokenIn and tokenOut to swap', { tags: tagName }, () => { + // select tokenIn + cy.clickButton(token.tokenIn) + cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbols[1]) + cy.verifySelectedToken(token.tokenIn, tokenSymbols[1]) + //select tokenOut + cy.importNewTokenByAddress(token.tokenOut, [unWhitelistTokens[0].address]) + cy.verifySelectedToken(token.tokenOut, unWhitelistTokens[0].name) + cy.verifyURL(tokenSymbols[1], unWhitelistTokens[0].name) + //delete imported tokenOut + cy.clickButton(token.tokenOut) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhitelistTokens[0].name], true) + cy.deleteImportedToken(unWhitelistTokens[0].address) + cy.verifyNoResultFound() + cy.get(token.tokenOut).should('include.text', 'Select a token') + }) + }) +}) diff --git a/cypress/support/selectTokenCommands.ts b/cypress/support/selectTokenCommands.ts index 36c9a8a20b..ba71c1f0f3 100644 --- a/cypress/support/selectTokenCommands.ts +++ b/cypress/support/selectTokenCommands.ts @@ -1,4 +1,5 @@ -import { getText, getTokenList } from '../e2e/pages/swap-page.po.cy' +/* eslint-disable @typescript-eslint/no-namespace */ +import { getTokenList } from '../e2e/pages/swap-page.po.cy' import { notification, tab, token } from '../e2e/selectors/selectors.cy' export {} @@ -17,7 +18,7 @@ declare global { verifyValueInList(selector: string, value: Array, exist: boolean): Chainable addTokenToFavoriteTokensList(value: string): Chainable verifyNoResultFound(): Chainable - importNewTokenByAddress(selector: string, address: string): Chainable + importNewTokenByAddress(selector: string, address: Array): Chainable deleteImportedToken(address: string): Chainable clearAllImportedTokens(): Chainable } @@ -84,10 +85,12 @@ Cypress.Commands.add('verifyNoResultFound', () => { }) Cypress.Commands.add('importNewTokenByAddress', (selector, address) => { - cy.clickButton(selector) - cy.input(token.inputToken, address) - cy.get(token.btnImport).click() - cy.get(token.btnUnderstand).click() + address.forEach(element => { + cy.clickButton(selector) + cy.input(token.inputToken, element) + cy.get(token.btnImport).click() + cy.get(token.btnUnderstand).click() + }); }) Cypress.Commands.add('deleteImportedToken', address => { diff --git a/package.json b/package.json index 8ac6a94b36..d2b8920418 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "start-dev": "vite --mode dev --host", "start-stg": "vite --mode stg --host", "start-prod": "vite --mode production --host", - "test-e2e": "synpress run -cf cypress.config.ts -c baseUrl=http://127.0.0.1:4173/ -e grepTags=smoke,grepFilterSpecs=true,grepOmitFiltered=true", - "test-schedule": "synpress run -cf cypress.config.ts -c baseUrl=https://kyberswap.com/ -e grepTags=regression,grepFilterSpecs=true,grepOmitFiltered=true" + "test-e2e": "synpress run -cf cypress.config.ts -c baseUrl=http://127.0.0.1:4173/", + "test-schedule": "synpress run -cf cypress.config.ts -c baseUrl=https://kyberswap.com/" }, "browserslist": [ "chrome >= 52",