From 7529163ab9fcd73ed74c59c4c1fd59b7866cdb2d Mon Sep 17 00:00:00 2001 From: MariuSZ Date: Wed, 17 Jul 2024 14:38:41 +0200 Subject: [PATCH 1/4] Update microapps-ui-test.yml --- .github/workflows/microapps-ui-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/microapps-ui-test.yml b/.github/workflows/microapps-ui-test.yml index a795d7747..46ac1b92f 100644 --- a/.github/workflows/microapps-ui-test.yml +++ b/.github/workflows/microapps-ui-test.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest env: - API_URL: 'wss://collator-01-ws-rollup-dev.mangata.online' + API_URL: 'wss://collator-01-ws-rollup-frontend.gasp.xyz' TEST_SUDO_NAME: ${{ secrets.TEST_SUDO_NAME }} TEST_SCRIPT: 'test-gasp-ui' TEST_ENV_TAG: 'develop' From 5d909b872d662794d4b33ad9fd378ee7a3adbd65 Mon Sep 17 00:00:00 2001 From: MariuSZ Date: Wed, 17 Jul 2024 14:53:28 +0200 Subject: [PATCH 2/4] Update microapps-ui-test.yml --- .github/workflows/microapps-ui-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/microapps-ui-test.yml b/.github/workflows/microapps-ui-test.yml index 46ac1b92f..a99e1df17 100644 --- a/.github/workflows/microapps-ui-test.yml +++ b/.github/workflows/microapps-ui-test.yml @@ -68,12 +68,12 @@ jobs: - name: Set Configuration - testnet if: contains(github.event.client_payload.environment, 'testnet') || contains(github.event.inputs.environment, 'testnet') run: | - echo 'API_URL=wss://collator-01-ws-rollup-testnet.mangata.online' >> $GITHUB_ENV + echo 'API_URL=wss://collator-01-ws-rollup-holesky.gasp.xyz' >> $GITHUB_ENV - name: Set Configuration - Develop if: contains(github.event.client_payload.environment, 'develop') || contains(github.event.inputs.environment, 'develop') run: | - echo 'API_URL=wss://collator-01-ws-rollup-dev.mangata.online' >> $GITHUB_ENV + echo 'API_URL=wss://collator-01-ws-rollup-frontend.gasp.xyz' >> $GITHUB_ENV echo 'TEST_SUDO_NAME=${{ secrets.DEV_SUDO_NAME }}' >> $GITHUB_ENV - uses: actions/checkout@v3 From 992deb37007bc271f3f3ed312ad6382250729fb1 Mon Sep 17 00:00:00 2001 From: MariuSZ Date: Mon, 22 Jul 2024 11:36:30 +0200 Subject: [PATCH 3/4] update dev tests post release --- test/rollup-test/rollup-main.deposit.test.ts | 15 ++++---- test/rollup-test/rollup-main.swap.test.ts | 34 +++++++++++-------- test/rollup-test/rollup-main.withdraw.test.ts | 11 +++--- test/rollup-test/rollup-prod.deposit.test.ts | 14 +++++--- test/rollup-test/rollup-prod.withdraw.test.ts | 7 +++- .../rollup-pages/BalanceWarningModal.ts | 2 +- utils/frontend/rollup-pages/Swap.ts | 18 ++++++---- utils/frontend/rollup-pages/WalletWrapper.ts | 14 +++++--- utils/frontend/utils/Helper.ts | 4 +++ 9 files changed, 75 insertions(+), 44 deletions(-) diff --git a/test/rollup-test/rollup-main.deposit.test.ts b/test/rollup-test/rollup-main.deposit.test.ts index 765fa81bf..1c65a073c 100644 --- a/test/rollup-test/rollup-main.deposit.test.ts +++ b/test/rollup-test/rollup-main.deposit.test.ts @@ -32,7 +32,8 @@ let driver: WebDriver; let acc_addr = ""; let acc_addr_short = ""; -const GETH_ASSET_NAME = "GETH"; +const ETH_ASSET_NAME = "ETH"; +const CHAIN_NAME = "Holesky"; describe("Gasp UI deposit tests", () => { beforeAll(async () => { @@ -50,7 +51,7 @@ describe("Gasp UI deposit tests", () => { await connectWallet(driver, "Metamask", acc_addr_short); }); - test("User can deposit GETH", async () => { + test("User can deposit ETH", async () => { await setupPageWithState(driver, acc_addr_short); const walletWrapper = new WalletWrapper(driver); @@ -61,10 +62,10 @@ describe("Gasp UI deposit tests", () => { expect(isModalVisible).toBeTruthy(); await depositModal.openChainList(); - await depositModal.selectChain("Ethereum"); + await depositModal.selectChain(CHAIN_NAME); await depositModal.openTokensList(); - await depositModal.waitForTokenListElementsVisible(GETH_ASSET_NAME); - await depositModal.selectToken(GETH_ASSET_NAME); + await depositModal.waitForTokenListElementsVisible(ETH_ASSET_NAME); + await depositModal.selectToken(ETH_ASSET_NAME); const randomNum = Math.floor(Math.random() * 99) + 1; await depositModal.enterValue("1." + randomNum.toString()); @@ -79,8 +80,8 @@ describe("Gasp UI deposit tests", () => { await depositModal.clickDepositButtonByText(DepositActionType.Network); await acceptNetworkSwitchInNewWindow(driver); - await depositModal.clickDepositButtonByText(DepositActionType.Approve); - await waitForActionNotification(driver, TransactionType.ApproveContract); + // await depositModal.clickDepositButtonByText(DepositActionType.Approve); + // await waitForActionNotification(driver, TransactionType.ApproveContract); await depositModal.clickDepositButtonByText(DepositActionType.Deposit); await waitForActionNotification(driver, TransactionType.Deposit); diff --git a/test/rollup-test/rollup-main.swap.test.ts b/test/rollup-test/rollup-main.swap.test.ts index 4719d2ab6..bf3f6498a 100644 --- a/test/rollup-test/rollup-main.swap.test.ts +++ b/test/rollup-test/rollup-main.swap.test.ts @@ -31,8 +31,9 @@ let driver: WebDriver; let acc_addr = ""; let acc_addr_short = ""; -const GETH_ASSET_NAME = "GETH"; -const GASP_ASSET_NAME = "GASP"; +const ETH_ASSET_NAME = "ETH"; +const GASP_ASSET_NAME = "GASPV2"; +const ETH_ORIGIN = "Ethereum"; describe("Gasp UI swap tests", () => { beforeAll(async () => { @@ -55,9 +56,9 @@ describe("Gasp UI swap tests", () => { const swap = new Swap(driver); const isSwapFrameDisplayed = await swap.isDisplayed(); expect(isSwapFrameDisplayed).toBeTruthy(); - await swap.pickPayToken(GETH_ASSET_NAME); + await swap.pickPayToken(ETH_ASSET_NAME, ETH_ORIGIN); await swap.pickGetToken(GASP_ASSET_NAME); - await swap.setPayTokenAmount("10000"); + await swap.setPayTokenAmount("10000000"); const getTokenAmount = await swap.fetchGetAssetAmount(); expect(parseFloat(getTokenAmount)).toBeGreaterThan(0); @@ -70,13 +71,13 @@ describe("Gasp UI swap tests", () => { const walletWrapper = new WalletWrapper(driver); await walletWrapper.openWalletConnectionInfo(); const tokensAmountBefore = - await walletWrapper.getMyTokensRowAmount(GASP_ASSET_NAME); + parseFloat(await walletWrapper.getMyTokensRowAmount(GASP_ASSET_NAME)) - 1; const swap = new Swap(driver); const isSwapFrameDisplayed = await swap.isDisplayed(); expect(isSwapFrameDisplayed).toBeTruthy(); await swap.pickPayToken(GASP_ASSET_NAME); - await swap.pickGetToken(GETH_ASSET_NAME); - await swap.setPayTokenAmount(tokensAmountBefore); + await swap.pickGetToken(ETH_ASSET_NAME, ETH_ORIGIN); + await swap.setPayTokenAmount(tokensAmountBefore.toString()); const getTokenAmount = await swap.fetchGetAssetAmount(); expect(parseFloat(getTokenAmount)).toBeGreaterThan(0); @@ -98,7 +99,7 @@ describe("Gasp UI swap tests", () => { const isSwapFrameDisplayed = await swap.isDisplayed(); expect(isSwapFrameDisplayed).toBeTruthy(); await swap.pickPayToken(GASP_ASSET_NAME); - await swap.pickGetToken(GETH_ASSET_NAME); + await swap.pickGetToken(ETH_ASSET_NAME, ETH_ORIGIN); await swap.setPayTokenAmount("1000"); const getTokenAmount = await swap.fetchGetAssetAmount(); expect(parseFloat(getTokenAmount)).toBeGreaterThan(0); @@ -112,7 +113,7 @@ describe("Gasp UI swap tests", () => { await swap.toggleRouteDetails(); const areRouteDetailsDisplayed = await swap.areRouteDetailsDisplayed( GASP_ASSET_NAME, - GETH_ASSET_NAME, + ETH_ASSET_NAME, ); expect(areRouteDetailsDisplayed).toBeTruthy(); @@ -128,14 +129,14 @@ describe("Gasp UI swap tests", () => { const isSwapFrameDisplayed = await swap.isDisplayed(); expect(isSwapFrameDisplayed).toBeTruthy(); await swap.pickPayToken(GASP_ASSET_NAME); - await swap.pickGetToken(GETH_ASSET_NAME); + await swap.pickGetToken(ETH_ASSET_NAME, ETH_ORIGIN); await swap.setPayTokenAmount("100"); const areTradeDetailsDisplayed = await swap.areTradeDetailsDisplayed(); expect(areTradeDetailsDisplayed).toBeTruthy(); const swapFee = await swap.fetchSwapFee(); - expect(swapFee).toEqual(1); + expect(swapFee).toEqual(50); }); it("Swap free - more than 1k GASP", async () => { @@ -144,7 +145,7 @@ describe("Gasp UI swap tests", () => { const isSwapFrameDisplayed = await swap.isDisplayed(); expect(isSwapFrameDisplayed).toBeTruthy(); await swap.pickPayToken(GASP_ASSET_NAME); - await swap.pickGetToken(GETH_ASSET_NAME); + await swap.pickGetToken(ETH_ASSET_NAME, ETH_ORIGIN); await swap.setPayTokenAmount("10001"); const areTradeDetailsDisplayed = await swap.areTradeDetailsDisplayed(); @@ -160,7 +161,7 @@ describe("Gasp UI swap tests", () => { const isSwapFrameDisplayed = await swap.isDisplayed(); expect(isSwapFrameDisplayed).toBeTruthy(); await swap.pickPayToken(GASP_ASSET_NAME); - await swap.pickGetToken(GETH_ASSET_NAME); + await swap.pickGetToken(ETH_ASSET_NAME, ETH_ORIGIN); await swap.setPayTokenAmount("1000"); const getTokenAmount = await swap.fetchGetAssetAmount(); expect(parseFloat(getTokenAmount)).toBeGreaterThan(0); @@ -169,7 +170,7 @@ describe("Gasp UI swap tests", () => { await sleep(1000); const payTokenNameAfterSwitch = await swap.fetchPayTokenName(); - expect(payTokenNameAfterSwitch).toEqual(GETH_ASSET_NAME); + expect(payTokenNameAfterSwitch).toEqual(ETH_ASSET_NAME); const getTokenNameAfterSwitch = await swap.fetchGetTokenName(); expect(getTokenNameAfterSwitch).toEqual(GASP_ASSET_NAME); const payTokeAmountAfterSwitch = await swap.fetchPayAssetAmount(); @@ -184,7 +185,7 @@ describe("Gasp UI swap tests", () => { const swap = new Swap(driver); const isSwapFrameDisplayed = await swap.isDisplayed(); expect(isSwapFrameDisplayed).toBeTruthy(); - await swap.pickPayToken(GETH_ASSET_NAME); + await swap.pickPayToken(ETH_ASSET_NAME, ETH_ORIGIN); await swap.pickGetToken(GASP_ASSET_NAME); await swap.setPayTokenAmount("1.213"); const getTokenAmount = await swap.fetchGetAssetAmount(); @@ -194,6 +195,9 @@ describe("Gasp UI swap tests", () => { const isSwapEnabled = await swap.isSwapButtonEnabled(); expect(isSwapEnabled).toBeTruthy(); + await swap.clickSwapButtonByAction(SwapActionType.Network); + await acceptNetworkSwitchInNewWindow(driver); + await swap.clickSwapButtonByAction(SwapActionType.Swap); await waitForActionNotification(driver, TransactionType.Swap); }); diff --git a/test/rollup-test/rollup-main.withdraw.test.ts b/test/rollup-test/rollup-main.withdraw.test.ts index 334e53116..d67103a9a 100644 --- a/test/rollup-test/rollup-main.withdraw.test.ts +++ b/test/rollup-test/rollup-main.withdraw.test.ts @@ -32,7 +32,8 @@ let driver: WebDriver; let acc_addr = ""; let acc_addr_short = ""; -const GETH_ASSET_NAME = "GETH"; +const ETH_ASSET_NAME = "ETH"; +const CHAIN_NAME = "Holesky"; describe("Gasp UI withdraw tests", () => { beforeAll(async () => { @@ -50,7 +51,7 @@ describe("Gasp UI withdraw tests", () => { await connectWallet(driver, "Metamask", acc_addr_short); }); - test("User can withdraw GETH", async () => { + test("User can withdraw ETH", async () => { await setupPageWithState(driver, acc_addr_short); const walletWrapper = new WalletWrapper(driver); @@ -61,10 +62,10 @@ describe("Gasp UI withdraw tests", () => { expect(isModalVisible).toBeTruthy(); await withdrawModal.openChainList(); - await withdrawModal.selectChain("Ethereum"); + await withdrawModal.selectChain(CHAIN_NAME); await withdrawModal.openTokensList(); - await withdrawModal.waitForTokenListElementsVisible(GETH_ASSET_NAME); - await withdrawModal.selectToken(GETH_ASSET_NAME); + await withdrawModal.waitForTokenListElementsVisible(ETH_ASSET_NAME); + await withdrawModal.selectToken(ETH_ASSET_NAME); await withdrawModal.enterValue("1"); await withdrawModal.waitForContinueState(true, 60000); diff --git a/test/rollup-test/rollup-prod.deposit.test.ts b/test/rollup-test/rollup-prod.deposit.test.ts index 8748eab14..fff1f7c76 100644 --- a/test/rollup-test/rollup-prod.deposit.test.ts +++ b/test/rollup-test/rollup-prod.deposit.test.ts @@ -34,6 +34,7 @@ let driver: WebDriver; let acc_addr = ""; let acc_addr_short = ""; const ETH_ASSET_NAME = "ETH"; +const ETH_ORIGIN = "Ethereum"; describe("Gasp Prod UI deposit tests", () => { beforeAll(async () => { @@ -56,8 +57,10 @@ describe("Gasp Prod UI deposit tests", () => { const walletWrapper = new WalletWrapper(driver); await walletWrapper.openWalletConnectionInfo(); - const tokensAmountBefore = - await walletWrapper.getMyTokensRowAmount(ETH_ASSET_NAME); + const tokensAmountBefore = await walletWrapper.getMyTokensRowAmount( + ETH_ASSET_NAME, + ETH_ORIGIN, + ); await walletWrapper.openDeposit(); const depositModal = new DepositModal(driver); const isModalVisible = await depositModal.isModalVisible(); @@ -92,9 +95,12 @@ describe("Gasp Prod UI deposit tests", () => { await walletWrapper.waitTokenAmountChange( ETH_ASSET_NAME, tokensAmountBefore, + ETH_ORIGIN, + ); + const tokensAmountAfter = await walletWrapper.getMyTokensRowAmount( + ETH_ASSET_NAME, + ETH_ORIGIN, ); - const tokensAmountAfter = - await walletWrapper.getMyTokensRowAmount(ETH_ASSET_NAME); expect(await uiStringToNumber(tokensAmountAfter)).toBeGreaterThan( await uiStringToNumber(tokensAmountBefore), ); diff --git a/test/rollup-test/rollup-prod.withdraw.test.ts b/test/rollup-test/rollup-prod.withdraw.test.ts index e004b70e4..9124b79eb 100644 --- a/test/rollup-test/rollup-prod.withdraw.test.ts +++ b/test/rollup-test/rollup-prod.withdraw.test.ts @@ -35,6 +35,7 @@ let driver: WebDriver; let acc_addr = ""; let acc_addr_short = ""; const ASSET_NAME = "GASPV2"; +const NATIVE_ORIGIN = "Native"; const CHAIN_NAME = "Holesky"; describe("Gasp Prod UI withdraw tests", () => { @@ -100,7 +101,11 @@ describe("Gasp Prod UI withdraw tests", () => { await waitForActionNotification(driver, TransactionType.Withdraw); await withdrawModal.closeSuccessModal(); - await walletWrapper.waitTokenAmountChange(ASSET_NAME, tokensAmountBefore); + await walletWrapper.waitTokenAmountChange( + ASSET_NAME, + tokensAmountBefore, + NATIVE_ORIGIN, + ); const tokensAmountAfter = await walletWrapper.getMyTokensRowAmount(ASSET_NAME); expect(await uiStringToNumber(tokensAmountAfter)).toBeLessThan( diff --git a/utils/frontend/rollup-pages/BalanceWarningModal.ts b/utils/frontend/rollup-pages/BalanceWarningModal.ts index 4817b8ad3..0ea39947c 100644 --- a/utils/frontend/rollup-pages/BalanceWarningModal.ts +++ b/utils/frontend/rollup-pages/BalanceWarningModal.ts @@ -9,7 +9,7 @@ export class BalanceWarningModal { } async displayed() { - const xpath = buildXpathByText("Warning! Low GASP Balance"); + const xpath = buildXpathByText("Warning! Low GASPV2 Balance"); return await isDisplayed(this.driver, xpath); } } diff --git a/utils/frontend/rollup-pages/Swap.ts b/utils/frontend/rollup-pages/Swap.ts index 645218d4a..41b258678 100644 --- a/utils/frontend/rollup-pages/Swap.ts +++ b/utils/frontend/rollup-pages/Swap.ts @@ -3,7 +3,7 @@ import { areDisplayed, buildDataTestIdXpath, buildXpathByElementText, - buildXpathByText, + buildXpathByMultiText, clickElement, getAttribute, getText, @@ -80,7 +80,7 @@ export class Swap { return await isDisplayed(this.driver, firstTokenSelector); } - async pickPayToken(tokenName: string) { + async pickPayToken(tokenName: string, origin = "Native") { const selectFirstToken = buildDataTestIdXpath(BTN_SELECT_FIRST_TOKEN); await clickElement(this.driver, selectFirstToken); const firstTokenSelector = buildDataTestIdXpath( @@ -89,13 +89,15 @@ export class Swap { await waitForElement(this.driver, firstTokenSelector); const firstTokenSelectorButton = buildDataTestIdXpath(DIV_TOKEN_SELECTOR_ITEM) + - buildXpathByText(tokenName); + buildXpathByMultiText([tokenName, origin]); await scrollIntoView(this.driver, firstTokenSelectorButton); await clickElement(this.driver, firstTokenSelectorButton); } async fetchPayTokenName() { - const tokenSelector = buildDataTestIdXpath(BTN_SELECT_FIRST_TOKEN); + const tokenSelector = + buildDataTestIdXpath(BTN_SELECT_FIRST_TOKEN) + + "//*[contains(@class, 'font-normal')]"; return await getText(this.driver, tokenSelector); } @@ -117,7 +119,9 @@ export class Swap { } async fetchGetTokenName() { - const tokenSelector = buildDataTestIdXpath(BTN_SELECT_SECOND_TOKEN); + const tokenSelector = + buildDataTestIdXpath(BTN_SELECT_SECOND_TOKEN) + + "//*[contains(@class, 'font-normal')]"; return await getText(this.driver, tokenSelector); } @@ -165,7 +169,7 @@ export class Swap { await clickElement(this.driver, xpath); } - async pickGetToken(tokenName: string) { + async pickGetToken(tokenName: string, origin = "Native") { const selectSecondToken = buildDataTestIdXpath(BTN_SELECT_SECOND_TOKEN); await clickElement(this.driver, selectSecondToken); const secondTokenSelector = buildDataTestIdXpath( @@ -174,7 +178,7 @@ export class Swap { await waitForElement(this.driver, secondTokenSelector); const secondTokenSelectorButton = buildDataTestIdXpath(DIV_TOKEN_SELECTOR_ITEM) + - buildXpathByText(tokenName); + buildXpathByMultiText([tokenName, origin]); await scrollIntoView(this.driver, secondTokenSelectorButton); await clickElement(this.driver, secondTokenSelectorButton); } diff --git a/utils/frontend/rollup-pages/WalletWrapper.ts b/utils/frontend/rollup-pages/WalletWrapper.ts index f6622d401..5f838fbb0 100644 --- a/utils/frontend/rollup-pages/WalletWrapper.ts +++ b/utils/frontend/rollup-pages/WalletWrapper.ts @@ -3,6 +3,7 @@ import { FIVE_MIN } from "../../Constants"; import { buildDataTestIdXpath, buildXpathByElementText, + buildXpathByMultiText, buildXpathByText, clickElement, elementExists, @@ -110,18 +111,20 @@ export class WalletWrapper { return await isDisplayed(this.driver, tokenRow); } - async getMyTokensRowAmount(tokenName: string) { + async getMyTokensRowAmount(tokenName: string, origin = "Native") { const tokenRowAmount = buildDataTestIdXpath(MY_TOKENS) + - buildXpathByText(tokenName) + + buildXpathByMultiText([tokenName, origin]) + buildDataTestIdXpath(MY_TOKENS_ROW_AMOUNT); await waitForElementVisible(this.driver, tokenRowAmount); - return await getText(this.driver, tokenRowAmount); + const amount = await getText(this.driver, tokenRowAmount); + return amount.split(",").join(""); } async waitTokenAmountChange( tokenName: string, initValue: string, + tokenOrigin = "Native", timeout = FIVE_MIN, ) { const startTime = Date.now(); @@ -129,7 +132,10 @@ export class WalletWrapper { while (Date.now() < endTime) { try { - const tokenAmount = await this.getMyTokensRowAmount(tokenName); + const tokenAmount = await this.getMyTokensRowAmount( + tokenName, + tokenOrigin, + ); if (tokenAmount !== initValue) { return; } diff --git a/utils/frontend/utils/Helper.ts b/utils/frontend/utils/Helper.ts index 56eced996..de57242af 100644 --- a/utils/frontend/utils/Helper.ts +++ b/utils/frontend/utils/Helper.ts @@ -694,6 +694,10 @@ export function buildXpathByText(text: string) { return `//*[contains(., "${text}")]`; } +export function buildXpathByMultiText(texts: string[]) { + return `//*[${texts.map((text) => `contains(., "${text}")`).join(" and ")}]`; +} + export function buildXpathByElementText(element: string, text: string) { return `//${element}[contains(., "${text}")]`; } From 5ecf25633d5ecc23a3ab02975615ba4bbc829af6 Mon Sep 17 00:00:00 2001 From: MariuSZ Date: Mon, 22 Jul 2024 11:53:47 +0200 Subject: [PATCH 4/4] Update rollup-main.swap.test.ts --- test/rollup-test/rollup-main.swap.test.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/rollup-test/rollup-main.swap.test.ts b/test/rollup-test/rollup-main.swap.test.ts index bf3f6498a..e160fa276 100644 --- a/test/rollup-test/rollup-main.swap.test.ts +++ b/test/rollup-test/rollup-main.swap.test.ts @@ -195,9 +195,6 @@ describe("Gasp UI swap tests", () => { const isSwapEnabled = await swap.isSwapButtonEnabled(); expect(isSwapEnabled).toBeTruthy(); - await swap.clickSwapButtonByAction(SwapActionType.Network); - await acceptNetworkSwitchInNewWindow(driver); - await swap.clickSwapButtonByAction(SwapActionType.Swap); await waitForActionNotification(driver, TransactionType.Swap); });