Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MariuszSzpyt committed Jan 20, 2025
1 parent d0b9213 commit db33a1c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
8 changes: 4 additions & 4 deletions test/rollup-test/rollup-prod.deposit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import {
} from "../../utils/frontend/utils/Helper";
import "dotenv/config";
import {
approveContractIfEligible,
connectWallet,
setupPage,
setupPageWithState,
switchNetworkIfEligible,
waitForActionNotification,
} from "../../utils/frontend/rollup-utils/Handlers";
import { WalletWrapper } from "../../utils/frontend/rollup-pages/WalletWrapper";
Expand All @@ -23,7 +25,6 @@ import {
DepositModal,
} from "../../utils/frontend/rollup-utils/DepositModal";
import { TransactionType } from "../../utils/frontend/rollup-pages/NotificationToast";
import { switchNetworkIfEligible } from "../../utils/frontend/utils/Handlers";

jest.spyOn(console, "log").mockImplementation(jest.fn());

Expand Down Expand Up @@ -74,9 +75,8 @@ describe("Gasp Prod UI deposit tests", () => {
const isOriginFeeDisplayed = await depositModal.isOriginFeeDisplayed();
expect(isOriginFeeDisplayed).toBeTruthy();
await switchNetworkIfEligible(driver, DepositActionType.NetworkArbitrum);

await depositModal.clickDepositButtonByText(DepositActionType.Approve);
await waitForActionNotification(driver, TransactionType.ApproveContract);
await approveContractIfEligible(driver);

await depositModal.clickDepositButtonByText(DepositActionType.Deposit);
await waitForActionNotification(driver, TransactionType.Deposit, true);

Expand Down
32 changes: 30 additions & 2 deletions utils/frontend/rollup-utils/Handlers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WebDriver } from "selenium-webdriver";
import { ApiContext } from "../../Framework/XcmHelper";
import { Polkadot } from "../pages/Polkadot";
import { acceptPermissionsWalletExtensionInNewWindow } from "../utils/Helper";
import { acceptNetworkSwitchInNewWindow, acceptPermissionsWalletExtensionInNewWindow } from "../utils/Helper";
import { BN_TEN } from "@mangata-finance/sdk";
import { BN } from "@polkadot/util";
import { Main } from "../rollup-pages/Main";
Expand All @@ -12,7 +12,7 @@ import {
NotificationToast,
ToastType,
} from "../rollup-pages/NotificationToast";
import { DepositModal } from "./DepositModal";
import { DepositActionType, DepositModal } from "./DepositModal";
import { WithdrawModal } from "../rollup-pages/WithdrawModal";
import { WalletConnectModal } from "../rollup-pages/WalletConnectModal";

Expand Down Expand Up @@ -224,3 +224,31 @@ export async function addLiqTokenMicroapps(
},
});
}

export async function approveContractIfEligible(
driver: WebDriver,
) {
const depositModal = new DepositModal(driver);
try {
await depositModal.clickDepositButtonByText(DepositActionType.Approve);
await waitForActionNotification(driver, TransactionType.ApproveContract);
} catch {
//Button not found - no action performed.
}
}

export async function switchNetworkIfEligible(
driver: WebDriver,
depositAction: DepositActionType,
) {
const depositModal = new DepositModal(driver);
try {
const isNetworkButtonEnabled =
await depositModal.isNetworkButtonEnabled(depositAction);
expect(isNetworkButtonEnabled).toBeTruthy();
await depositModal.clickDepositButtonByText(depositAction);
await acceptNetworkSwitchInNewWindow(driver);
} catch {
//Button not found - no action performed.
}
}
16 changes: 0 additions & 16 deletions utils/frontend/utils/Handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,3 @@ export async function initDeposit(driver: WebDriver, assetName: string) {
// await depositModal.waitForProgressBar();
await depositModal.clickContinue();
}

export async function switchNetworkIfEligible(
driver: WebDriver,
depositAction: DepositActionType,
) {
const depositModal = new DepositModal(driver);
try {
const isNetworkButtonEnabled =
await depositModal.isNetworkButtonEnabled(depositAction);
expect(isNetworkButtonEnabled).toBeTruthy();
await depositModal.clickDepositButtonByText(depositAction);
await acceptNetworkSwitchInNewWindow(driver);
} catch {
//Button not found - no action performed.
}
}

0 comments on commit db33a1c

Please sign in to comment.