Skip to content

Commit

Permalink
Merge branch 'main' into paraswap
Browse files Browse the repository at this point in the history
  • Loading branch information
atn4z7 authored Dec 9, 2024
2 parents 53807db + 5a6181b commit ddfe301
Show file tree
Hide file tree
Showing 40 changed files with 371 additions and 642 deletions.
4 changes: 2 additions & 2 deletions packages/core-mobile/e2e/helpers/playwrightActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { expect } from '@playwright/test'
const fs = require('fs')

const tap = async (item: Locator, timeout = 5000) => {
await expect(item.first()).toBeEnabled({ timeout })
await item.first().click()
await expect(item).toBeEnabled({ timeout })
await item.click()
}

const open = async (url: string, page: Page) => {
Expand Down
13 changes: 8 additions & 5 deletions packages/core-mobile/e2e/helpers/playwrightSetup.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { test, Page } from '@playwright/test'
import { test, Page, Browser } from '@playwright/test'
const { chromium } = require('playwright-extra')
const stealth = require('puppeteer-extra-plugin-stealth')()
chromium.use(stealth)

export const warmupWeb = async () => {
const browser = await chromium.launch({ headless: false })
const page = await browser.newPage()
const browser = await chromium.launch({ headless: true })
const context = await browser.newContext({
permissions: ['clipboard-read']
})
const page = await context.newPage()
return { browser, page }
}

export const playwrightSetup = () => {
let browser: { close: () => Promise<void> } | null = null
let browser: Browser | null = null
let page: Page | null = null

test.beforeAll(async () => {
Expand All @@ -30,7 +33,7 @@ export const playwrightSetup = () => {
})

return () => {
if (page !== null) {
if (page !== null && browser !== null) {
return { browser, page }
} else {
throw new Error('Page is not initialized or invalid type.')
Expand Down
4 changes: 3 additions & 1 deletion packages/core-mobile/e2e/locators/commonPlaywrightEls.loc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default {
connectWallet: 'Connect Wallet',
connectwallet: 'Connect wallet',
walletConnectBtn: 'WalletConnect',
wuiQrCode: 'wui-qr-code',
wcmUri: 'wcm-qrcode'
wcmQrCode: 'wcm-qrcode',
w3mQrCode: 'w3m-qrcode'
}
3 changes: 0 additions & 3 deletions packages/core-mobile/e2e/locators/oasis.loc.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/core-mobile/e2e/locators/traderjoe.loc.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/core-mobile/e2e/locators/uniswap.loc.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/core-mobile/e2e/pages/aave.page.ts

This file was deleted.

39 changes: 0 additions & 39 deletions packages/core-mobile/e2e/pages/balancer.page.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/core-mobile/e2e/pages/benqi.page.ts

This file was deleted.

64 changes: 47 additions & 17 deletions packages/core-mobile/e2e/pages/commonPlaywrightEls.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Page } from '@playwright/test'
import commonEls from '../locators/commonPlaywrightEls.loc'
import playwrightActions from '../helpers/playwrightActions'
import actions from '../helpers/playwrightActions'

class CommonElsPage {
page: Page

Expand All @@ -12,54 +13,83 @@ class CommonElsPage {
return this.page.getByText(commonEls.connectWallet).first()
}

get connectwalletBtn() {
return this.page.getByText(commonEls.connectwallet).first()
}

get walletConnectBtn() {
return this.page.getByText(commonEls.walletConnectBtn).first()
}

get walletConnectV2Btn() {
return this.page.locator('text="WalletConnect V2"')
}

get wuiQrCodeUri() {
return this.page.locator(commonEls.wuiQrCode)
}

get wcmWalletUri() {
return this.page.locator(commonEls.wcmUri).first()
get w3mQrCodeUri() {
return this.page.locator(commonEls.w3mQrCode)
}

get wcmQrCode() {
return this.page.locator(commonEls.wcmQrCode).first()
}

get connectToAWalletBtn() {
return this.page.getByText('Connect to a wallet')
return this.page.locator('text="Connect to a wallet"')
}

get open() {
return this.page.locator('text="OPEN"')
}

async qrUriValue(locator = 'wcm', timeout = 5000) {
if (locator === 'wcm') {
await playwrightActions.waitFor(this.wcmWalletUri, timeout)
return await this.wcmWalletUri.getAttribute('uri')
await actions.waitFor(this.wcmQrCode, timeout)
return await this.wcmQrCode.getAttribute('uri')
} else if (locator === 'w3m') {
await actions.waitFor(this.w3mQrCodeUri, timeout)
return await this.w3mQrCodeUri.getAttribute('uri')
} else {
await playwrightActions.waitFor(this.wuiQrCodeUri, timeout)
await actions.waitFor(this.wuiQrCodeUri, timeout)
return await this.wuiQrCodeUri.getAttribute('uri')
}
}

async clickConnectWalletBtn() {
await this.connectWalletBtn.click()
async tapConnectWallet(index = 0) {
const connectWallet = this.page.locator(
`text=/connect wallet/i >> nth=${index}`
)
await actions.waitFor(connectWallet)
await connectWallet.click()
}

// Some sites have multiple wallet connect buttons so adjust the index as needed in order to click the correct one
async clickWalletConnectBtn(index = 0) {
async tapWalletConnect(index = 0) {
const walletConnectBtn = this.page.locator(
`text=WalletConnect >> nth=${index}`
`text="WalletConnect" >> nth=${index}`
)
await actions.waitFor(walletConnectBtn)
await walletConnectBtn.click()
}

get walletConnectUri() {
return this.page.getByText('Copy to clipboard')
async tapCopy() {
return actions.tap(this.page.getByText('Copy'))
}

async tapWalletConnectV2() {
await actions.waitFor(this.walletConnectV2Btn)
await actions.tap(this.walletConnectV2Btn)
}

async walletConnectUriValue() {
await this.walletConnectUri.click()
async tapOpen() {
await actions.tap(this.open, 20000)
}

async clickConnectToAWalletBtn() {
await this.connectToAWalletBtn.click()
async tapConnectToAWallet(index = 0) {
await this.connectToAWalletBtn.nth(index).click()
}
}

Expand Down
15 changes: 0 additions & 15 deletions packages/core-mobile/e2e/pages/compoundFinance.page.ts

This file was deleted.

23 changes: 0 additions & 23 deletions packages/core-mobile/e2e/pages/convexFinance.page.ts

This file was deleted.

85 changes: 85 additions & 0 deletions packages/core-mobile/e2e/pages/dappsPlaywright.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { Page } from '@playwright/test'

class DappsPlaywrightPage {
page: Page

constructor(page: Page) {
this.page = page
}

get aaveUrl() {
return 'https://app.aave.com/'
}

get balancerUrl() {
return 'https://balancer.fi/pools'
}

get benqiUrl() {
return 'https://app.benqi.fi/markets'
}

get compoundFinanceUrl() {
return 'https://app.compound.finance/'
}

get convexFinanceUrl() {
return 'https://www.convexfinance.com/'
}

get gmxUrl() {
return 'https://app.gmx.io/#/trade'
}

get instadappUrl() {
return 'https://lite.instadapp.io/'
}

get multichainUrl() {
return 'https://app.multichain.org/#/router'
}

get oasisUrl() {
return 'https://summer.fi/'
}

get openseaUrl() {
return 'https://opensea.io/'
}

get pangolinUrl() {
return 'https://beta.pangolin.exchange/swap'
}

get pangolinAgree() {
return this.page.locator('#agree')
}

get stakeLidoUrl() {
return 'https://stake.lido.fi/'
}

get lfjUrl() {
return 'https://lfj.gg/avalanche'
}

get uniswapUrl() {
return 'https://app.uniswap.org/#/swap'
}

get yieldYakUrl() {
return 'https://www.yieldyak.com/'
}

get lidoAgree() {
return this.page.getByText(
'I certify that I have read and accept the updated'
)
}

get lfjAgree() {
return this.page.locator('text="I read and accept"')
}
}

export default DappsPlaywrightPage
15 changes: 0 additions & 15 deletions packages/core-mobile/e2e/pages/gmx.page.ts

This file was deleted.

Loading

0 comments on commit ddfe301

Please sign in to comment.