Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into test-stg
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Nov 8, 2023
2 parents 651295d + 93cb63d commit f672e5d
Show file tree
Hide file tree
Showing 123 changed files with 7,772 additions and 1,403 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ cypress/fixtures/example.json
.vim
target/

*.tsbuildinfo
2 changes: 1 addition & 1 deletion cypress/e2e/pages/cross-chain.po.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const CrossChain = {
},

checkLoadedPage() {
return cy.get(CrossChainLocators.rechartsSurface, { timeout: 20000 }).should(() => { }).then($obj => {
return cy.get(CrossChainLocators.rechartsSurface, { timeout: 20000 }).should('be.visible').then($obj => {
if ($obj.length > 0) {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/pages/swap-page.po.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class TokenCatalog {
}

getWhitelistTokens(list: myCallbackType<string[]>) {
cy.getList(TokenCatalogLocators.lblRowInWhiteList, list)
cy.getList(TokenCatalogLocators.lblTokenSymbol, list)
}

getNoResultsFound(text: myCallbackType<string>) {
Expand Down
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', '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']
'Ethereum': ['BAND', 'ETH', 'USDT', 'USDC', '1INCH'],
'Arbitrum': ['ANGLE', 'ARB', 'USDT', 'USDC.e', 'BOB'],
'Optimism': ['BOND', 'ETH', 'USDT', 'USDC', 'BOB'],
'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e', 'BUSD.e'],
'BNB': ['RICE', 'BUSD', 'USDT', 'USDC', 'BOB']
}

export const NETWORK_LIST = ['Ethereum', 'Arbitrum', 'Optimism', 'Avalanche', 'BNB Chain', 'Polygon PoS', 'Fantom', 'Linea', 'Base']
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/selectors/selectors.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const TokenCatalogLocators = {
txtToken: '[data-testid=token-search-input]',
lblFavoriteToken: '[data-testid=favorite-token]',
lblRowInWhiteList: '[data-testid=token-item]',
lblTokenSymbol: '[data-testid=token-symbol]',
lblNotFound: '[data-testid=no-token-result]',
iconFavorite: '[data-testid=button-favorite-token]',
iconRemoveImportedToken: '[data-testid=button-remove-import-token]',
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/specs/connect-wallet.e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Metamask Extension tests', { tags: TAG.regression }, () => {
SwapPage.connectWallet()
})

it('Redirects to swap page when a user has already connected a wallet', () => {
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')
Expand Down
16 changes: 14 additions & 2 deletions cypress/e2e/specs/cross-chain.e2e.cy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { CrossChain } from "../pages/cross-chain.po.cy"
import { SwapPage } from "../pages/swap-page.po.cy"
import { DEFAULT_URL, NETWORK, TAG } from "../selectors/constants.cy"

import { DEFAULT_NETWORK, DEFAULT_URL, NETWORK, TAG } from "../selectors/constants.cy"

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) {
Expand All @@ -18,6 +20,16 @@ describe(`Cross-chain on ${NETWORK}`, { tags: TAG.regression }, () => {
it('The network should be changed successfully', () => {
const networkIn = CrossChain.changeNetwork([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
})
}
CrossChain.getCurrentNetworkIn().then((currentNetworkIn) => {
expect(currentNetworkIn).to.equal(networkIn)
})
Expand Down
48 changes: 33 additions & 15 deletions cypress/e2e/specs/limit-order.e2e.cy.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
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"
import { Network, SwapPage, TokenCatalog } from "../pages/swap-page.po.cy"
import { DEFAULT_URL, NETWORK, NORESULTS_TEXT, TAG, TOKEN_SYMBOLS, UNWHITELIST_SYMBOL_TOKENS } from "../selectors/constants.cy"

const tokenSymbols = TOKEN_SYMBOLS[NETWORK]

const tokenCatalog = new TokenCatalog();

const netw = new Network()

describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => {
beforeEach(() => {
SwapPage.open(DEFAULT_URL)
SwapPage.goToLimitOrder()
LimitOder.checkGetStartedDisplay().then((checked) => {
if (checked === true) {
LimitOder.clickGetStarted()
}
})
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()
}
})
})
it('Should be added, selected and removed favorite token sell', () => {
LimitOder.selectTokenSell().addFavoriteToken([tokenSymbols[0], tokenSymbols[4]])
tokenCatalog.getFavoriteTokens((list) => {
Expand All @@ -34,7 +48,16 @@ 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) => {
Expand All @@ -51,9 +74,7 @@ describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => {
expect(list).not.to.include.members([tokenSymbols[0]])
})
})
})

describe('Select token by symbol', () => {
it('Should be selected token sell by symbol successfully', () => {
LimitOder.selectTokenSell().selectTokenBySymbol(tokenSymbols[0])
LimitOder.getCurrentTokenSell((text) => {
Expand Down Expand Up @@ -81,18 +102,15 @@ describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => {
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')
})
})
})

describe('Messages', () => {

it('Verify error message when insufficient balance', () => {
LimitOder.getBalanceIn((text) => {
LimitOder.setAmountIn(String(Number(text) + 1))
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/specs/swap-page.e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const tokenCatalog = new TokenCatalog();
describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => {
beforeEach(() => {
SwapPage.open(DEFAULT_URL)
SwapPage.connectWallet()
SwapPage.getStatusConnectedWallet()
})

describe('Select token in favorite tokens list', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/connectWalletCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ declare global {

Cypress.Commands.add('connectWallet', () => {
// feature changed => temporary comment
// cy.get(WalletLocators.chkAcceptTerm).click()
cy.get(WalletLocators.chkAcceptTerm).click()
cy.get(WalletLocators.btnMetaMask).click()
})
117 changes: 59 additions & 58 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,65 @@
s.parentNode.insertBefore(g, s)
})()
</script>

<script>
!(function () {
var analytics = (window.analytics = window.analytics || [])
if (!analytics.initialize)
if (analytics.invoked) window.console && console.error && console.error('Segment snippet included twice.')
else {
analytics.invoked = !0
analytics.methods = [
'trackSubmit',
'trackClick',
'trackLink',
'trackForm',
'pageview',
'identify',
'reset',
'group',
'track',
'ready',
'alias',
'debug',
'page',
'once',
'off',
'on',
'addSourceMiddleware',
'addIntegrationMiddleware',
'setAnonymousId',
'addDestinationMiddleware',
]
analytics.factory = function (e) {
return function () {
if (window.analytics.initialized) return window.analytics[e].apply(window.analytics, arguments)
var i = Array.prototype.slice.call(arguments)
i.unshift(e)
analytics.push(i)
return analytics
}
}
for (var i = 0; i < analytics.methods.length; i++) {
var key = analytics.methods[i]
analytics[key] = analytics.factory(key)
}
analytics.load = function (key, i) {
var t = document.createElement('script')
t.type = 'text/javascript'
t.async = !0
t.src = '/libs/red2.js'
var n = document.getElementsByTagName('script')[0]
n.parentNode.insertBefore(t, n)
analytics._loadOptions = i
}
analytics._writeKey = 'DgnqvAHbWsKaPnkdvC19EMC8DbXh1G52'
analytics.SNIPPET_VERSION = '4.16.1'
analytics.load('DgnqvAHbWsKaPnkdvC19EMC8DbXh1G52')
analytics.page()
}
})()
</script>
</head>

<body>
Expand Down Expand Up @@ -220,64 +279,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script>
!(function () {
var analytics = (window.analytics = window.analytics || [])
if (!analytics.initialize)
if (analytics.invoked) window.console && console.error && console.error('Segment snippet included twice.')
else {
analytics.invoked = !0
analytics.methods = [
'trackSubmit',
'trackClick',
'trackLink',
'trackForm',
'pageview',
'identify',
'reset',
'group',
'track',
'ready',
'alias',
'debug',
'page',
'once',
'off',
'on',
'addSourceMiddleware',
'addIntegrationMiddleware',
'setAnonymousId',
'addDestinationMiddleware',
]
analytics.factory = function (e) {
return function () {
if (window.analytics.initialized) return window.analytics[e].apply(window.analytics, arguments)
var i = Array.prototype.slice.call(arguments)
i.unshift(e)
analytics.push(i)
return analytics
}
}
for (var i = 0; i < analytics.methods.length; i++) {
var key = analytics.methods[i]
analytics[key] = analytics.factory(key)
}
analytics.load = function (key, i) {
var t = document.createElement('script')
t.type = 'text/javascript'
t.async = !0
t.src = '/libs/red2.js'
var n = document.getElementsByTagName('script')[0]
n.parentNode.insertBefore(t, n)
analytics._loadOptions = i
}
analytics._writeKey = 'pe0ARTOeWYLV8SG0Dz7Vcs5YkDS9vT9Y'
analytics.SNIPPET_VERSION = '4.16.1'
analytics.load('pe0ARTOeWYLV8SG0Dz7Vcs5YkDS9vT9Y')
analytics.page()
}
})()
</script>
</body>

</html>
37 changes: 28 additions & 9 deletions src/assets/svg/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/svg/zap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f672e5d

Please sign in to comment.