From 3fda067a069d7e9d4d7298074a69dc58d78c97b0 Mon Sep 17 00:00:00 2001 From: Sahil Kashetwar Date: Fri, 30 Aug 2024 04:56:34 +0530 Subject: [PATCH] change: test cases updated for packages! --- .github/workflows/end2end-test.yml | 7 +- e2e-tests/lib/gatewayAction.ts | 10 +- e2e-tests/pages/bridgePage.ts | 13 ++ e2e-tests/tests/01_bnb.bridge.spec.ts | 139 ++++++++++++++------ package.json | 2 +- src/containers/modals/tokenPicker/config.ts | 1 + 6 files changed, 122 insertions(+), 50 deletions(-) diff --git a/.github/workflows/end2end-test.yml b/.github/workflows/end2end-test.yml index 0cb1e638..8c11314d 100644 --- a/.github/workflows/end2end-test.yml +++ b/.github/workflows/end2end-test.yml @@ -1,10 +1,9 @@ name: Integration Test on: - # push: - # branches: ['main', 'master'] - # pull_request: - workflow_dispatch + push: + branches: ['main', 'master'] + pull_request: jobs: e2e-test: diff --git a/e2e-tests/lib/gatewayAction.ts b/e2e-tests/lib/gatewayAction.ts index 846db0fb..7fd98247 100644 --- a/e2e-tests/lib/gatewayAction.ts +++ b/e2e-tests/lib/gatewayAction.ts @@ -20,8 +20,6 @@ export class GatewayAction { tokenSymbol: string estimatedTime?: string }) { - await this.basePage.disconnectMetamask() - await this.basePage.connectToMetamask(true) await this.bridgePage.openTokenPickerAndSelect(tokenSymbol) await this.bridgePage.bridgeButtonToBeDisable() await this.bridgePage.fillBridgingAmount(amountToBridge) @@ -60,6 +58,10 @@ export class GatewayAction { await this.bridgePage.reviewAndWithdraw() } + async doWithdrawClassicBridgeBnb(amount) { + await this.bridgePage.reviewAproveAndWithdraw(amount) + } + async lightBridge({ amountToBridge, tokenSymbol, @@ -106,6 +108,10 @@ export class GatewayAction { await this.basePage.wait(1000) } + async connect() { + await this.basePage.connectToMetamask(true) + } + async switchToL2AndReset() { await this.basePage.clickToSwitchNetwork() await this.basePage.disconnectMetamask() diff --git a/e2e-tests/pages/bridgePage.ts b/e2e-tests/pages/bridgePage.ts index 6a5d8879..6c4feb3d 100644 --- a/e2e-tests/pages/bridgePage.ts +++ b/e2e-tests/pages/bridgePage.ts @@ -151,6 +151,19 @@ export class BridgePage extends BasePage { await this.page.getByRole('button', { name: 'Close' }).click() } + async reviewAproveAndWithdraw(amount) { + await expect( + this.page.getByRole('heading', { name: 'Withdrawal' }) + ).toBeVisible() + await expect( + this.page.getByRole('button', { name: 'Initiate Withdrawal' }) + ).toBeEnabled() + await this.page.getByRole('button', { name: 'Initiate Withdrawal' }).click() + await metamask.confirmPermissionToSpend(amount) + await this.wait(2000) + await this.page.getByRole('button', { name: 'Close' }).click() + } + async switchNetworkProovWithdrawal() { const switchBtn = this.page.getByRole('button', { name: 'Switch Network' }) diff --git a/e2e-tests/tests/01_bnb.bridge.spec.ts b/e2e-tests/tests/01_bnb.bridge.spec.ts index d4de3cc0..b05181ad 100644 --- a/e2e-tests/tests/01_bnb.bridge.spec.ts +++ b/e2e-tests/tests/01_bnb.bridge.spec.ts @@ -1,54 +1,107 @@ import { test } from '../fixture/synpress' import { GatewayAction } from '../lib/gatewayAction' -import { BasePage } from '../pages/basePage' -const amountToBridge: string = '0.0001' +let amountToBridge: string = '0.0001' + +const TEST_TIMEOUT = 120000 test.beforeEach(async ({ page }) => { await page.goto('/') }) -test.describe('Gateway BNB (Testnet)', () => { - test.skip() - test.describe('Classic Bridge', () => { - test.describe('Deposit', () => { - test('tBNB', async ({ page }) => { - test.setTimeout(120000) - const bridgeAction = new GatewayAction(page) - await bridgeAction.addAndConnectBNBTestnet() - await bridgeAction.classicBridgeDeposit({ - amountToBridge, - tokenSymbol: 'tBNB', - networkKey: 'bnb', - }) - }) - test('BOBA', async ({ page }) => { - test.setTimeout(120000) - const bridgeAction = new GatewayAction(page) - await bridgeAction.addAndConnectBNBTestnet() - await bridgeAction.classicBridgeDeposit({ - amountToBridge, - tokenSymbol: 'BOBA', - approveAllowance: true, - networkKey: 'bnb', - }) - }) - }) - test.describe('Withdraw', () => { - test.skip('BOBA', async ({ page }) => { - test.setTimeout(120000) - const basePage = new BasePage(page) - const bridgeAction = new GatewayAction(page) - await bridgeAction.addAndConnectBNBTestnet() - await bridgeAction.switchL2Network() - page.waitForTimeout(2000) - await basePage.connectToMetamask(true) - await bridgeAction.classicBridgeWithdrawal({ - amountToBridge: '0.00001', - tokenSymbol: 'tBNB', - networkKey: 'bnb', - }) - }) +test.describe('BNB', () => { + let gatewayAction + + test.beforeEach(async ({ page }) => { + gatewayAction = new GatewayAction(page) + await gatewayAction.addAndConnectBNBTestnet() + test.setTimeout(TEST_TIMEOUT) + }) + + test('should deposit tBNB token with classic bridge', async () => { + await gatewayAction.classicBridge({ + amountToBridge, + tokenSymbol: 'tBNB', + estimatedTime: '13 ~ 14mins.', + }) + await gatewayAction.doDepositClassicBridge({ + amountToBridge, + }) + }) + + // fix conflicting MM popup raise or update to new synpress 4 -beta. + test.fixme('should deposit BOBA token with classic bridge', async () => { + await gatewayAction.classicBridge({ + amountToBridge, + tokenSymbol: 'BOBA', + estimatedTime: '13 ~ 14mins.', + }) + await gatewayAction.doDepositClassicBridge({ + amountToBridge, + approveAllowance: true, + }) + }) + + test('should withdraw tBNB token with classic bridge', async () => { + await gatewayAction.switchToL2AndReset() + await gatewayAction.connect() + await gatewayAction.classicBridge({ + amountToBridge, + estimatedTime: '7 days', + tokenSymbol: 'tBNB', + }) + await gatewayAction.doWithdrawClassicBridgeBnb(amountToBridge) + }) + + test('should withdraw BOBA token with classic bridge', async () => { + await gatewayAction.switchToL2AndReset() + await gatewayAction.connect() + await gatewayAction.classicBridge({ + amountToBridge, + estimatedTime: '7 days', + tokenSymbol: 'BOBA', + }) + await gatewayAction.doWithdrawClassicBridge() + }) + + // as of now no supported tokens for teleportation on BNB + test.fixme('should deposit tBNB token with light bridge', async () => { + await gatewayAction.lightBridge({ + amountToBridge: '0.01', + tokenSymbol: 'tBNB', + }) + }) + // as of now no supported tokens for teleportation on BNB + test.fixme('should deposit BOBA token with light bridge', async () => { + await gatewayAction.lightBridge({ + amountToBridge: '20.021', + tokenSymbol: 'BOBA', + approveAllowance: true, + }) + }) + + // as of now no supported tokens for teleportation on BNB + test.fixme('should withdraw tBNB token with light bridge', async () => { + amountToBridge = '0.01' + await gatewayAction.switchToL2AndReset() + const receivableAmt = Number(amountToBridge) * ((100 - 1) / 100) + await gatewayAction.lightBridge({ + amountToBridge, + receivableAmt, + tokenSymbol: 'tBNB', + }) + }) + + // as of now no supported tokens for teleportation on BNB + test.fixme('should withdraw BOBA token with light bridge', async () => { + amountToBridge = '20.0211' + await gatewayAction.switchToL2AndReset() + const receivableAmt = Number(amountToBridge) * ((100 - 1) / 100) + await gatewayAction.lightBridge({ + amountToBridge, + receivableAmt, + tokenSymbol: 'BOBA', + approveAllowance: true, }) }) }) diff --git a/package.json b/package.json index 0d7b0094..d75c8a77 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", - "@bobanetwork/graphql-utils": "^1.1.15", + "@bobanetwork/graphql-utils": "^1.1.16", "@bobanetwork/light-bridge-chains": "^1.1.0", "@bobanetwork/register": "^0.0.26", "@bobanetwork/sdk": "1.0.7", diff --git a/src/containers/modals/tokenPicker/config.ts b/src/containers/modals/tokenPicker/config.ts index b2a2c05a..1271e271 100644 --- a/src/containers/modals/tokenPicker/config.ts +++ b/src/containers/modals/tokenPicker/config.ts @@ -6,6 +6,7 @@ export const bridgeConfig = { getBalance: ({ l1Balance, l2Balance, layer, getBridgeableTokens }) => { const balances = layer === 'L2' ? l2Balance : l1Balance return getBridgeableTokens(balances).then((supportedTokens) => { + console.log(`supportedTokens`, supportedTokens, balances) return balances.filter((balance) => { return supportedTokens .map((b) => b.token)