-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added injected wallet back in, configured simple test with w3m …
…prefer injected flag, added in extension, added in data storage location, configured playwright to use projects, updated workflow
- Loading branch information
1 parent
e4e8f06
commit d13f386
Showing
7 changed files
with
117 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
/playwright/.cache/ | ||
/tests/shared/data/** | ||
!/tests/shared/data/*.zip |
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
Binary file not shown.
Binary file not shown.
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 @@ | ||
/* eslint-disable prefer-destructuring */ | ||
/* eslint-disable no-empty-pattern */ | ||
import { test as base, chromium, type BrowserContext } from '@playwright/test' | ||
import path from 'path' | ||
|
||
export const testWithMM = base.extend<{ | ||
contextMM: BrowserContext | ||
extensionId: string | ||
}>({ | ||
context: async ({}, use) => { | ||
const pathToExtension = path.join(__dirname, '../data/metamask-chrome-10.34.0') | ||
const pathToStorage = path.join(__dirname, '../data/mm-storage') | ||
|
||
const context = await chromium.launchPersistentContext(pathToStorage, { | ||
headless: false, | ||
args: [ | ||
// `--headless=new`, | ||
`--disable-extensions-except=${pathToExtension}`, | ||
`--load-extension=${pathToExtension}` | ||
] | ||
}) | ||
await use(context) | ||
await context.close() | ||
}, | ||
extensionId: async ({ context }, use) => { | ||
let [background] = context.serviceWorkers() | ||
if (!background) { | ||
background = await context.waitForEvent('serviceworker') | ||
} | ||
|
||
const extensionId = background.url().split('/')[2] | ||
await use(extensionId) | ||
} | ||
}) |
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,33 @@ | ||
import { testWithMM } from './shared/fixtures/mm-fixture' | ||
import { expect } from '@playwright/test' | ||
|
||
/** | ||
* R&D testing for inject wallets, WIP | ||
*/ | ||
|
||
testWithMM('should prefer injected wallets', async ({ page, context }) => { | ||
const mmPageEvent = context.waitForEvent('page') | ||
const mmPage = await mmPageEvent | ||
await mmPage.getByTestId('unlock-password').fill('password') | ||
await mmPage.getByTestId('unlock-submit').click() | ||
|
||
await page.goto('https://lab.web3modal.com/with-wagmi/react?w3mPreferInjected=true') | ||
await page.getByTestId('partial-core-connect-button').focus() | ||
await page.getByTestId('partial-core-connect-button').click() | ||
|
||
await mmPage.reload() | ||
await expect(mmPage.getByText(/Connect with MetaMask/u)).toBeVisible() | ||
}) | ||
|
||
/* You can use this mock test + playwright debug to open/modify the mm extension */ | ||
testWithMM.skip('debug extension', async ({ page, context }) => { | ||
const mmPageEvent = context.waitForEvent('page') | ||
const mmPage = await mmPageEvent | ||
await mmPage.getByTestId('unlock-password').fill('password') | ||
await mmPage.getByTestId('unlock-submit').click() | ||
|
||
// eslint-disable-next-line no-promise-executor-return | ||
await new Promise(resolve => setTimeout(resolve, 10000000)) | ||
await page.goto('https://example.com') | ||
expect(true).toBe(true) | ||
}) |