diff --git a/.env.dev b/.env.dev index e455cb9425..354a474d17 100644 --- a/.env.dev +++ b/.env.dev @@ -19,6 +19,7 @@ VITE_TRANSAK_URL=https://staging-global.transak.com VITE_TRANSAK_API_KEY=327b8b63-626b-4376-baf2-70a304c48488 VITE_KS_SETTING_API=https://ks-setting.dev.kyberengineering.io/api +VITE_BLACKJACK_API=https://blackjack.dev.kyberengineering.io/api VITE_GTM_ID= diff --git a/.env.production b/.env.production index db6168b726..dad530c4b1 100644 --- a/.env.production +++ b/.env.production @@ -19,6 +19,7 @@ VITE_TRANSAK_URL=https://global.transak.com VITE_TRANSAK_API_KEY=48949c0b-2d20-4e3a-a311-51ca91ae8c0d VITE_KS_SETTING_API=https://ks-setting.kyberswap.com/api +VITE_BLACKJACK_API=https://blackjack.kyberswap.com/api VITE_GTM_ID=GTM-TRQCJ8F diff --git a/.env.stg b/.env.stg index 984c5d45eb..085738be95 100644 --- a/.env.stg +++ b/.env.stg @@ -18,6 +18,7 @@ VITE_TRANSAK_URL=https://staging-global.transak.com VITE_TRANSAK_API_KEY=327b8b63-626b-4376-baf2-70a304c48488 VITE_KS_SETTING_API=https://ks-setting.stg.kyberengineering.io/api +VITE_BLACKJACK_API=https://blackjack.stg.kyberengineering.io/api VITE_GTM_ID= diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cd4eff2f0b..26e8d1ab17 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -71,10 +71,10 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Set up Node.js 18.15.0 + - name: Set up Node.js uses: actions/setup-node@v1 with: - node-version: 18.15.0 + node-version: 20.9.0 registry-url: 'https://npm.pkg.github.com' scope: '@kybernetwork' @@ -147,10 +147,10 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Set up Node.js 18.15.0 + - name: Set up Node.js uses: actions/setup-node@v1 with: - node-version: 18.15.0 + node-version: 20.9.0 registry-url: 'https://npm.pkg.github.com' scope: '@kybernetwork' diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 170fa2a8d9..a1e9cf6fc0 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -70,10 +70,10 @@ jobs: - name: Check out Git repository uses: actions/checkout@v3 - - name: Set up Node.js 18.15.0 + - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: 18.15.0 + node-version: 20.9.0 registry-url: 'https://npm.pkg.github.com' scope: '@kybernetwork' @@ -84,9 +84,9 @@ jobs: - name: Install linux deps run: | - sudo apt-get install --no-install-recommends -y \ - fluxbox \ - xvfb + sudo apt-get install --no-install-recommends -y \ + fluxbox \ + xvfb - name: Yarn Build env: @@ -118,14 +118,14 @@ jobs: yarn preview & yarn test-e2e -c baseUrl='http://127.0.0.1:4173/' -e grepTags=smoke,NETWORK=Ethereum env: - DISPLAY: :0.0 + DISPLAY: :0.0 - name: Archive e2e artifacts uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 if: always() with: - name: e2e-artifacts - path: | - cypress/videos - cypress/screenshots + name: e2e-artifacts + path: | + cypress/videos + cypress/screenshots continue-on-error: true diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 2c5e51d076..795a6814b0 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -70,10 +70,10 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Set up Node.js 18.15.0 + - name: Set up Node.js uses: actions/setup-node@v1 with: - node-version: 18.15.0 + node-version: 20.9.0 registry-url: 'https://npm.pkg.github.com' scope: '@kybernetwork' @@ -97,11 +97,11 @@ jobs: path: /tmp/.buildx-cache key: ${{ runner.os }}-${{ env.SERVICE }}-buildx - # - name: Restore node_modules - # uses: actions/cache@v2 - # with: - # path: '**/node_modules' - # key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + - name: Restore node_modules + uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependences uses: bahmutov/npm-install@HEAD @@ -144,10 +144,10 @@ jobs: - name: Check out Git repository uses: actions/checkout@v2 - - name: Set up Node.js 18.15.0 + - name: Set up Node.js uses: actions/setup-node@v1 with: - node-version: 18.15.0 + node-version: 20.9.0 registry-url: 'https://npm.pkg.github.com' scope: '@kybernetwork' diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4fc695a362..b5616604a6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -38,18 +38,18 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Set up Node.js 18.15.0 + - name: Set up Node.js uses: actions/setup-node@v1 with: - node-version: 18.15.0 + node-version: 20.9.0 registry-url: 'https://npm.pkg.github.com' scope: '@kybernetwork' - # - name: Restore node_modules - # uses: actions/cache@v2 - # with: - # path: '**/node_modules' - # key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + - name: Restore node_modules + uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependences uses: bahmutov/npm-install@HEAD diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index ad37319e3d..8649a988e8 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -12,15 +12,15 @@ jobs: strategy: fail-fast: false matrix: - network: ['Ethereum', 'Arbitrum', 'Optimism', 'Avalanche', 'BNB'] + network: ['Ethereum', 'Arbitrum', 'Optimism', 'Avalanche', 'BNB Chain'] steps: - name: Trigger Code Checkout uses: actions/checkout@v3 - - name: Set up Node.js 18.15.0 + - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: 18.15.0 + node-version: 20.9.0 registry-url: 'https://npm.pkg.github.com' scope: '@kybernetwork' diff --git a/.nvmrc b/.nvmrc index 2f3b977c5b..c946e1df49 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v18.15.0 \ No newline at end of file +v20.9.0 \ No newline at end of file diff --git a/cypress/e2e/pages/cross-chain.po.cy.ts b/cypress/e2e/pages/cross-chain.po.cy.ts new file mode 100644 index 0000000000..52f647f14b --- /dev/null +++ b/cypress/e2e/pages/cross-chain.po.cy.ts @@ -0,0 +1,50 @@ +import { NETWORK_LIST } from "../selectors/constants.cy" +import { CrossChainLocators, NetworkLocators } from "../selectors/selectors.cy" + +export const CrossChain = { + + closeUnderstandPopup() { + cy.get(CrossChainLocators.btnUnderstand).click() + }, + + selectNetworkIn(networkName: string) { + cy.get(CrossChainLocators.btnNetworkIn).click() + cy.get(NetworkLocators.btnNetwork).contains(networkName).click({ force: true }) + + }, + + selectNetworkOut(networkName: string) { + cy.get(CrossChainLocators.btnNetworkOut).click() + cy.get(NetworkLocators.btnNetwork).contains(networkName).click({ force: true }) + }, + + changeNetwork(oldNetwork: string[]) { + let random = 0 + do { + random = Math.floor(Math.random() * NETWORK_LIST.length) + } while (oldNetwork.includes(NETWORK_LIST[random]) === true) + + return NETWORK_LIST[random] + }, + + checkLoadedPage() { + return cy.get(CrossChainLocators.rechartsSurface, { timeout: 20000 }).should(() => { }).then($obj => { + if ($obj.length > 0) { + return true + } + return false + }) + }, + + getCurrentNetworkIn() { + return cy.get(CrossChainLocators.btnNetworkIn).invoke('text').then(network => { + return network + }) + }, + + getCurrentNetworkOut() { + return cy.get(CrossChainLocators.btnNetworkOut).invoke('text').then(network => { + return network + }) + }, +} diff --git a/cypress/e2e/pages/limit-order.po.cy.ts b/cypress/e2e/pages/limit-order.po.cy.ts index 708437da71..de95c61aa1 100644 --- a/cypress/e2e/pages/limit-order.po.cy.ts +++ b/cypress/e2e/pages/limit-order.po.cy.ts @@ -5,6 +5,19 @@ export interface myCallbackType { } export const LimitOder = { + checkGetStartedDisplay() { + return cy.get(LimitOrderLocators.btnGetStarted, { timeout: 10000 }).should(() => { }).then($obj => { + if ($obj.length > 0) { + return true + } + return false + }) + }, + + clickGetStarted() { + cy.get(LimitOrderLocators.btnGetStarted, { timeout: 10000 }).click({ force: true }) + }, + selectTokenSell(): TokenCatalog { cy.selectToken(LimitOrderLocators.dropdownTokenSell) return new TokenCatalog() diff --git a/cypress/e2e/pages/swap-page.po.cy.ts b/cypress/e2e/pages/swap-page.po.cy.ts index a45936195a..86e69682d7 100644 --- a/cypress/e2e/pages/swap-page.po.cy.ts +++ b/cypress/e2e/pages/swap-page.po.cy.ts @@ -1,4 +1,4 @@ -import { HeaderLocators, LimitOrderLocators, NetworkLocators, SwapPageLocators, TokenCatalogLocators, WalletLocators } from "../selectors/selectors.cy" +import { CrossChainLocators, HeaderLocators, LimitOrderLocators, NetworkLocators, SwapPageLocators, TokenCatalogLocators, WalletLocators } from "../selectors/selectors.cy" export interface myCallbackType { (myArgument: T): void @@ -41,6 +41,10 @@ export const SwapPage = { cy.get(LimitOrderLocators.btnLimit).click() }, + goToCrossChain() { + cy.get(CrossChainLocators.btnCrossChain).click() + }, + goToFarmPage() { cy.get(HeaderLocators.dropdownEarn).click({ force: true }) cy.get(HeaderLocators.lblFarms).click({ force: true }) diff --git a/cypress/e2e/selectors/constants.cy.ts b/cypress/e2e/selectors/constants.cy.ts index f015f87d6c..f50ff81317 100644 --- a/cypress/e2e/selectors/constants.cy.ts +++ b/cypress/e2e/selectors/constants.cy.ts @@ -19,6 +19,8 @@ export const TOKEN_SYMBOLS = { 'BNB': ['RICE', 'DAI', 'USDT', 'USDC', 'MAI'] } +export const NETWORK_LIST = ['Ethereum', 'Arbitrum', 'Optimism', 'Avalanche', 'BNB Chain', 'Polygon PoS', 'Fantom', 'Linea', 'Base'] + export const UNWHITELIST_TOKENS = { "Ethereum": [ diff --git a/cypress/e2e/selectors/selectors.cy.ts b/cypress/e2e/selectors/selectors.cy.ts index b36d6b9868..0ad9015779 100644 --- a/cypress/e2e/selectors/selectors.cy.ts +++ b/cypress/e2e/selectors/selectors.cy.ts @@ -28,7 +28,16 @@ export const LimitOrderLocators = { btnLimit: '[data-testid=limit-button]', txtSellingRate: '[data-testid=input-selling-rate]', lblBalanceIn: '[data-testid=limit-order-input-tokena] [data-testid=balance]', - lblErrorMessage: '[data-testid=error-message]' + lblErrorMessage: '[data-testid=error-message]', + btnGetStarted: '[data-testid=get-started-button]' +} + +export const CrossChainLocators = { + btnCrossChain: '[data-testid=cross-chain-tab]', + btnNetworkIn: '[data-testid=swap-currency-input] [data-testid=network-button]', + btnNetworkOut: '[data-testid=swap-currency-output] [data-testid=network-button]', + btnUnderstand: '[data-testid=understand-button]', + rechartsSurface: '.recharts-surface' //it's in the library so don't use data-testid } export const WalletLocators = { @@ -40,7 +49,7 @@ export const WalletLocators = { export const NetworkLocators = { btnSelectNetwork: '[data-testid=select-network]', - btnNetwork: '[data-testid=network-button]', + btnNetwork: '[data-testid=network-list]', } export const HeaderLocators = { diff --git a/cypress/e2e/specs/connect-wallet.e2e.cy.ts b/cypress/e2e/specs/connect-wallet.e2e.cy.ts index 3de9e0e8da..34f9afabbb 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.skip('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', () => { cy.acceptMetamaskAccess() SwapPage.getStatusConnectedWallet() cy.url().should('include', '/swap') }) - it.skip('Should approve permission to switch network', () => { + it('Should approve permission to switch network', () => { if (NETWORK !== DEFAULT_NETWORK) { SwapPage.getStatusConnectedWallet() wallet.selectNetwork(NETWORK) diff --git a/cypress/e2e/specs/cross-chain.e2e.cy.ts b/cypress/e2e/specs/cross-chain.e2e.cy.ts new file mode 100644 index 0000000000..5580eeb4fb --- /dev/null +++ b/cypress/e2e/specs/cross-chain.e2e.cy.ts @@ -0,0 +1,37 @@ +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" + + +describe(`Cross-chain on ${NETWORK}`, { tags: TAG.regression }, () => { + beforeEach(() => { + SwapPage.open(DEFAULT_URL) + SwapPage.goToCrossChain() + CrossChain.checkLoadedPage().then((checked) => { + if (checked === true) { + CrossChain.closeUnderstandPopup() + } + }) + }) + + describe('Select network', () => { + it('The network should be changed successfully', () => { + const networkIn = CrossChain.changeNetwork([NETWORK]) + CrossChain.selectNetworkIn(networkIn) + CrossChain.getCurrentNetworkIn().then((currentNetworkIn) => { + expect(currentNetworkIn).to.equal(networkIn) + }) + + CrossChain.getCurrentNetworkOut().then((currentNetworkOut) => { + const networkOut = CrossChain.changeNetwork([networkIn, currentNetworkOut]) + cy.wait(1000) + CrossChain.selectNetworkOut(networkOut) + CrossChain.getCurrentNetworkOut().then((currentNetworkOut) => { + expect(currentNetworkOut).to.equal(networkOut) + }) + + }) + }) + + }) +}) \ No newline at end of file diff --git a/cypress/e2e/specs/limit-order.e2e.cy.ts b/cypress/e2e/specs/limit-order.e2e.cy.ts index 5bd9d4e22c..19310474c8 100644 --- a/cypress/e2e/specs/limit-order.e2e.cy.ts +++ b/cypress/e2e/specs/limit-order.e2e.cy.ts @@ -4,14 +4,17 @@ import { DEFAULT_URL, NETWORK, NORESULTS_TEXT, NOTOKENS_TEXT, TAG, TOKEN_SYMBOLS const tokenSymbols = TOKEN_SYMBOLS[NETWORK] - const tokenCatalog = new TokenCatalog(); - describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => { beforeEach(() => { SwapPage.open(DEFAULT_URL) SwapPage.goToLimitOrder() + LimitOder.checkGetStartedDisplay().then((checked) => { + if (checked === true) { + LimitOder.clickGetStarted() + } + }) }) describe('Add/remove/select token with favorite tokens list', () => { diff --git a/cypress/support/connectWalletCommands.ts b/cypress/support/connectWalletCommands.ts index 556542d341..80959f22e0 100644 --- a/cypress/support/connectWalletCommands.ts +++ b/cypress/support/connectWalletCommands.ts @@ -12,6 +12,7 @@ declare global { } Cypress.Commands.add('connectWallet', () => { - cy.get(WalletLocators.chkAcceptTerm).click() + // feature changed => temporary comment + // cy.get(WalletLocators.chkAcceptTerm).click() cy.get(WalletLocators.btnMetaMask).click() }) diff --git a/index.html b/index.html index 747986cc54..745dafecb9 100644 --- a/index.html +++ b/index.html @@ -1,62 +1,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - KyberSwap - Trading Smart - - - - + + + - - - - - -
- - - -
-
- -