From 84040be6e6cd99badc3d3944fc652d00b6b90beb Mon Sep 17 00:00:00 2001 From: ltthienn Date: Wed, 15 Nov 2023 15:33:38 +0700 Subject: [PATCH 1/6] Update failed tests --- cypress/e2e/pages/swap-page.po.cy.ts | 4 + cypress/e2e/selectors/constants.cy.ts | 4 +- cypress/e2e/selectors/selectors.cy.ts | 1 + cypress/e2e/specs/intercept.e2e.cy.ts | 6 +- cypress/e2e/specs/limit-order.e2e.cy.ts | 50 ++- cypress/e2e/specs/swap-page.e2e.cy.ts | 299 +++++++++--------- .../Header/web3/NetworkModal/index.tsx | 2 +- src/components/SearchModal/CurrencySearch.tsx | 2 +- 8 files changed, 188 insertions(+), 180 deletions(-) diff --git a/cypress/e2e/pages/swap-page.po.cy.ts b/cypress/e2e/pages/swap-page.po.cy.ts index af6d09aed8..459c1e8012 100644 --- a/cypress/e2e/pages/swap-page.po.cy.ts +++ b/cypress/e2e/pages/swap-page.po.cy.ts @@ -134,4 +134,8 @@ export class TokenCatalog { getNoResultsFound(text: myCallbackType) { cy.getContent(TokenCatalogLocators.lblNotFound, text) } + + closePopup() { + cy.get(TokenCatalogLocators.iconClosePopup).click() + } } diff --git a/cypress/e2e/selectors/constants.cy.ts b/cypress/e2e/selectors/constants.cy.ts index 5914bc8043..e10804a1fd 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', 'wstETH', 'USDT', 'USDC', '1INCH'], Arbitrum: ['ANGLE', 'ARB', 'USDT', 'USDC.e', 'BOB'], - Optimism: ['BOND', 'ETH', 'USDT', 'USDC', 'BOB'], + Optimism: ['BOND', 'wstETH', 'USDT', 'USDC', 'BOB'], Avalanche: ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e', 'BUSD.e'], BNB: ['RICE', 'BUSD', 'USDT', 'USDC', 'BOB'], } diff --git a/cypress/e2e/selectors/selectors.cy.ts b/cypress/e2e/selectors/selectors.cy.ts index 3ac8d89c5f..52f760fa52 100644 --- a/cypress/e2e/selectors/selectors.cy.ts +++ b/cypress/e2e/selectors/selectors.cy.ts @@ -9,6 +9,7 @@ export const TokenCatalogLocators = { iconFavorite: '[data-testid=button-favorite-token]', iconRemoveImportedToken: '[data-testid=button-remove-import-token]', iconRemoveFavoriteToken: '[data-testid=close-btn]', + iconClosePopup: '[data-testid=close-icon]', btnImport: '[data-testid=button-import-token]', btnUnderstand: '[data-testid=button-confirm-import-token]', btnClearAll: '[data-testid=button-clear-all-import-token]', diff --git a/cypress/e2e/specs/intercept.e2e.cy.ts b/cypress/e2e/specs/intercept.e2e.cy.ts index 32893b316e..3bfb40ae59 100644 --- a/cypress/e2e/specs/intercept.e2e.cy.ts +++ b/cypress/e2e/specs/intercept.e2e.cy.ts @@ -7,9 +7,13 @@ const tokenCatalog = new TokenCatalog() const farm = new FarmPage() describe('Intercept', { tags: TAG.regression }, () => { - beforeEach(() => { + before(() => { SwapPage.open(DEFAULT_URL) }) + + afterEach(() => { + cy.reload() + }) describe('Swap', () => { it('Should get route successfully', () => { cy.intercept('GET', '**/routes?**').as('get-route') diff --git a/cypress/e2e/specs/limit-order.e2e.cy.ts b/cypress/e2e/specs/limit-order.e2e.cy.ts index 9c3030c544..9059d5fcb8 100644 --- a/cypress/e2e/specs/limit-order.e2e.cy.ts +++ b/cypress/e2e/specs/limit-order.e2e.cy.ts @@ -9,29 +9,32 @@ const tokenCatalog = new TokenCatalog(); const netw = new Network() describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => { - beforeEach(() => { + before(() => { SwapPage.open(DEFAULT_URL) 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() - } + 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() + } }) + }) + + afterEach(() => { + cy.reload(false) + SwapPage.getStatusConnectedWallet() + }) + + describe('Add/remove/select token', () => { it('Should be added, selected and removed favorite token sell', () => { LimitOder.selectTokenSell().addFavoriteToken([tokenSymbols[0], tokenSymbols[4]]) tokenCatalog.getFavoriteTokens((list) => { @@ -48,16 +51,7 @@ 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) => { diff --git a/cypress/e2e/specs/swap-page.e2e.cy.ts b/cypress/e2e/specs/swap-page.e2e.cy.ts index bc93ebf5c0..3e7f7856b0 100644 --- a/cypress/e2e/specs/swap-page.e2e.cy.ts +++ b/cypress/e2e/specs/swap-page.e2e.cy.ts @@ -1,13 +1,13 @@ 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, + DEFAULT_URL, + NETWORK, + NORESULTS_TEXT, + NOTOKENS_TEXT, + TAG, + TOKEN_SYMBOLS, + UNWHITELIST_SYMBOL_TOKENS, + UNWHITELIST_TOKENS, } from '../selectors/constants.cy' const unWhitelistTokens = UNWHITELIST_TOKENS[NETWORK] @@ -19,161 +19,166 @@ const arrSymbol = [unWhitelistTokens[0].symbol, unWhitelistTokens[1].symbol, unW const tokenCatalog = new TokenCatalog() describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { - before(() => { - SwapPage.open(DEFAULT_URL) - SwapPage.connectWallet() - SwapPage.getStatusConnectedWallet() - }) - - describe('Select token in favorite tokens list', () => { - it('Should be selected tokenIn in favorite tokens list successfully', () => { - SwapPage.selectTokenIn().getFavoriteTokens(arr => { - tokenCatalog.selectFavoriteToken(arr[1]) - SwapPage.getCurrentTokenIn(text => { - expect(text).to.equal(arr[1]) - }) - }) + before(() => { + SwapPage.open(DEFAULT_URL) + SwapPage.connectWallet() + SwapPage.getStatusConnectedWallet() }) - it('Should be selected tokenOut in favorite tokens list successfully', () => { - SwapPage.selectTokenOut().getFavoriteTokens(arr => { - tokenCatalog.selectFavoriteToken(arr[2]) - SwapPage.getCurrentTokenOut(text => { - expect(text).to.equal(arr[2]) + describe('Select token in favorite tokens list', () => { + it('Should be selected tokenIn in favorite tokens list successfully', () => { + SwapPage.selectTokenIn().getFavoriteTokens(arr => { + tokenCatalog.selectFavoriteToken(arr[1]) + SwapPage.getCurrentTokenIn(text => { + expect(text).to.equal(arr[1]) + }) + }) }) - }) - }) - }) - - describe('Remove/add token with favorite tokens list', () => { - it('Should be removed tokenIn from favorite tokens list', () => { - SwapPage.selectTokenIn().getFavoriteTokens(arr => { - tokenCatalog.removeFavoriteToken(arr[1]) - cy.wait(2000) - tokenCatalog.getFavoriteTokens(list => { - expect(list).not.to.include.members([arr[1]]) + + it('Should be selected tokenOut in favorite tokens list successfully', () => { + SwapPage.selectTokenOut().getFavoriteTokens(arr => { + tokenCatalog.selectFavoriteToken(arr[2]) + SwapPage.getCurrentTokenOut(text => { + expect(text).to.equal(arr[2]) + }) + }) }) - }) }) - it('Should be added tokenIn to favorite tokens list', () => { - SwapPage.selectTokenIn().addFavoriteToken([tokenSymbols[0]]) - tokenCatalog.getFavoriteTokens(list => { - expect(list).to.include.members([tokenSymbols[0]]) - }) - }) + describe('Remove/add token with favorite tokens list', () => { + it('Should be removed tokenIn from favorite tokens list', () => { + SwapPage.selectTokenIn().getFavoriteTokens(arr => { + tokenCatalog.removeFavoriteToken(arr[1]) + cy.wait(2000) + tokenCatalog.getFavoriteTokens(list => { + expect(list).not.to.include.members([arr[1]]) + }) + }) + tokenCatalog.closePopup() + }) - it('Should be removed tokenOut from favorite tokens list', () => { - SwapPage.selectTokenOut().getFavoriteTokens(arr => { - tokenCatalog.removeFavoriteToken(arr[2]) - cy.wait(2000) - tokenCatalog.getFavoriteTokens(list => { - expect(list).not.to.include.members([arr[2]]) + it('Should be added tokenIn to favorite tokens list', () => { + SwapPage.selectTokenIn().addFavoriteToken([tokenSymbols[0]]) + tokenCatalog.getFavoriteTokens(list => { + expect(list).to.include.members([tokenSymbols[0]]) + }) + tokenCatalog.closePopup() }) - }) - }) - it('Should be added tokenOut to favorite tokens list', () => { - SwapPage.selectTokenOut().addFavoriteToken([tokenSymbols[0]]) - tokenCatalog.getFavoriteTokens(list => { - expect(list).to.include.members([tokenSymbols[0]]) - }) - }) - }) - - describe('Select token by symbol', () => { - it('Should be selected tokenIn by symbol successfully', () => { - SwapPage.selectTokenIn().selectTokenBySymbol(tokenSymbols[0]) - SwapPage.getCurrentTokenIn(text => { - expect(text).to.equal(tokenSymbols[0]) - }) - }) + it('Should be removed tokenOut from favorite tokens list', () => { + SwapPage.selectTokenOut().getFavoriteTokens(arr => { + tokenCatalog.removeFavoriteToken(arr[2]) + cy.wait(2000) + tokenCatalog.getFavoriteTokens(list => { + expect(list).not.to.include.members([arr[2]]) + }) + }) + tokenCatalog.closePopup() + }) - it('Should be selected tokenOut by symbol successfully', () => { - SwapPage.selectTokenOut().selectTokenBySymbol(tokenSymbols[1]) - SwapPage.getCurrentTokenOut(text => { - expect(text).to.equal(tokenSymbols[1]) - }) + it('Should be added tokenOut to favorite tokens list', () => { + SwapPage.selectTokenOut().addFavoriteToken([tokenSymbols[0]]) + tokenCatalog.getFavoriteTokens(list => { + expect(list).to.include.members([tokenSymbols[0]]) + }) + tokenCatalog.closePopup() + }) }) - it('Should be unselected tokenIn not exist in whitelist', () => { - SwapPage.selectTokenIn().searchToken(UNWHITELIST_SYMBOL_TOKENS[0]) - tokenCatalog.getNoResultsFound(text => { - expect(text).to.equal(NORESULTS_TEXT) - }) - }) + describe('Select token by symbol', () => { + it('Should be selected tokenIn by symbol successfully', () => { + SwapPage.selectTokenIn().selectTokenBySymbol(tokenSymbols[0]) + SwapPage.getCurrentTokenIn(text => { + expect(text).to.equal(tokenSymbols[0]) + }) + }) - it('Should be unselected tokenOut not exist in whitelist', () => { - SwapPage.selectTokenOut().searchToken(UNWHITELIST_SYMBOL_TOKENS[0]) - tokenCatalog.getNoResultsFound(text => { - expect(text).to.equal(NORESULTS_TEXT) - }) - }) - }) - - describe('Import and delete token', () => { - it('Should be imported then deleted tokenIn successfully', () => { - tokenCatalog.importNewTokens(arrAddress) - SwapPage.selectTokenIn().selectImportTab() - tokenCatalog.getWhitelistTokens(list => { - expect(list).to.include.members(arrSymbol) - }) - - tokenCatalog.deleteImportedToken(arrSymbol[2]) - tokenCatalog.getWhitelistTokens(list => { - expect(list).not.to.include.members([arrSymbol[2]]) - }) - - tokenCatalog.clearAllImportedTokens() - tokenCatalog.getNoResultsFound(text => { - expect(text).to.equal(NORESULTS_TEXT) - }) + it('Should be selected tokenOut by symbol successfully', () => { + SwapPage.selectTokenOut().selectTokenBySymbol(tokenSymbols[1]) + SwapPage.getCurrentTokenOut(text => { + expect(text).to.equal(tokenSymbols[1]) + }) + }) + + it('Should be unselected tokenIn not exist in whitelist', () => { + SwapPage.selectTokenIn().searchToken(UNWHITELIST_SYMBOL_TOKENS[0]) + tokenCatalog.getNoResultsFound(text => { + expect(text).to.equal(NORESULTS_TEXT) + }) + tokenCatalog.closePopup() + }) + + it('Should be unselected tokenOut not exist in whitelist', () => { + SwapPage.selectTokenOut().searchToken(UNWHITELIST_SYMBOL_TOKENS[0]) + tokenCatalog.getNoResultsFound(text => { + expect(text).to.equal(NORESULTS_TEXT) + }) + tokenCatalog.closePopup() + }) }) - it('Should be imported then deleted tokenOut successfully', () => { - tokenCatalog.importNewTokens(arrAddress) - SwapPage.selectTokenOut().selectImportTab() - tokenCatalog.getWhitelistTokens(list => { - expect(list).to.include.members(arrSymbol) - }) - - tokenCatalog.deleteImportedToken(arrSymbol[1]) - tokenCatalog.getWhitelistTokens(list => { - expect(list).not.to.include.members([arrSymbol[1]]) - }) - - tokenCatalog.clearAllImportedTokens() - tokenCatalog.getNoResultsFound(text => { - expect(text).to.equal(NORESULTS_TEXT) - }) + describe('Import and delete token', () => { + it('Should be imported then deleted tokenIn successfully', () => { + tokenCatalog.importNewTokens(arrAddress) + SwapPage.selectTokenIn().selectImportTab() + tokenCatalog.getWhitelistTokens(list => { + expect(list).to.include.members(arrSymbol) + }) + + tokenCatalog.deleteImportedToken(arrSymbol[2]) + tokenCatalog.getWhitelistTokens(list => { + expect(list).not.to.include.members([arrSymbol[2]]) + }) + + tokenCatalog.clearAllImportedTokens() + tokenCatalog.getNoResultsFound(text => { + expect(text).to.equal(NORESULTS_TEXT) + }) + tokenCatalog.closePopup() + }) + + it('Should be imported then deleted tokenOut successfully', () => { + tokenCatalog.importNewTokens(arrAddress) + SwapPage.selectTokenOut().selectImportTab() + tokenCatalog.getWhitelistTokens(list => { + expect(list).to.include.members(arrSymbol) + }) + + tokenCatalog.deleteImportedToken(arrSymbol[1]) + tokenCatalog.getWhitelistTokens(list => { + expect(list).not.to.include.members([arrSymbol[1]]) + }) + + tokenCatalog.clearAllImportedTokens() + tokenCatalog.getNoResultsFound(text => { + expect(text).to.equal(NORESULTS_TEXT) + }) + tokenCatalog.closePopup() + }) }) - }) - - 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]) - }) - - SwapPage.selectTokenOut().getFavoriteTokens(arr => { - tokenCatalog.selectFavoriteToken(arr[1]) - SwapPage.getCurrentTokenOut(text => { - expect(text).to.equal(arr[1]) + + 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]) + }) + + 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) - }) }) - }) - afterEach(() => { - cy.reload() - }) }) diff --git a/src/components/Header/web3/NetworkModal/index.tsx b/src/components/Header/web3/NetworkModal/index.tsx index 77678fb59a..b46aa29ae3 100644 --- a/src/components/Header/web3/NetworkModal/index.tsx +++ b/src/components/Header/web3/NetworkModal/index.tsx @@ -196,7 +196,7 @@ export default function NetworkModal({ ) : ( - + {supportedChains .filter(chain => !favoriteChains.some(_ => _ === chain.chainId.toString())) .map((networkInfo: NetworkInfo) => { diff --git a/src/components/SearchModal/CurrencySearch.tsx b/src/components/SearchModal/CurrencySearch.tsx index 08b5d3831a..0e5069f09a 100644 --- a/src/components/SearchModal/CurrencySearch.tsx +++ b/src/components/SearchModal/CurrencySearch.tsx @@ -423,7 +423,7 @@ export function CurrencySearch({ } /> - + From aed749e68d97276b717c45a77ab7ea5526e4074f Mon Sep 17 00:00:00 2001 From: ltthienn Date: Tue, 21 Nov 2023 15:37:48 +0700 Subject: [PATCH 2/6] Update failed test --- cypress.config.ts | 1 + cypress/e2e/selectors/constants.cy.ts | 10 +++++----- cypress/e2e/specs/intercept.e2e.cy.ts | 20 ++++++++++---------- cypress/e2e/specs/swap-page.e2e.cy.ts | 15 +++++++-------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cypress.config.ts b/cypress.config.ts index ff52e33d50..a2e2a3f104 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -156,5 +156,6 @@ export default defineConfig({ }) }, specPattern: 'cypress/e2e/specs/*.e2e.cy.ts', + excludeSpecPattern: '*/*/**/zap.e2e.cy.ts', }, }) diff --git a/cypress/e2e/selectors/constants.cy.ts b/cypress/e2e/selectors/constants.cy.ts index e10804a1fd..7ce18b6ae6 100644 --- a/cypress/e2e/selectors/constants.cy.ts +++ b/cypress/e2e/selectors/constants.cy.ts @@ -12,11 +12,11 @@ export enum TAG { } export const TOKEN_SYMBOLS = { - Ethereum: ['BAND', 'wstETH', 'USDT', 'USDC', '1INCH'], - Arbitrum: ['ANGLE', 'ARB', 'USDT', 'USDC.e', 'BOB'], - Optimism: ['BOND', 'wstETH', 'USDT', 'USDC', 'BOB'], - Avalanche: ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e', 'BUSD.e'], - BNB: ['RICE', 'BUSD', 'USDT', 'USDC', 'BOB'], + Ethereum: ['BAND', 'wstETH', 'USDT', 'AAVE', '1INCH'], + Arbitrum: ['ANGLE', 'ARB', 'USDT', 'ANGLE', 'BOB'], + Optimism: ['BOND', 'WETH', 'USDT', 'AAVE', 'BOB'], + Avalanche: ['AAVE.e', 'sAVAX', 'USDT.e', 'ANGLE', 'BUSD.e'], + BNB: ['RICE', 'BUSD', 'USDT', 'AAVE', 'BOB'], } export const NETWORK_LIST = [ diff --git a/cypress/e2e/specs/intercept.e2e.cy.ts b/cypress/e2e/specs/intercept.e2e.cy.ts index 3bfb40ae59..983b320833 100644 --- a/cypress/e2e/specs/intercept.e2e.cy.ts +++ b/cypress/e2e/specs/intercept.e2e.cy.ts @@ -11,7 +11,7 @@ describe('Intercept', { tags: TAG.regression }, () => { SwapPage.open(DEFAULT_URL) }) - afterEach(() => { + beforeEach(() => { cy.reload() }) describe('Swap', () => { @@ -46,21 +46,13 @@ describe('Intercept', { tags: TAG.regression }, () => { }) }) - describe('My Pools', () => { - it('Should get farm list successfully', () => { - cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') - SwapPage.goToMyPoolsPage() - 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') SwapPage.goToFarmPage() cy.get('[data-testid=farm-block]') - .should(_ => {}) + .should(_ => { }) .then($list => { if ($list.length) { cy.wait('@get-pool-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200) @@ -69,4 +61,12 @@ describe('Intercept', { tags: TAG.regression }, () => { }) }) }) + + describe('My Pools', () => { + it('Should get farm list successfully', () => { + cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') + SwapPage.goToMyPoolsPage() + cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200) + }) + }) }) \ No newline at end of file diff --git a/cypress/e2e/specs/swap-page.e2e.cy.ts b/cypress/e2e/specs/swap-page.e2e.cy.ts index 3e7f7856b0..dd96372409 100644 --- a/cypress/e2e/specs/swap-page.e2e.cy.ts +++ b/cypress/e2e/specs/swap-page.e2e.cy.ts @@ -37,15 +37,18 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { it('Should be selected tokenOut in favorite tokens list successfully', () => { SwapPage.selectTokenOut().getFavoriteTokens(arr => { - tokenCatalog.selectFavoriteToken(arr[2]) + tokenCatalog.selectFavoriteToken(arr[0]) SwapPage.getCurrentTokenOut(text => { - expect(text).to.equal(arr[2]) + expect(text).to.equal(arr[0]) }) }) }) }) describe('Remove/add token with favorite tokens list', () => { + afterEach(() => { + tokenCatalog.closePopup() + }) it('Should be removed tokenIn from favorite tokens list', () => { SwapPage.selectTokenIn().getFavoriteTokens(arr => { tokenCatalog.removeFavoriteToken(arr[1]) @@ -54,7 +57,6 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { expect(list).not.to.include.members([arr[1]]) }) }) - tokenCatalog.closePopup() }) it('Should be added tokenIn to favorite tokens list', () => { @@ -62,7 +64,6 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { tokenCatalog.getFavoriteTokens(list => { expect(list).to.include.members([tokenSymbols[0]]) }) - tokenCatalog.closePopup() }) it('Should be removed tokenOut from favorite tokens list', () => { @@ -73,15 +74,13 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { expect(list).not.to.include.members([arr[2]]) }) }) - tokenCatalog.closePopup() }) it('Should be added tokenOut to favorite tokens list', () => { - SwapPage.selectTokenOut().addFavoriteToken([tokenSymbols[0]]) + SwapPage.selectTokenOut().addFavoriteToken([tokenSymbols[4]]) tokenCatalog.getFavoriteTokens(list => { - expect(list).to.include.members([tokenSymbols[0]]) + expect(list).to.include.members([tokenSymbols[4]]) }) - tokenCatalog.closePopup() }) }) From 746ded9f25d81c21eb013ccb91d650e5a01ae79a Mon Sep 17 00:00:00 2001 From: ltthienn Date: Wed, 22 Nov 2023 11:37:31 +0700 Subject: [PATCH 3/6] Update tests --- cypress/e2e/specs/intercept.e2e.cy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/specs/intercept.e2e.cy.ts b/cypress/e2e/specs/intercept.e2e.cy.ts index 983b320833..eaac7f33a6 100644 --- a/cypress/e2e/specs/intercept.e2e.cy.ts +++ b/cypress/e2e/specs/intercept.e2e.cy.ts @@ -9,9 +9,10 @@ const farm = new FarmPage() describe('Intercept', { tags: TAG.regression }, () => { before(() => { SwapPage.open(DEFAULT_URL) + // cy.setCookie('myCookie', 'cookieValue'); }) - beforeEach(() => { + cy.clearCookies() cy.reload() }) describe('Swap', () => { From 7ed8c6b6abd8c76c9932d0035988777863d448bd Mon Sep 17 00:00:00 2001 From: ltthienn Date: Wed, 22 Nov 2023 11:57:08 +0700 Subject: [PATCH 4/6] Update tests --- cypress/e2e/specs/intercept.e2e.cy.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/specs/intercept.e2e.cy.ts b/cypress/e2e/specs/intercept.e2e.cy.ts index eaac7f33a6..862defdd91 100644 --- a/cypress/e2e/specs/intercept.e2e.cy.ts +++ b/cypress/e2e/specs/intercept.e2e.cy.ts @@ -9,11 +9,13 @@ const farm = new FarmPage() describe('Intercept', { tags: TAG.regression }, () => { before(() => { SwapPage.open(DEFAULT_URL) - // cy.setCookie('myCookie', 'cookieValue'); }) beforeEach(() => { - cy.clearCookies() cy.reload() + cy.setCookie('myCookie', 'cookieValue'); + }) + afterEach(() => { + cy.clearCookie('myCookie') }) describe('Swap', () => { it('Should get route successfully', () => { From be2e9065105be944109b17a81acca85eeb688a9e Mon Sep 17 00:00:00 2001 From: ltthienn Date: Wed, 22 Nov 2023 15:47:48 +0700 Subject: [PATCH 5/6] Update tests --- cypress/e2e/specs/intercept.e2e.cy.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/specs/intercept.e2e.cy.ts b/cypress/e2e/specs/intercept.e2e.cy.ts index 862defdd91..645273ea73 100644 --- a/cypress/e2e/specs/intercept.e2e.cy.ts +++ b/cypress/e2e/specs/intercept.e2e.cy.ts @@ -1,8 +1,6 @@ -/* eslint-disable @typescript-eslint/no-empty-function */ import { FarmPage } from "../pages/farm-page.po.cy"; import { SwapPage, TokenCatalog } from "../pages/swap-page.po.cy" import { DEFAULT_URL, TAG, } from "../selectors/constants.cy" -import { HeaderLocators } from "../selectors/selectors.cy" const tokenCatalog = new TokenCatalog() const farm = new FarmPage() @@ -10,13 +8,7 @@ describe('Intercept', { tags: TAG.regression }, () => { before(() => { SwapPage.open(DEFAULT_URL) }) - beforeEach(() => { - cy.reload() - cy.setCookie('myCookie', 'cookieValue'); - }) - afterEach(() => { - cy.clearCookie('myCookie') - }) + describe('Swap', () => { it('Should get route successfully', () => { cy.intercept('GET', '**/routes?**').as('get-route') @@ -26,16 +18,16 @@ describe('Intercept', { tags: TAG.regression }, () => { describe('Pools', () => { it('Should get pool, farm list successfully', () => { + SwapPage.goToPoolPage() cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') cy.intercept('GET', '**/pools?**').as('get-pool-list') - SwapPage.goToPoolPage() 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) }) it('Should be displayed APR and TVL values', () => { + cy.reload() cy.intercept('GET', '**/pools?**').as('get-pools') - SwapPage.goToPoolPage() cy.wait('@get-pools', { timeout: 20000 }).its('response.body.data').then(response => { const totalPools = response.pools.length; const count = response.pools.reduce((acc: number, pool: { totalValueLockedUsd: string; apr: string }) => { @@ -51,6 +43,7 @@ describe('Intercept', { tags: TAG.regression }, () => { describe('Farms', () => { it('Should get pool, farm list successfully', () => { + cy.reload() cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') cy.intercept('GET', '**/pools?**').as('get-pool-list') SwapPage.goToFarmPage() @@ -67,6 +60,7 @@ describe('Intercept', { tags: TAG.regression }, () => { describe('My Pools', () => { it('Should get farm list successfully', () => { + cy.reload() cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') SwapPage.goToMyPoolsPage() cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200) From d4e5381b747f5939ba5794ac8c8cd82bb855bdf8 Mon Sep 17 00:00:00 2001 From: ltthienn Date: Wed, 22 Nov 2023 17:48:35 +0700 Subject: [PATCH 6/6] Update tests --- cypress/e2e/specs/intercept.e2e.cy.ts | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/cypress/e2e/specs/intercept.e2e.cy.ts b/cypress/e2e/specs/intercept.e2e.cy.ts index 645273ea73..384570e5c7 100644 --- a/cypress/e2e/specs/intercept.e2e.cy.ts +++ b/cypress/e2e/specs/intercept.e2e.cy.ts @@ -5,10 +5,15 @@ const tokenCatalog = new TokenCatalog() const farm = new FarmPage() describe('Intercept', { tags: TAG.regression }, () => { - before(() => { + beforeEach(() => { SwapPage.open(DEFAULT_URL) }) + afterEach(() => { + cy.clearCookies(); + cy.clearLocalStorage(); + }) + describe('Swap', () => { it('Should get route successfully', () => { cy.intercept('GET', '**/routes?**').as('get-route') @@ -18,16 +23,16 @@ describe('Intercept', { tags: TAG.regression }, () => { describe('Pools', () => { it('Should get pool, farm list successfully', () => { - SwapPage.goToPoolPage() cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') cy.intercept('GET', '**/pools?**').as('get-pool-list') + SwapPage.goToPoolPage() 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) }) it('Should be displayed APR and TVL values', () => { - cy.reload() cy.intercept('GET', '**/pools?**').as('get-pools') + SwapPage.goToPoolPage() cy.wait('@get-pools', { timeout: 20000 }).its('response.body.data').then(response => { const totalPools = response.pools.length; const count = response.pools.reduce((acc: number, pool: { totalValueLockedUsd: string; apr: string }) => { @@ -41,9 +46,16 @@ describe('Intercept', { tags: TAG.regression }, () => { }) }) + describe('My Pools', () => { + it('Should get farm list successfully', () => { + cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') + SwapPage.goToMyPoolsPage() + cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200) + }) + }) + describe('Farms', () => { it('Should get pool, farm list successfully', () => { - cy.reload() cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') cy.intercept('GET', '**/pools?**').as('get-pool-list') SwapPage.goToFarmPage() @@ -57,13 +69,4 @@ describe('Intercept', { tags: TAG.regression }, () => { }) }) }) - - describe('My Pools', () => { - it('Should get farm list successfully', () => { - cy.reload() - cy.intercept('GET', '**/farm-pools?**').as('get-farm-list') - SwapPage.goToMyPoolsPage() - cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200) - }) - }) }) \ No newline at end of file