-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
5,248 additions
and
343 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 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,19 @@ | ||
import { type PlaywrightTestConfig, devices } from '@playwright/test'; | ||
|
||
const config: PlaywrightTestConfig = { | ||
webServer: { | ||
command: 'pnpm build && pnpm preview', | ||
port: 4173 | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] } | ||
} | ||
], | ||
testDir: 'tests', | ||
testMatch: /(.+\.)?(test|spec)\.[jt]s/ | ||
}; | ||
|
||
export default config; | ||
|
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,9 @@ | ||
import { test, expect } from './fixtures'; | ||
import { metamask } from './synthetixio'; | ||
|
||
test.only('connect wallet using default metamask account', async ({ page }) => { | ||
await page.goto('/'); | ||
await page.click('#metamaskConnect'); | ||
await metamask.acceptAccess(); | ||
await expect(page.locator('#metamaskAccount')).toContainText('0xf39Fd6e5'); | ||
}); |
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,54 @@ | ||
import { test as base, chromium, type BrowserContext } from '@playwright/test'; | ||
import { metamask, playwright, synpress, helpers } from './synthetixio'; | ||
|
||
export const test = base.extend<{ | ||
context: BrowserContext; | ||
}>({ | ||
context: async ({}, use) => { | ||
// required for synpress as it shares same expect instance as playwright | ||
await playwright.setExpectInstance(expect); | ||
|
||
// download metamask | ||
const metamaskPath = await helpers.prepareMetamask(process.env.METAMASK_VERSION || '10.25.0'); | ||
|
||
// prepare browser args | ||
const browserArgs = [ | ||
`--disable-extensions-except=${metamaskPath}`, | ||
`--load-extension=${metamaskPath}`, | ||
'--remote-debugging-port=9222' | ||
]; | ||
|
||
if (process.env.CI) { | ||
browserArgs.push('--disable-gpu'); | ||
} | ||
|
||
if (process.env.HEADLESS_MODE) { | ||
browserArgs.push('--headless=new'); | ||
} | ||
|
||
// launch browser | ||
const context = await chromium.launchPersistentContext('', { | ||
headless: false, | ||
args: browserArgs | ||
}); | ||
|
||
// wait for metamask | ||
await context.pages()[0].waitForTimeout(3000); | ||
|
||
// setup metamask | ||
await metamask.initialSetup(chromium, { | ||
secretWordsOrPrivateKey: 'test test test test test test test test test test test junk', | ||
network: 'optimism', | ||
password: 'Tester@1234', | ||
enableAdvancedSettings: true | ||
}); | ||
|
||
await use(context); | ||
|
||
await context.close(); | ||
|
||
await synpress.resetState(); | ||
} | ||
}); | ||
|
||
export const expect = test.expect; |
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,9 @@ | ||
import { createRequire } from 'module'; | ||
const require = createRequire(import.meta.url); | ||
|
||
const metamask = require('@synthetixio/synpress/commands/metamask'); | ||
const playwright = require('@synthetixio/synpress/commands/playwright'); | ||
const synpress = require('@synthetixio/synpress/commands/synpress'); | ||
const helpers = require('@synthetixio/synpress/helpers'); | ||
|
||
export { metamask, playwright, synpress, helpers }; |
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,6 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('index page title ok', async ({ page }) => { | ||
await page.goto('/'); | ||
await expect(page).toHaveTitle('Kredeum NFTs Factory'); | ||
}); |