-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
87478e8
commit 971b517
Showing
8 changed files
with
3,304 additions
and
147 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,46 @@ | ||
import type { BrowserContext } from "@playwright/test"; | ||
import { chromium, test as baseTest } from "@playwright/test"; | ||
import { initialSetup } from "@synthetixio/synpress/commands/metamask"; | ||
import { prepareMetamask } from "@synthetixio/synpress/helpers"; | ||
|
||
export const test = baseTest.extend<{ | ||
context: BrowserContext; | ||
}>({ | ||
context: async ({}, use) => { | ||
// Required for SynPress | ||
// @ts-ignore | ||
global.expect = baseTest.expect; | ||
|
||
// Download Metamask | ||
const metamaskVersion = "11.15.1"; | ||
const metamaskPath = await prepareMetamask(metamaskVersion); | ||
|
||
// Prepare browser args | ||
const browserArgs = [ | ||
`--disable-extensions-except=${metamaskPath}`, | ||
`--load-extension=${metamaskPath}`, | ||
"--remote-debugging-port=9222", | ||
]; | ||
|
||
// Launch browser | ||
const context = await chromium.launchPersistentContext("", { | ||
headless: false, | ||
args: browserArgs, | ||
}); | ||
|
||
// Wait for Metamask window to be shown. | ||
await context.pages()[0].waitForTimeout(3000); | ||
|
||
// Setup metamask | ||
await initialSetup(chromium, { | ||
secretWordsOrPrivateKey: | ||
"test test test test test test test test test test test junk", | ||
network: "sepolia", | ||
password: "Tester@1234", | ||
enableAdvancedSettings: true, | ||
}); | ||
|
||
// Provide context | ||
await use(context); | ||
}, | ||
}); |
File renamed without changes.
File renamed without changes.
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,32 @@ | ||
import { expect } from "@playwright/test"; | ||
import { test } from "../fixtures/metamask"; | ||
import * as metamask from "@synthetixio/synpress/commands/metamask"; | ||
|
||
test.describe.configure({ | ||
mode: "serial", | ||
timeout: 120000, | ||
}); | ||
|
||
test.afterAll(async ({ context }) => { | ||
await context.close(); | ||
}); | ||
|
||
test("should connect to MetaMask and enable 'Send Transaction' button", async ({ | ||
page, | ||
}) => { | ||
await page.goto("/"); | ||
|
||
const sendTransactionButton = page.getByTestId("transaction-button"); | ||
await expect(sendTransactionButton).toBeDisabled(); | ||
|
||
const connectButton = page.getByText("Connect Wallet"); | ||
await connectButton.click(); | ||
|
||
const metamaskButton = page.getByText("Metamask"); | ||
await metamaskButton.click(); | ||
|
||
await metamask.acceptAccess(); | ||
|
||
await expect(sendTransactionButton).toBeEnabled(); | ||
await sendTransactionButton.click(); | ||
}); |
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.