Skip to content

Commit

Permalink
QA-58 | E2E | Limit Order - Add selling rate tests (#2305)
Browse files Browse the repository at this point in the history
* Add sell rate tests
  • Loading branch information
ltthienn authored Oct 18, 2023
1 parent 6febaf0 commit 367fa49
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 22 deletions.
10 changes: 10 additions & 0 deletions cypress/e2e/pages/limit-order.po.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ export const LimitOder = {
getCurrentTokenBuy(text: myCallbackType<string>) {
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
})
}
}
10 changes: 5 additions & 5 deletions cypress/e2e/selectors/constants.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/selectors/selectors.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/specs/connect-wallet.e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 19 additions & 14 deletions cypress/e2e/specs/limit-order.e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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])
Expand All @@ -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])
Expand All @@ -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')
})
})
})
})
1 change: 1 addition & 0 deletions src/components/swapv2/LimitOrder/LimitOrderForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ const LimitOrderForm = forwardRef<LimitOrderFormHandle, Props>(function LimitOrd
<NumericalInput
maxLength={50}
style={{ fontSize: 14, height: INPUT_HEIGHT }}
data-testid="input-selling-rate"
value={displayRate}
onUserInput={onChangeRate}
onFocus={trackingTouchInput}
Expand Down

0 comments on commit 367fa49

Please sign in to comment.