-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/automated tests with metamask (#2636)
- Loading branch information
1 parent
7bf3aa4
commit ead5f90
Showing
10 changed files
with
1,250 additions
and
179 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 |
---|---|---|
|
@@ -60,4 +60,4 @@ const nextConfig = { | |
} | ||
} | ||
|
||
module.exports = nextConfig | ||
export default nextConfig |
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,22 @@ | ||
import { expect } from '@playwright/test' | ||
import { metaMaskFixtures, testWithSynpress } from '@synthetixio/synpress' | ||
import { ModalValidator } from './shared/validators/ModalValidator' | ||
import basicSetup from './wallet-setup/basic.setup' | ||
|
||
// -- Setup -------------------------------------------------------------------- | ||
const synpressTest = testWithSynpress(metaMaskFixtures(basicSetup)).extend<{ library: string }>({ | ||
library: ['wagmi', { option: true }] | ||
}) | ||
|
||
synpressTest.describe.configure({ mode: 'serial' }) | ||
|
||
synpressTest('should be connected as expected', async ({ page, metamask }) => { | ||
await page.goto(`/library/wagmi`) | ||
const modalValidator = new ModalValidator(page) | ||
await page.getByTestId('connect-button').click() | ||
const connectMetaMaskButton = page.getByTestId('wallet-selector-io.metamask') | ||
await expect(connectMetaMaskButton).toBeVisible() | ||
await connectMetaMaskButton.click() | ||
await metamask.connectToDapp() | ||
await modalValidator.expectConnected() | ||
}) |
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,11 @@ | ||
import { MetaMask, defineWalletSetup, getExtensionId } from '@synthetixio/synpress' | ||
|
||
const SEED_PHRASE = 'test test test test test test test test test test test junk' | ||
const PASSWORD = 'Password123' | ||
|
||
export default defineWalletSetup(PASSWORD, async (context, walletPage) => { | ||
const extensionId = await getExtensionId(context, 'MetaMask') | ||
const metamask = new MetaMask(context, walletPage, PASSWORD, extensionId) | ||
|
||
await metamask.importWallet(SEED_PHRASE) | ||
}) |
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
22 changes: 22 additions & 0 deletions
22
patches/@synthetixio__synpress-metamask@0.0.1-alpha.7.patch
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,22 @@ | ||
diff --git a/src/fixtures/metaMaskFixtures.ts b/src/fixtures/metaMaskFixtures.ts | ||
index cc2019e4baa64c8a7dee64398c09dd415169a17f..cda6d980723f3ce885d4fab99596a3e07384a65e 100644 | ||
--- a/src/fixtures/metaMaskFixtures.ts | ||
+++ b/src/fixtures/metaMaskFixtures.ts | ||
@@ -53,7 +53,7 @@ export const metaMaskFixtures = (walletSetup: ReturnType<typeof defineWalletSetu | ||
// We don't need the `--load-extension` arg since the extension is already loaded in the cache. | ||
const browserArgs = [`--disable-extensions-except=${metamaskPath}`] | ||
|
||
- if (process.env.HEADLESS) { | ||
+ if (process.env["HEADLESS"]) { | ||
browserArgs.push('--headless=new') | ||
|
||
if (slowMo > 0) { | ||
@@ -64,7 +64,7 @@ export const metaMaskFixtures = (walletSetup: ReturnType<typeof defineWalletSetu | ||
const context = await chromium.launchPersistentContext(_contextPath, { | ||
headless: false, | ||
args: browserArgs, | ||
- slowMo: process.env.HEADLESS ? 0 : slowMo | ||
+ slowMo: process.env["HEADLESS"] ? 0 : slowMo | ||
}) | ||
|
||
const { cookies, origins } = await currentContext.storageState() |
Oops, something went wrong.