-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QA New: Playground testing with
playwright web
and detox mobile
i…
…ntegration (#2166)
- Loading branch information
Showing
32 changed files
with
490 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,40 @@ | ||
import { test, Page, Browser } from '@playwright/test' | ||
import { Page, Browser, BrowserContext } from '@playwright/test' | ||
import PlaygroundPlaywrightPage from '../pages/playgroundPlaywright.page' | ||
import CommonPlaywrightPage from '../pages/commonPlaywrightEls.page' | ||
import DappsPlaywrightPage from '../pages/dappsPlaywright.page' | ||
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 context = await browser.newContext({ | ||
let sharedContext: BrowserContext | null = null | ||
|
||
export const playwrightSetup = async (saveContext = false) => { | ||
const browser: Browser = await chromium.launch({ headless: false }) | ||
const context: BrowserContext = await browser.newContext({ | ||
permissions: ['clipboard-read'] | ||
}) | ||
const page = await context.newPage() | ||
return { browser, page } | ||
const page: Page = await context.newPage() | ||
if (saveContext) { | ||
sharedContext = context | ||
} | ||
const playground = new PlaygroundPlaywrightPage(page) | ||
const common = new CommonPlaywrightPage(page) | ||
const dapps = new DappsPlaywrightPage(page) | ||
return { browser, page, sharedContext, playground, common, dapps } | ||
} | ||
|
||
export const playwrightSetup = () => { | ||
let browser: Browser | null = null | ||
let page: Page | null = null | ||
|
||
test.beforeAll(async () => { | ||
const context = await warmupWeb() | ||
browser = context.browser | ||
page = context.page | ||
console.log('Starting Playwright test...') | ||
}) | ||
|
||
test.afterAll(async () => { | ||
if (browser) { | ||
await browser.close() | ||
browser = null | ||
page = null | ||
} | ||
console.log('Closing Playwright test...') | ||
}) | ||
|
||
return () => { | ||
if (page !== null && browser !== null) { | ||
return { browser, page } | ||
} else { | ||
throw new Error('Page is not initialized or invalid type.') | ||
} | ||
export const getCurrentContext = async () => { | ||
if (!sharedContext) { | ||
throw new Error( | ||
'sharedContext is not initialized. Ensure it is set before calling getCurrentContext.' | ||
) | ||
} | ||
const page = await sharedContext.newPage() | ||
if (!page) { | ||
throw new Error('Failed to create a new page.') | ||
} | ||
const playground = new PlaygroundPlaywrightPage(page) | ||
const common = new CommonPlaywrightPage(page) | ||
const dapps = new DappsPlaywrightPage(page) | ||
return { sharedContext, page, playground, common, dapps } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/core-mobile/e2e/pages/playgroundPlaywright.page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Page } from '@playwright/test' | ||
import actions from '../helpers/playwrightActions' | ||
import delay from '../helpers/waits' | ||
import CommonElsPage from './commonPlaywrightEls.page' | ||
|
||
class PlaygroundPlaywrightPage { | ||
page: Page | ||
|
||
constructor(page: Page) { | ||
this.page = page | ||
} | ||
|
||
get url() { | ||
return 'https://ava-labs.github.io/extension-avalanche-playground/' | ||
} | ||
|
||
get rpcCalls() { | ||
return this.page.locator('text="RPC Calls"') | ||
} | ||
|
||
get response() { | ||
return this.page.locator( | ||
"//button[normalize-space()='Send']/following-sibling::h1" | ||
) | ||
} | ||
|
||
async sendRpcCall(rpcCall: string) { | ||
await actions.open(this.url, this.page) | ||
await this.tapRpcCalls() | ||
await this.selectMethod(rpcCall) | ||
await this.tapSend() | ||
await delay(5000) | ||
} | ||
|
||
async connect() { | ||
const common = new CommonElsPage(this.page) | ||
await actions.open(this.url, this.page) | ||
await this.tapWagmi() | ||
await common.tapWalletConnect() | ||
const qrUri = await common.qrUriValue('wui') | ||
if (qrUri) { | ||
await actions.writeQrCodeToFile(qrUri) | ||
} | ||
console.log(qrUri) | ||
await actions.waitFor(this.rpcCalls, 30000) | ||
await delay(1000) | ||
} | ||
|
||
async tapWagmi() { | ||
await this.page.locator('text="Connect via Wallet Connect - Wagmi"').click() | ||
} | ||
|
||
async tapRpcCalls() { | ||
await this.rpcCalls.click() | ||
} | ||
|
||
async tapMethodsDropdown() { | ||
await this.page.locator('[data-testid="ArrowDropDownIcon"]').click() | ||
} | ||
|
||
async selectMethod(rpcCall: string) { | ||
await this.tapMethodsDropdown() | ||
const dropdownOption = `//li[contains(@id, "option")]/span[text()="${rpcCall}"]` | ||
await this.page.locator(dropdownOption).click() | ||
} | ||
|
||
async tapSend() { | ||
await this.page.locator('text="Send"').click() | ||
} | ||
} | ||
|
||
export default PlaygroundPlaywrightPage |
12 changes: 5 additions & 7 deletions
12
...e/e2e/tests/dapps/playwright/aave.spec.ts → ...sts/dapps/playwright/connect/aave.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
...e/tests/dapps/playwright/balancer.spec.ts → ...dapps/playwright/connect/balancer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
.../e2e/tests/dapps/playwright/benqi.spec.ts → ...ts/dapps/playwright/connect/benqi.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
.../dapps/playwright/compoundFinance.spec.ts → ...laywright/connect/compoundFinance.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
...ts/dapps/playwright/convexFinance.spec.ts → .../playwright/connect/convexFinance.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
...e/e2e/tests/dapps/playwright/core.spec.ts → ...sts/dapps/playwright/connect/core.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
...le/e2e/tests/dapps/playwright/gmx.spec.ts → ...ests/dapps/playwright/connect/gmx.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
...e/tests/dapps/playwright/gogopool.spec.ts → ...dapps/playwright/connect/gogopool.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
.../tests/dapps/playwright/instadapp.spec.ts → ...apps/playwright/connect/instadapp.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.