-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
playwright and core.app integration (#2141)
Signed-off-by: Eunji Song <[email protected]> Co-authored-by: Tyler Hackett <[email protected]>
- Loading branch information
1 parent
2bb681f
commit a68977a
Showing
13 changed files
with
374 additions
and
51 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Locator, Page } from '@playwright/test' | ||
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() | ||
} | ||
|
||
const open = async (url: string, page: Page) => { | ||
await page.goto(url) | ||
await page.setViewportSize({ width: 2080, height: 1080 }) | ||
} | ||
|
||
const waitFor = async (item: Locator, timeout = 5000) => { | ||
await expect(item).toBeVisible({ timeout }) | ||
} | ||
|
||
async function writeQrCodeToFile(clipboardValue: string) { | ||
fs.writeFile( | ||
'./e2e/tests/playwright/qr_codes.txt', | ||
clipboardValue, | ||
(err: NodeJS.ErrnoException | null) => { | ||
if (err) throw err | ||
} | ||
) | ||
} | ||
|
||
export default { | ||
tap, | ||
open, | ||
waitFor, | ||
writeQrCodeToFile | ||
} |
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,39 @@ | ||
import { test, Page } 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() | ||
return { browser, page } | ||
} | ||
|
||
export const playwrightSetup = () => { | ||
let browser: { close: () => Promise<void> } | 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) { | ||
return { browser, page } | ||
} else { | ||
throw new Error('Page is not initialized or invalid type.') | ||
} | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
packages/core-mobile/e2e/tests/playwright/core/core.e2e.playwright.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,11 @@ | ||
import { warmup } from '../../../helpers/warmup' | ||
import connectToSitePage from '../../../pages/connectToSite.page' | ||
import plusMenuPage from '../../../pages/plusMenu.page' | ||
|
||
describe('PlayWright Integration', () => { | ||
it('should connect Core App', async () => { | ||
await warmup() | ||
await plusMenuPage.connectWallet() | ||
await connectToSitePage.selectAccountAndconnect() | ||
}) | ||
}) |
25 changes: 25 additions & 0 deletions
25
packages/core-mobile/e2e/tests/playwright/core/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { test } from '@playwright/test' | ||
import CoreApp from '../../../pages/coreApp.page' | ||
import CommonPlaywrightPage from '../../../pages/commonPlaywrightEls.page' | ||
import playwrightActions from '../../../helpers/playwrightActions' | ||
import { playwrightSetup } from '../../../helpers/playwrightSetup' | ||
|
||
const getContext = playwrightSetup() | ||
|
||
test('Connect Core', async () => { | ||
const { page } = getContext() | ||
const common = new CommonPlaywrightPage(page) | ||
const core = new CoreApp(page) | ||
|
||
await playwrightActions.open(core.coreUrl, core.page) | ||
await playwrightActions.tap(core.connect, 10000) | ||
await playwrightActions.tap(core.coreMobile) | ||
await playwrightActions.tap(core.termsCheckBox) | ||
await playwrightActions.tap(core.continueBtn) | ||
await playwrightActions.tap(common.walletConnectBtn) | ||
const uri = await common.qrUriValue('w3m') | ||
console.log('URI: ', uri) | ||
if (uri) { | ||
await playwrightActions.writeQrCodeToFile(uri) | ||
} | ||
}) |
31 changes: 31 additions & 0 deletions
31
packages/core-mobile/e2e/tests/playwright/core/run-tests.js
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,31 @@ | ||
const { execSync } = require('child_process') | ||
|
||
const runTests = () => { | ||
const testFile = 'e2e/tests/playwright/core/core.spec.ts' | ||
const testFile2 = 'e2e/tests/playwright/core/core.e2e.playwright.ts' | ||
|
||
try { | ||
// Test Playwright | ||
console.log('Running Playwright tests...') | ||
execSync(`npx playwright test ${testFile} --project=chromium`, { | ||
stdio: 'inherit' | ||
}) | ||
|
||
// Test Detox | ||
console.log('Running Detox tests...') | ||
execSync(`detox test -c ios.internal.debug ${testFile2}`, { | ||
stdio: 'inherit' | ||
}) | ||
|
||
console.log('All tests completed successfully.') | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
console.error('Test execution failed:', error.message) | ||
} else { | ||
console.error('Unexpected error occurred:', error) | ||
} | ||
process.exit(1) | ||
} | ||
} | ||
|
||
runTests() |
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.