Skip to content

Commit

Permalink
change: test cases updated for packages!
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-enya committed Aug 29, 2024
1 parent 35d2fb7 commit 3fda067
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 50 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
10 changes: 8 additions & 2 deletions e2e-tests/lib/gatewayAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -60,6 +58,10 @@ export class GatewayAction {
await this.bridgePage.reviewAndWithdraw()
}

async doWithdrawClassicBridgeBnb(amount) {
await this.bridgePage.reviewAproveAndWithdraw(amount)
}

async lightBridge({
amountToBridge,
tokenSymbol,
Expand Down Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions e2e-tests/pages/bridgePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' })

Expand Down
139 changes: 96 additions & 43 deletions e2e-tests/tests/01_bnb.bridge.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
})
})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/containers/modals/tokenPicker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3fda067

Please sign in to comment.