From bfb62a2af769bfe243d2bdb2a0ebfa0b294b210b Mon Sep 17 00:00:00 2001 From: MariuSZ <112616777+MariuszSzpyt@users.noreply.github.com> Date: Wed, 6 Dec 2023 15:40:43 +0100 Subject: [PATCH] Feature/microapps prod checks (#356) --- .github/workflows/ui-prod-smoke-test.yml | 71 +++++----- package.json | 1 + .../microapps-prod-main.deposit.test.ts | 108 ++++++++++++++++ .../microapps-prod-main.swap.test.ts | 122 ++++++++++++++++++ .../microapps-prod-main.wallet.test.ts | 110 ++++++++++++++++ .../microapps-ui-main.withdraw.test.ts | 108 ++++++++++++++++ .../frontend/microapps-pages/WalletWrapper.ts | 36 ++++++ 7 files changed, 519 insertions(+), 37 deletions(-) create mode 100644 test/microapps-prod/microapps-prod-main.deposit.test.ts create mode 100644 test/microapps-prod/microapps-prod-main.swap.test.ts create mode 100644 test/microapps-prod/microapps-prod-main.wallet.test.ts create mode 100644 test/microapps-prod/microapps-ui-main.withdraw.test.ts diff --git a/.github/workflows/ui-prod-smoke-test.yml b/.github/workflows/ui-prod-smoke-test.yml index b970f3b13..4cf54c4ef 100644 --- a/.github/workflows/ui-prod-smoke-test.yml +++ b/.github/workflows/ui-prod-smoke-test.yml @@ -1,13 +1,10 @@ -name: dex UI prod smoke tests +name: Microapps UI prod smoke tests on: - workflow_dispatch: - -# repository_dispatch: -# Goncer: Old app is decomissioned types: [run-ci] + schedule: + - cron: "5 10 * * *" jobs: - setup-report: name: setup testmo report runs-on: ubuntu-latest @@ -49,24 +46,24 @@ jobs: strategy: fail-fast: false matrix: - command: ['prodUiSmoke'] + command: ["first"] runs-on: ubuntu-latest env: - API_URL: 'wss://kusama-rpc.mangata.online' + API_URL: "wss://kusama-rpc.mangata.online" UI_URL: https://app.mangata.finance/ TEST_SUDO_NAME: ${{ secrets.DEV_SUDO_NAME }} MNEMONIC_POLK: ${{ secrets.MNEMONIC_PROD_POLK }} - TEST_SCRIPT: 'test-ui' + TEST_SCRIPT: "test-ui" NODE_ENV: test SELENIUM_REMOTE_URL: http://localhost:4444/wd/hub - steps: + steps: - name: Start Selenoid Server uses: Xotabu4/selenoid-github-action@v2 with: selenoid-start-arguments: | --args "-timeout 300s" --browsers 'chrome:110.0;chrome:112.0;chrome:114.0' - + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: @@ -80,34 +77,34 @@ jobs: - name: Tsc code quality check run: yarn tsc-lint - name: ESLint code quality check - run: yarn eslint + run: yarn eslint - name: installed packages run: yarn list - name: is selenoid started? run: curl http://localhost:4444/status - + - name: Run tests - run: yarn test-ui --group=${{ matrix.command }} - + run: yarn test-microapps-prod-${{ matrix.command }} + - name: Test Report uses: dorny/test-reporter@v1 - if: success() || failure() # run this step even if previous step failed + if: success() || failure() # run this step even if previous step failed with: - name: JEST UI Tests ${{ matrix.command }} # Name of the check run which will be created - path: reports/*.xml # Path to test results - reporter: jest-junit # Format of test results + name: JEST UI Tests ${{ matrix.command }} # Name of the check run which will be created + path: reports/*.xml # Path to test results + reporter: jest-junit # Format of test results - name: Install testmo - run: npm install --no-save @testmo/testmo-cli + run: yarn global add @testmo/testmo-cli - name: Submit results to the testmo-run if: always() run: | - testmo automation:run:submit-thread \ - --instance https://mangata-finance.testmo.net \ - --run-id ${{needs.setup-report.outputs.testmo-run-id}} \ - --results reports/*.xml + testmo automation:run:submit-thread \ + --instance https://mangata-finance.testmo.net \ + --run-id ${{needs.setup-report.outputs.testmo-run-id}} \ + --results reports/*.xml env: TESTMO_URL: ${{ secrets.TESTMO_URL }} TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }} @@ -148,20 +145,20 @@ jobs: steps: - name: Install testmo - run: npm install --no-save @testmo/testmo-cli + run: yarn global add @testmo/testmo-cli - name: Complete test run run: | - npx testmo automation:run:complete \ - --instance https://mangata-finance.testmo.net \ - --run-id ${{needs.setup-report.outputs.testmo-run-id}} \ + npx testmo automation:run:complete \ + --instance https://mangata-finance.testmo.net \ + --run-id ${{needs.setup-report.outputs.testmo-run-id}} \ env: TESTMO_URL: ${{ secrets.TESTMO_URL }} TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }} continue-on-error: true slack-notify-ok: - needs: [e2e-test-matrix] + needs: [e2e-test-matrix, setup-report] if: success() runs-on: ubuntu-latest @@ -171,11 +168,11 @@ jobs: uses: bryannice/gitactions-slack-notification@2.0.0 env: SLACK_INCOMING_WEBHOOK: ${{ secrets.STG_SLACK_WEBHOOK }} - SLACK_TITLE: 'PROD dex smoke UI tests - results - OK' + SLACK_TITLE: "PROD Microapps smoke UI tests - results - OK" SLACK_COLOR: "#00ff11" - SLACK_MESSAGE: 'Test succeed in [ ${{ env.TEST_SCRIPT }} ] - testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{needs.setup-report.outputs.testmo-run-id}}' - GITHUB_REF: 'https://mangata-finance.github.io/mangata-e2e/${{ github.run_number }}' + SLACK_MESSAGE: "Test succeed in [ ${{ env.TEST_SCRIPT }} ] + testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{needs.setup-report.outputs.testmo-run-id}}" + GITHUB_REF: "https://mangata-finance.github.io/mangata-e2e/${{ github.run_number }}" slack-notify-nook: needs: [e2e-test-matrix] @@ -187,8 +184,8 @@ jobs: uses: bryannice/gitactions-slack-notification@2.0.0 env: SLACK_INCOMING_WEBHOOK: ${{ secrets.STG_SLACK_WEBHOOK }} - SLACK_TITLE: 'PROD dex smoke UI tests - results - NOOK' + SLACK_TITLE: "PROD Microapps smoke UI tests - results - NOOK" SLACK_COLOR: "#ff0011" - SLACK_MESSAGE: 'Test failures [ ${{ env.TEST_SCRIPT }} ] - testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{needs.setup-report.outputs.testmo-run-id}}' - GITHUB_REF: 'https://mangata-finance.github.io/mangata-e2e/${{ github.run_number }}' + SLACK_MESSAGE: "Test failures [ ${{ env.TEST_SCRIPT }} ] + testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{needs.setup-report.outputs.testmo-run-id}}" + GITHUB_REF: "https://mangata-finance.github.io/mangata-e2e/${{ github.run_number }}" diff --git a/package.json b/package.json index de6d587d4..c6ff563e8 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,7 @@ "test-microapps-chops-second": "export CHOPSTICK_UI=true ; rm nonce.db ; rm sudo.lock; node --experimental-specifier-resolution=node --loader ts-node/esm --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --runInBand --ci --group=microappsTokens --group=microappsSwap --group=microappsPools", "test-microapps-chops-third": "export CHOPSTICK_UI=true ; rm nonce.db ; rm sudo.lock; node --experimental-specifier-resolution=node --loader ts-node/esm --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --runInBand --ci --group=microappsAccounts", "test-microapps-chops-fourth": "export CHOPSTICK_UI=true ; rm nonce.db ; rm sudo.lock; node --experimental-specifier-resolution=node --loader ts-node/esm --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --runInBand --ci --group=microappsPosition", + "test-microapps-prod-first": "export CHOPSTICK_UI=true ; rm nonce.db ; rm sudo.lock; node --experimental-specifier-resolution=node --loader ts-node/esm --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --runInBand --ci --group=microappsProdDeposit --group=microappsProdSwap --group=microappsProdWallet --group=microappsProdWithdraw", "runtimeUpgrade": " jest --verbose --ci --group=upgradeRuntime --runInBand --forceExit" }, "devDependencies": { diff --git a/test/microapps-prod/microapps-prod-main.deposit.test.ts b/test/microapps-prod/microapps-prod-main.deposit.test.ts new file mode 100644 index 000000000..ee07b39ac --- /dev/null +++ b/test/microapps-prod/microapps-prod-main.deposit.test.ts @@ -0,0 +1,108 @@ +/* + * + * @group microappsProdDeposit + */ +import { jest } from "@jest/globals"; +import { Keyring } from "@polkadot/api"; +import { WebDriver } from "selenium-webdriver"; +import { getApi, initApi } from "../../utils/api"; +import { DriverBuilder } from "../../utils/frontend/utils/Driver"; +import { + addExtraLogs, + importPolkadotExtension, +} from "../../utils/frontend/utils/Helper"; +import { AssetWallet, User } from "../../utils/User"; +import { getEnvironmentRequiredVars } from "../../utils/utils"; +import { KSM_ASSET_ID, MGA_ASSET_ID } from "../../utils/Constants"; +import { Node } from "../../utils/Framework/Node/Node"; +import "dotenv/config"; +import { + connectWallet, + setupPage, + setupPageWithState, +} from "../../utils/frontend/microapps-utils/Handlers"; +import { DepositModal } from "../../utils/frontend/microapps-pages/DepositModal"; +import { WalletWrapper } from "../../utils/frontend/microapps-pages/WalletWrapper"; + +jest.spyOn(console, "log").mockImplementation(jest.fn()); + +jest.setTimeout(1500000); +let driver: WebDriver; +let testUser1: User; + +const acc_name = "acc_automation"; +const KSM_ASSET_NAME = "KSM"; + +describe("Microapps Prod UI deposit modal tests", () => { + beforeAll(async () => { + try { + getApi(); + } catch (e) { + await initApi(); + } + + driver = await DriverBuilder.getInstance(); + await importPolkadotExtension(driver); + + const keyring = new Keyring({ type: "sr25519" }); + const node = new Node(getEnvironmentRequiredVars().chainUri); + await node.connect(); + + testUser1 = new User(keyring); + testUser1.addFromMnemonic( + keyring, + getEnvironmentRequiredVars().mnemonicPolkadot, + ); + + testUser1.addAsset(KSM_ASSET_ID); + testUser1.addAsset(MGA_ASSET_ID); + await testUser1.refreshAmounts(AssetWallet.BEFORE); + + await setupPage(driver); + await connectWallet(driver, "Polkadot", acc_name); + }); + + test("Deposit - not enough assets", async () => { + await setupPageWithState(driver, acc_name); + + const walletWrapper = new WalletWrapper(driver); + await walletWrapper.openWalletConnectionInfo(); + await walletWrapper.openDeposit(); + const depositModal = new DepositModal(driver); + const isModalVisible = await depositModal.isModalVisible(); + expect(isModalVisible).toBeTruthy(); + + await depositModal.openChainList(); + await depositModal.selectChain("Kusama"); + await depositModal.openTokensList(); + await depositModal.waitForTokenListElementsVisible(KSM_ASSET_NAME); + await depositModal.selectToken(KSM_ASSET_NAME); + await depositModal.enterValue("1"); + + await depositModal.waitForContinueState(false, 60000); + const isOriginFeeDisplayed = await depositModal.isOriginFeeDisplayed(); + expect(isOriginFeeDisplayed).toBeTruthy(); + const isDestinationFeeDisplayed = + await depositModal.isDestinationFeeDisplayed(); + expect(isDestinationFeeDisplayed).toBeTruthy(); + + const isContinueButtonEnabled = + await depositModal.isContinueButtonEnabled(); + expect(isContinueButtonEnabled).toBeFalsy(); + }); + + afterEach(async () => { + const session = await driver.getSession(); + await addExtraLogs( + driver, + expect.getState().currentTestName + " - " + session.getId(), + ); + }); + + afterAll(async () => { + const api = getApi(); + await api.disconnect(); + await driver.quit(); + DriverBuilder.destroy(); + }); +}); diff --git a/test/microapps-prod/microapps-prod-main.swap.test.ts b/test/microapps-prod/microapps-prod-main.swap.test.ts new file mode 100644 index 000000000..11b204bff --- /dev/null +++ b/test/microapps-prod/microapps-prod-main.swap.test.ts @@ -0,0 +1,122 @@ +/* + * + * @group microappsProdSwap + */ +import { jest } from "@jest/globals"; +import { WebDriver } from "selenium-webdriver"; +import { getApi, initApi } from "../../utils/api"; +import { DriverBuilder } from "../../utils/frontend/utils/Driver"; +import { Node } from "../../utils/Framework/Node/Node"; +import { + addExtraLogs, + importPolkadotExtension, +} from "../../utils/frontend/utils/Helper"; +import { Keyring } from "@polkadot/api"; +import { FIVE_MIN, KSM_ASSET_ID, MGA_ASSET_ID } from "../../utils/Constants"; +import { AssetWallet, User } from "../../utils/User"; +import { getEnvironmentRequiredVars } from "../../utils/utils"; +import { + connectWallet, + setupPage, + setupPageWithState, +} from "../../utils/frontend/microapps-utils/Handlers"; +import { Swap } from "../../utils/frontend/microapps-pages/Swap"; + +jest.setTimeout(FIVE_MIN); +jest.spyOn(console, "log").mockImplementation(jest.fn()); +let driver: WebDriver; +let testUser1: User; +const acc_name = "acc_automation"; +const MGX_ASSET_NAME = "MGX"; +const TUR_ASSET_NAME = "TUR"; + +describe("Miocroapps Prod UI swap tests", () => { + beforeAll(async () => { + try { + getApi(); + } catch (e) { + await initApi(); + } + + driver = await DriverBuilder.getInstance(); + await importPolkadotExtension(driver); + + const keyring = new Keyring({ type: "sr25519" }); + const node = new Node(getEnvironmentRequiredVars().chainUri); + await node.connect(); + + testUser1 = new User(keyring); + testUser1.addFromMnemonic( + keyring, + getEnvironmentRequiredVars().mnemonicPolkadot, + ); + + testUser1.addAsset(KSM_ASSET_ID); + testUser1.addAsset(MGA_ASSET_ID); + await testUser1.refreshAmounts(AssetWallet.BEFORE); + + await setupPage(driver); + await connectWallet(driver, "Polkadot", acc_name); + }); + + it("Swap is enabled with enough tokens", async () => { + await setupPageWithState(driver, acc_name); + const swap = new Swap(driver); + const isSwapFrameDisplayed = await swap.isDisplayed(); + expect(isSwapFrameDisplayed).toBeTruthy(); + await swap.pickPayToken(MGX_ASSET_NAME); + await swap.pickGetToken(TUR_ASSET_NAME); + await swap.setPayTokenAmount("1"); + const getTokenAmount = await swap.fetchGetAssetAmount(); + expect(parseFloat(getTokenAmount)).toBeGreaterThan(0); + + await swap.waitForSwapButtonEnabled(); + const isSwapEnabled = await swap.isSwapButtonEnabled(); + expect(isSwapEnabled).toBeTruthy(); + }); + + it("Swap details are visible & dynamic", async () => { + await setupPageWithState(driver, acc_name); + const swap = new Swap(driver); + const isSwapFrameDisplayed = await swap.isDisplayed(); + expect(isSwapFrameDisplayed).toBeTruthy(); + await swap.pickPayToken(MGX_ASSET_NAME); + await swap.pickGetToken(TUR_ASSET_NAME); + await swap.setPayTokenAmount("10"); + const getTokenAmount = await swap.fetchGetAssetAmount(); + expect(parseFloat(getTokenAmount)).toBeGreaterThan(0); + + const isTradeRateDisplayed = await swap.isTradeRateDisplayed(); + expect(isTradeRateDisplayed).toBeTruthy(); + + const areTradeDetailsDisplayed = await swap.areTradeDetailsDisplayed(); + expect(areTradeDetailsDisplayed).toBeTruthy(); + + await swap.toggleRouteDetails(); + const areRouteDetailsDisplayed = await swap.areRouteDetailsDisplayed( + MGX_ASSET_NAME, + TUR_ASSET_NAME, + ); + expect(areRouteDetailsDisplayed).toBeTruthy(); + + const minimumRecieved = await swap.fetchMinimumReceivedAmount(); + await swap.setPayTokenAmount("50"); + const minimumRecievedAfterChange = await swap.fetchMinimumReceivedAmount(); + expect(minimumRecieved).toBeLessThan(minimumRecievedAfterChange); + }); + + afterEach(async () => { + const session = await driver.getSession(); + await addExtraLogs( + driver, + expect.getState().currentTestName + " - " + session.getId(), + ); + }); + + afterAll(async () => { + const api = getApi(); + await api.disconnect(); + await driver.quit(); + DriverBuilder.destroy(); + }); +}); diff --git a/test/microapps-prod/microapps-prod-main.wallet.test.ts b/test/microapps-prod/microapps-prod-main.wallet.test.ts new file mode 100644 index 000000000..58e3320f5 --- /dev/null +++ b/test/microapps-prod/microapps-prod-main.wallet.test.ts @@ -0,0 +1,110 @@ +/* + * + * @group microappsProdWallet + */ +import { jest } from "@jest/globals"; +import { Keyring } from "@polkadot/api"; +import { WebDriver } from "selenium-webdriver"; +import { getApi, initApi } from "../../utils/api"; +import { DriverBuilder } from "../../utils/frontend/utils/Driver"; +import { + addExtraLogs, + importPolkadotExtension, +} from "../../utils/frontend/utils/Helper"; +import { AssetWallet, User } from "../../utils/User"; +import { getEnvironmentRequiredVars } from "../../utils/utils"; +import { KSM_ASSET_ID, MGA_ASSET_ID } from "../../utils/Constants"; +import { Node } from "../../utils/Framework/Node/Node"; +import "dotenv/config"; +import { + connectWallet, + setupPage, + setupPageWithState, +} from "../../utils/frontend/microapps-utils/Handlers"; +import { WalletWrapper } from "../../utils/frontend/microapps-pages/WalletWrapper"; + +jest.spyOn(console, "log").mockImplementation(jest.fn()); + +jest.setTimeout(1500000); +let driver: WebDriver; +let testUser1: User; + +const acc_name = "acc_automation"; +const KSM_ASSET_NAME = "KSM"; +const MGX_ASSET_NAME = "MGX"; +const TUR_ASSET_NAME = "TUR"; + +describe("Microapps Prod UI wallet tests", () => { + beforeAll(async () => { + try { + getApi(); + } catch (e) { + await initApi(); + } + + driver = await DriverBuilder.getInstance(); + await importPolkadotExtension(driver); + + const keyring = new Keyring({ type: "sr25519" }); + const node = new Node(getEnvironmentRequiredVars().chainUri); + await node.connect(); + + testUser1 = new User(keyring); + testUser1.addFromMnemonic( + keyring, + getEnvironmentRequiredVars().mnemonicPolkadot, + ); + + testUser1.addAsset(KSM_ASSET_ID); + testUser1.addAsset(MGA_ASSET_ID); + await testUser1.refreshAmounts(AssetWallet.BEFORE); + + await setupPage(driver); + await connectWallet(driver, "Polkadot", acc_name); + }); + + test("User can see his tokens and amounts", async () => { + await setupPageWithState(driver, acc_name); + + const walletWrapper = new WalletWrapper(driver); + await walletWrapper.openWalletConnectionInfo(); + const isKSM = await walletWrapper.isMyTokensRowDisplayed(KSM_ASSET_NAME); + expect(isKSM).toBeFalsy(); + const isMGX = await walletWrapper.isMyTokensRowDisplayed(MGX_ASSET_NAME); + expect(isMGX).toBeTruthy(); + const isTUR = await walletWrapper.isMyTokensRowDisplayed(TUR_ASSET_NAME); + expect(isTUR).toBeTruthy(); + + const mgxAmount = await walletWrapper.getMyTokensRowAmount(MGX_ASSET_NAME); + expect(parseFloat(mgxAmount)).toBeGreaterThan(0); + + const turAmount = await walletWrapper.getMyTokensRowAmount(TUR_ASSET_NAME); + expect(parseFloat(turAmount)).toBeGreaterThan(0); + }); + + test("User can see his pool positions", async () => { + await setupPageWithState(driver, acc_name); + + const walletWrapper = new WalletWrapper(driver); + await walletWrapper.openWalletConnectionInfo(); + await walletWrapper.pickMyPositions(); + const POOL_NAME = "TUR - MGX"; + const isTurMgx = await walletWrapper.isMyPositionsRowDisplayed(POOL_NAME); + expect(isTurMgx).toBeTruthy(); + }); + + afterEach(async () => { + const session = await driver.getSession(); + await addExtraLogs( + driver, + expect.getState().currentTestName + " - " + session.getId(), + ); + }); + + afterAll(async () => { + const api = getApi(); + await api.disconnect(); + await driver.quit(); + DriverBuilder.destroy(); + }); +}); diff --git a/test/microapps-prod/microapps-ui-main.withdraw.test.ts b/test/microapps-prod/microapps-ui-main.withdraw.test.ts new file mode 100644 index 000000000..cc28550ab --- /dev/null +++ b/test/microapps-prod/microapps-ui-main.withdraw.test.ts @@ -0,0 +1,108 @@ +/* + * + * @group microappsProdWithdraw + */ +import { jest } from "@jest/globals"; +import { Keyring } from "@polkadot/api"; +import { WebDriver } from "selenium-webdriver"; +import { getApi, initApi } from "../../utils/api"; +import { DriverBuilder } from "../../utils/frontend/utils/Driver"; +import { + addExtraLogs, + importPolkadotExtension, +} from "../../utils/frontend/utils/Helper"; +import { AssetWallet, User } from "../../utils/User"; +import { getEnvironmentRequiredVars } from "../../utils/utils"; +import { KSM_ASSET_ID, MGA_ASSET_ID } from "../../utils/Constants"; +import { Node } from "../../utils/Framework/Node/Node"; +import "dotenv/config"; +import { + connectWallet, + setupPage, + setupPageWithState, +} from "../../utils/frontend/microapps-utils/Handlers"; +import { WalletWrapper } from "../../utils/frontend/microapps-pages/WalletWrapper"; +import { WithdrawModal } from "../../utils/frontend/microapps-pages/WithdrawModal"; + +jest.spyOn(console, "log").mockImplementation(jest.fn()); + +jest.setTimeout(1500000); +let driver: WebDriver; +let testUser1: User; + +const acc_name = "acc_automation"; +const KSM_ASSET_NAME = "KSM"; + +describe("Microapps Prod UI withdraw modal tests", () => { + beforeAll(async () => { + try { + getApi(); + } catch (e) { + await initApi(); + } + + driver = await DriverBuilder.getInstance(); + await importPolkadotExtension(driver); + + const keyring = new Keyring({ type: "sr25519" }); + const node = new Node(getEnvironmentRequiredVars().chainUri); + await node.connect(); + + testUser1 = new User(keyring); + testUser1.addFromMnemonic( + keyring, + getEnvironmentRequiredVars().mnemonicPolkadot, + ); + + testUser1.addAsset(KSM_ASSET_ID); + testUser1.addAsset(MGA_ASSET_ID); + await testUser1.refreshAmounts(AssetWallet.BEFORE); + + await setupPage(driver); + await connectWallet(driver, "Polkadot", acc_name); + }); + + test("Withdraw - not enough assets", async () => { + await setupPageWithState(driver, acc_name); + + const walletWrapper = new WalletWrapper(driver); + await walletWrapper.openWalletConnectionInfo(); + await walletWrapper.openWithdraw(); + const withdrawModal = new WithdrawModal(driver); + const isModalVisible = await withdrawModal.isModalVisible(); + expect(isModalVisible).toBeTruthy(); + + await withdrawModal.openChainList(); + await withdrawModal.selectChain("Kusama"); + await withdrawModal.openTokensList(); + await withdrawModal.waitForTokenListElementsVisible(KSM_ASSET_NAME); + await withdrawModal.selectToken(KSM_ASSET_NAME); + await withdrawModal.enterValue("1"); + + await withdrawModal.waitForContinueState(false, 60000); + const isOriginFeeDisplayed = await withdrawModal.isOriginFeeDisplayed(); + expect(isOriginFeeDisplayed).toBeTruthy(); + const isDestinationFeeDisplayed = + await withdrawModal.isDestinationFeeDisplayed(); + expect(isDestinationFeeDisplayed).toBeTruthy(); + + const isContinueButtonEnabled = + await withdrawModal.isContinueButtonEnabled(); + expect(isContinueButtonEnabled).toBeFalsy(); + }); + + afterEach(async () => { + const session = await driver.getSession(); + await addExtraLogs( + driver, + expect.getState().currentTestName + " - " + session.getId(), + ); + }); + + afterAll(async () => { + const api = getApi(); + await api.disconnect(); + await driver.quit(); + DriverBuilder.destroy(); + }); +}); diff --git a/utils/frontend/microapps-pages/WalletWrapper.ts b/utils/frontend/microapps-pages/WalletWrapper.ts index 6ce3ba81c..416072ca0 100644 --- a/utils/frontend/microapps-pages/WalletWrapper.ts +++ b/utils/frontend/microapps-pages/WalletWrapper.ts @@ -5,6 +5,7 @@ import { buildXpathByText, clickElement, elementExists, + getText, isDisplayed, } from "../utils/Helper"; @@ -13,6 +14,11 @@ const DIV_WALLET_CONNECTED = "wallet-connected"; const DIV_WALLET_ITEM = "installedWallets-walletCard"; const DIV_WALLET_WRAPPER_HEADER_ACC = "wallet-wrapper-header-account"; const BUTTON_WALLET_CONNECT = "wallet-notConnected-cta"; +const MY_TOKENS = "my-tokens"; +const MY_POSITIONS = "my-positions"; +const MY_TOKENS_TAB_BUTTON = "My-Tokens-item"; +const MY_TOKENS_ROW_AMOUNT = "AmountTooltip-anchor"; +const MY_POSITIONS_TAB_BUTTON = "My-Positions-item"; export class WalletWrapper { driver: WebDriver; @@ -67,4 +73,34 @@ export class WalletWrapper { const walletItem = buildDataTestIdXpath(DIV_WALLET_ITEM); await clickElement(this.driver, walletItem + walletButtonXpath); } + + async pickMyTokens() { + const myTokensTab = buildDataTestIdXpath(MY_TOKENS_TAB_BUTTON); + await clickElement(this.driver, myTokensTab); + } + + async pickMyPositions() { + const myPositionsTab = buildDataTestIdXpath(MY_POSITIONS_TAB_BUTTON); + await clickElement(this.driver, myPositionsTab); + } + + async isMyTokensRowDisplayed(tokenName: string) { + const tokenRow = + buildDataTestIdXpath(MY_TOKENS) + buildXpathByText(tokenName); + return await isDisplayed(this.driver, tokenRow); + } + + async getMyTokensRowAmount(tokenName: string) { + const tokenRowAmount = + buildDataTestIdXpath(MY_TOKENS) + + buildXpathByText(tokenName) + + buildDataTestIdXpath(MY_TOKENS_ROW_AMOUNT); + return await getText(this.driver, tokenRowAmount); + } + + async isMyPositionsRowDisplayed(poolName: string) { + const poolRow = + buildDataTestIdXpath(MY_POSITIONS) + buildXpathByText(poolName); + return await isDisplayed(this.driver, poolRow); + } }