From 6f84bae4e067e14ddf14da757e3e31f22e01f7b3 Mon Sep 17 00:00:00 2001 From: ltthienn Date: Wed, 8 Nov 2023 15:51:56 +0700 Subject: [PATCH 1/3] Update failed tests --- cypress/e2e/selectors/constants.cy.ts | 4 +-- cypress/e2e/specs/connect-wallet.e2e.cy.ts | 29 ---------------------- cypress/e2e/specs/cross-chain.e2e.cy.ts | 19 ++++++++------ cypress/e2e/specs/limit-order.e2e.cy.ts | 8 +++--- 4 files changed, 18 insertions(+), 42 deletions(-) delete mode 100644 cypress/e2e/specs/connect-wallet.e2e.cy.ts diff --git a/cypress/e2e/selectors/constants.cy.ts b/cypress/e2e/selectors/constants.cy.ts index 00e804a953..51101d7de2 100644 --- a/cypress/e2e/selectors/constants.cy.ts +++ b/cypress/e2e/selectors/constants.cy.ts @@ -12,9 +12,9 @@ export enum TAG { } export const TOKEN_SYMBOLS = { - 'Ethereum': ['BAND', 'ETH', 'USDT', 'USDC', '1INCH'], + 'Ethereum': ['BAND', 'USDC', 'USDT', 'ETH', '1INCH'], 'Arbitrum': ['ANGLE', 'ARB', 'USDT', 'USDC.e', 'BOB'], - 'Optimism': ['BOND', 'ETH', 'USDT', 'USDC', 'BOB'], + 'Optimism': ['BOND', 'USDC', 'USDT', 'ETH', 'BOB'], 'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e', 'BUSD.e'], 'BNB': ['RICE', 'BUSD', 'USDT', 'USDC', 'BOB'] } diff --git a/cypress/e2e/specs/connect-wallet.e2e.cy.ts b/cypress/e2e/specs/connect-wallet.e2e.cy.ts deleted file mode 100644 index bd512ef615..0000000000 --- a/cypress/e2e/specs/connect-wallet.e2e.cy.ts +++ /dev/null @@ -1,29 +0,0 @@ - -import { Network, SwapPage } from '../pages/swap-page.po.cy' -import { DEFAULT_NETWORK, DEFAULT_URL, NETWORK, TAG } from '../selectors/constants.cy' - - -const wallet = new Network() - -describe('Metamask Extension tests', { tags: TAG.regression }, () => { - beforeEach(() => { - SwapPage.open(DEFAULT_URL) - SwapPage.connectWallet() - }) - - 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') - }) - - it('Should approve permission to switch network', () => { - if (NETWORK !== DEFAULT_NETWORK) { - SwapPage.getStatusConnectedWallet() - wallet.selectNetwork(NETWORK) - cy.allowMetamaskToAddAndSwitchNetwork().then(approved => { - expect(approved).to.be.true - }) - } - }) -}) diff --git a/cypress/e2e/specs/cross-chain.e2e.cy.ts b/cypress/e2e/specs/cross-chain.e2e.cy.ts index 23a99c3338..1284830118 100644 --- a/cypress/e2e/specs/cross-chain.e2e.cy.ts +++ b/cypress/e2e/specs/cross-chain.e2e.cy.ts @@ -6,17 +6,20 @@ 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) { - CrossChain.closeUnderstandPopup() - } - }) }) describe('Select network', () => { + beforeEach(() => { + cy.acceptMetamaskAccess() + SwapPage.getStatusConnectedWallet() + + SwapPage.goToCrossChain() + CrossChain.checkLoadedPage().then((checked) => { + if (checked === true) { + CrossChain.closeUnderstandPopup() + } + }) + }) it('The network should be changed successfully', () => { const networkIn = CrossChain.changeNetwork([NETWORK]) CrossChain.selectNetworkIn(networkIn) diff --git a/cypress/e2e/specs/limit-order.e2e.cy.ts b/cypress/e2e/specs/limit-order.e2e.cy.ts index 9c3030c544..b85c69f8e7 100644 --- a/cypress/e2e/specs/limit-order.e2e.cy.ts +++ b/cypress/e2e/specs/limit-order.e2e.cy.ts @@ -17,13 +17,15 @@ describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => { describe('Add/remove/select token with favorite tokens list', () => { beforeEach(() => { - if (NETWORK === 'BNB' || NETWORK === 'Ethereum') { - netw.selectNetwork(NETWORK) + netw.selectNetwork(NETWORK) + if (NETWORK === 'Ethereum') { cy.allowMetamaskToSwitchNetwork().then(approved => { expect(approved).to.be.true }) } else { - cy.changeMetamaskNetwork(NETWORK) + cy.allowMetamaskToAddAndSwitchNetwork().then(approved => { + expect(approved).to.be.true + }) } SwapPage.goToLimitOrder() LimitOder.checkGetStartedDisplay().then((checked) => { From 0143152eb9e833e729b03493657ef98d17b4f2b5 Mon Sep 17 00:00:00 2001 From: ltthienn Date: Wed, 8 Nov 2023 16:59:34 +0700 Subject: [PATCH 2/3] Update tests --- cypress/e2e/selectors/constants.cy.ts | 2 +- cypress/e2e/specs/cross-chain.e2e.cy.ts | 15 +++------ cypress/e2e/specs/swap-page.e2e.cy.ts | 44 ++++++++++++++----------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/cypress/e2e/selectors/constants.cy.ts b/cypress/e2e/selectors/constants.cy.ts index 51101d7de2..4b778d56eb 100644 --- a/cypress/e2e/selectors/constants.cy.ts +++ b/cypress/e2e/selectors/constants.cy.ts @@ -14,7 +14,7 @@ export enum TAG { export const TOKEN_SYMBOLS = { 'Ethereum': ['BAND', 'USDC', 'USDT', 'ETH', '1INCH'], 'Arbitrum': ['ANGLE', 'ARB', 'USDT', 'USDC.e', 'BOB'], - 'Optimism': ['BOND', 'USDC', 'USDT', 'ETH', 'BOB'], + 'Optimism': ['BOND', 'USDC.e', 'USDT', 'ETH', 'BOB'], 'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e', 'BUSD.e'], 'BNB': ['RICE', 'BUSD', 'USDT', 'USDC', 'BOB'] } diff --git a/cypress/e2e/specs/cross-chain.e2e.cy.ts b/cypress/e2e/specs/cross-chain.e2e.cy.ts index 1284830118..a58b9df5e2 100644 --- a/cypress/e2e/specs/cross-chain.e2e.cy.ts +++ b/cypress/e2e/specs/cross-chain.e2e.cy.ts @@ -21,18 +21,11 @@ describe(`Cross-chain on ${NETWORK}`, { tags: TAG.regression }, () => { }) }) it('The network should be changed successfully', () => { - const networkIn = CrossChain.changeNetwork([NETWORK]) + const networkIn = CrossChain.changeNetwork([NETWORK, DEFAULT_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 - }) - } + cy.allowMetamaskToSwitchNetwork().then(approved => { + expect(approved).to.be.true + }) CrossChain.getCurrentNetworkIn().then((currentNetworkIn) => { expect(currentNetworkIn).to.equal(networkIn) }) diff --git a/cypress/e2e/specs/swap-page.e2e.cy.ts b/cypress/e2e/specs/swap-page.e2e.cy.ts index 2939d15ebb..18b792c873 100644 --- a/cypress/e2e/specs/swap-page.e2e.cy.ts +++ b/cypress/e2e/specs/swap-page.e2e.cy.ts @@ -141,29 +141,35 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { }) }) }) +}) - describe(`E2E Token Catalog`, () => { - it('Should be selected tokenIn and tokenOut to swap', { tags: TAG.smoke }, () => { - tokenCatalog.importNewTokens([arrAddress[2]]) - SwapPage.getCurrentTokenIn((text) => { - expect(text).to.equal(arrSymbol[2]) - }) +describe(`E2E Token Catalog`, () => { + beforeEach(() => { + SwapPage.open(DEFAULT_URL) + SwapPage.connectWallet() + cy.acceptMetamaskAccess() + SwapPage.getStatusConnectedWallet() + }) + it('Should be selected tokenIn and tokenOut to swap', { tags: TAG.smoke }, () => { + tokenCatalog.importNewTokens([arrAddress[2]]) + SwapPage.getCurrentTokenIn((text) => { + expect(text).to.equal(arrSymbol[2]) + }) - SwapPage.selectTokenOut().getFavoriteTokens((arr) => { - tokenCatalog.selectFavoriteToken(arr[1]) - SwapPage.getCurrentTokenOut((text) => { - expect(text).to.equal(arr[1]) - }) + SwapPage.selectTokenOut().getFavoriteTokens((arr) => { + tokenCatalog.selectFavoriteToken(arr[1]) + SwapPage.getCurrentTokenOut((text) => { + expect(text).to.equal(arr[1]) }) + }) - SwapPage.selectTokenOut() - tokenCatalog.deleteImportedToken(arrSymbol[2]) - tokenCatalog.getNoResultsFound((text) => { - expect(text).to.equal(NORESULTS_TEXT) - }) - SwapPage.getCurrentTokenIn((text) => { - expect(text).to.equal(NOTOKENS_TEXT) - }) + SwapPage.selectTokenOut() + tokenCatalog.deleteImportedToken(arrSymbol[2]) + tokenCatalog.getNoResultsFound((text) => { + expect(text).to.equal(NORESULTS_TEXT) + }) + SwapPage.getCurrentTokenIn((text) => { + expect(text).to.equal(NOTOKENS_TEXT) }) }) }) \ No newline at end of file From bd5f0e13abe6d850d88265bfc07ef4e991a63427 Mon Sep 17 00:00:00 2001 From: ltthienn Date: Wed, 8 Nov 2023 17:27:24 +0700 Subject: [PATCH 3/3] Update tests --- cypress/e2e/specs/cross-chain.e2e.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/specs/cross-chain.e2e.cy.ts b/cypress/e2e/specs/cross-chain.e2e.cy.ts index a58b9df5e2..7d19e2715a 100644 --- a/cypress/e2e/specs/cross-chain.e2e.cy.ts +++ b/cypress/e2e/specs/cross-chain.e2e.cy.ts @@ -23,7 +23,7 @@ describe(`Cross-chain on ${NETWORK}`, { tags: TAG.regression }, () => { it('The network should be changed successfully', () => { const networkIn = CrossChain.changeNetwork([NETWORK, DEFAULT_NETWORK]) CrossChain.selectNetworkIn(networkIn) - cy.allowMetamaskToSwitchNetwork().then(approved => { + cy.allowMetamaskToAddAndSwitchNetwork().then(approved => { expect(approved).to.be.true }) CrossChain.getCurrentNetworkIn().then((currentNetworkIn) => {