From 367fa49020f8899ad42814cf7b15926a63857ce5 Mon Sep 17 00:00:00 2001 From: ltthienn <132639843+ltthienn@users.noreply.github.com> Date: Wed, 18 Oct 2023 09:01:45 +0700 Subject: [PATCH] QA-58 | E2E | Limit Order - Add selling rate tests (#2305) * Add sell rate tests --- cypress/e2e/pages/limit-order.po.cy.ts | 10 ++++++ cypress/e2e/selectors/constants.cy.ts | 10 +++--- cypress/e2e/selectors/selectors.cy.ts | 3 +- cypress/e2e/specs/connect-wallet.e2e.cy.ts | 4 +-- cypress/e2e/specs/limit-order.e2e.cy.ts | 33 +++++++++++-------- .../swapv2/LimitOrder/LimitOrderForm.tsx | 1 + 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/cypress/e2e/pages/limit-order.po.cy.ts b/cypress/e2e/pages/limit-order.po.cy.ts index 6b75549119..9f69cdadc2 100644 --- a/cypress/e2e/pages/limit-order.po.cy.ts +++ b/cypress/e2e/pages/limit-order.po.cy.ts @@ -21,4 +21,14 @@ export const LimitOder = { getCurrentTokenBuy(text: myCallbackType) { cy.getContent(LimitOrderLocators.dropdownTokenBuy, text) }, + + setSellingRate(text: string) { + cy.get(LimitOrderLocators.txtSellingRate).click().type(text) + }, + + getSellingRate() { + return cy.get(LimitOrderLocators.txtSellingRate).invoke('val').then(value => { + return value + }) + } } diff --git a/cypress/e2e/selectors/constants.cy.ts b/cypress/e2e/selectors/constants.cy.ts index 4376474012..f015f87d6c 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', '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'] + 'Ethereum': ['BAND', 'DAI', 'USDT', 'USDC', '1INCH'], + 'Arbitrum': ['ANGLE', 'DAI', 'USDT', 'USDC.e', 'MAI'], + 'Optimism': ['BOB', 'DAI', 'USDT', 'USDC', 'MAI'], + 'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e', 'MAI'], + 'BNB': ['RICE', 'DAI', 'USDT', 'USDC', 'MAI'] } export const UNWHITELIST_TOKENS = { diff --git a/cypress/e2e/selectors/selectors.cy.ts b/cypress/e2e/selectors/selectors.cy.ts index 4451a4168f..1d10220820 100644 --- a/cypress/e2e/selectors/selectors.cy.ts +++ b/cypress/e2e/selectors/selectors.cy.ts @@ -24,7 +24,8 @@ export const SwapPageLocators = { export const LimitOrderLocators = { dropdownTokenSell: '[data-testid=limit-order-input-tokena] [data-testid=token-symbol-container]', dropdownTokenBuy: '[data-testid=limit-order-input-tokenb] [data-testid=token-symbol-container]', - btnLimit: '[data-testid=limit-button]' + btnLimit: '[data-testid=limit-button]', + txtSellingRate: '[data-testid=input-selling-rate]' } export const WalletLocators = { diff --git a/cypress/e2e/specs/connect-wallet.e2e.cy.ts b/cypress/e2e/specs/connect-wallet.e2e.cy.ts index 34f9afabbb..3de9e0e8da 100644 --- a/cypress/e2e/specs/connect-wallet.e2e.cy.ts +++ b/cypress/e2e/specs/connect-wallet.e2e.cy.ts @@ -11,13 +11,13 @@ describe('Metamask Extension tests', { tags: TAG.regression }, () => { SwapPage.connectWallet() }) - it('Redirects to swap page when a user has already connected a wallet', () => { + it.skip('Redirects to swap page when a user has already connected a wallet', () => { cy.acceptMetamaskAccess() SwapPage.getStatusConnectedWallet() cy.url().should('include', '/swap') }) - it('Should approve permission to switch network', () => { + it.skip('Should approve permission to switch network', () => { if (NETWORK !== DEFAULT_NETWORK) { SwapPage.getStatusConnectedWallet() wallet.selectNetwork(NETWORK) diff --git a/cypress/e2e/specs/limit-order.e2e.cy.ts b/cypress/e2e/specs/limit-order.e2e.cy.ts index d77682cd85..4f069997a8 100644 --- a/cypress/e2e/specs/limit-order.e2e.cy.ts +++ b/cypress/e2e/specs/limit-order.e2e.cy.ts @@ -2,12 +2,8 @@ import { LimitOder } from "../pages/limit-order.po.cy" 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 } from "../selectors/constants.cy" -const unWhitelistTokens = UNWHITELIST_TOKENS[NETWORK] const tokenSymbols = TOKEN_SYMBOLS[NETWORK] -const arrAddress = [unWhitelistTokens[0].address, unWhitelistTokens[1].address, unWhitelistTokens[2].address] -const arrSymbol = [unWhitelistTokens[0].symbol, unWhitelistTokens[1].symbol, unWhitelistTokens[2].symbol] - const tokenCatalog = new TokenCatalog(); @@ -20,14 +16,14 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { describe('Add/remove/select token with favorite tokens list', () => { it('Should be added, selected and removed favorite token sell', () => { - LimitOder.selectTokenSell().addFavoriteToken([tokenSymbols[0], tokenSymbols[1]]) + LimitOder.selectTokenSell().addFavoriteToken([tokenSymbols[0], tokenSymbols[4]]) tokenCatalog.getFavoriteTokens((list) => { - expect(list).to.include.members([tokenSymbols[1]]) + expect(list).to.include.members([tokenSymbols[4]]) }) - tokenCatalog.selectFavoriteToken(tokenSymbols[1]) + tokenCatalog.selectFavoriteToken(tokenSymbols[4]) LimitOder.getCurrentTokenSell((text) => { - expect(text).to.equal(tokenSymbols[1]) + expect(text).to.equal(tokenSymbols[4]) }) LimitOder.selectTokenSell() tokenCatalog.removeFavoriteToken(tokenSymbols[0]) @@ -37,14 +33,14 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { }) it('Should be added, selected and removed favorite token buy', () => { - LimitOder.selectTokenBuy().addFavoriteToken([tokenSymbols[0], tokenSymbols[1]]) + LimitOder.selectTokenBuy().addFavoriteToken([tokenSymbols[0], tokenSymbols[4]]) tokenCatalog.getFavoriteTokens((list) => { - expect(list).to.include.members([tokenSymbols[1]]) + expect(list).to.include.members([tokenSymbols[4]]) }) - tokenCatalog.selectFavoriteToken(tokenSymbols[1]) + tokenCatalog.selectFavoriteToken(tokenSymbols[4]) LimitOder.getCurrentTokenBuy((text) => { - expect(text).to.equal(tokenSymbols[1]) + expect(text).to.equal(tokenSymbols[4]) }) LimitOder.selectTokenBuy() tokenCatalog.removeFavoriteToken(tokenSymbols[0]) @@ -69,18 +65,27 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { }) }) - it('Should be unselected tokenIn not exist in whitelist', () => { + it('Should be unselected token sell not exist in whitelist', () => { LimitOder.selectTokenSell().searchToken(UNWHITELIST_SYMBOL_TOKENS[0]) tokenCatalog.getNoResultsFound((text) => { expect(text).to.equal(NORESULTS_TEXT) }) }) - it('Should be unselected tokenOut not exist in whitelist', () => { + it('Should be unselected token buy not exist in whitelist', () => { LimitOder.selectTokenBuy().searchToken(UNWHITELIST_SYMBOL_TOKENS[0]) tokenCatalog.getNoResultsFound((text) => { expect(text).to.equal(NORESULTS_TEXT) }) }) }) + + describe('Sell rate', () => { + it('Able to set selling rate by number', () => { + LimitOder.setSellingRate('1.2345..67') + LimitOder.getSellingRate().then((value) => { + cy.wrap(value).should('eq', '1.234567') + }) + }) + }) }) \ No newline at end of file diff --git a/src/components/swapv2/LimitOrder/LimitOrderForm.tsx b/src/components/swapv2/LimitOrder/LimitOrderForm.tsx index 3cae177bfb..35d7888231 100644 --- a/src/components/swapv2/LimitOrder/LimitOrderForm.tsx +++ b/src/components/swapv2/LimitOrder/LimitOrderForm.tsx @@ -739,6 +739,7 @@ const LimitOrderForm = forwardRef(function LimitOrd