From 84040be6e6cd99badc3d3944fc652d00b6b90beb Mon Sep 17 00:00:00 2001 From: ltthienn Date: Wed, 15 Nov 2023 15:33:38 +0700 Subject: [PATCH] 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({ } /> - +