-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QA New: Playground testing with playwright web
and detox mobile
integration
#2166
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we wait for the response to be visible or change instead of using delay?