-
Notifications
You must be signed in to change notification settings - Fork 29
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
5 changed files
with
277 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: playwright-test | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
playwright-test: | ||
runs-on: ubuntu-latest | ||
services: | ||
sapphire-localnet-ci: | ||
image: ghcr.io/oasisprotocol/sapphire-localnet:latest | ||
ports: | ||
- 8545:8545 | ||
- 8546:8546 | ||
env: | ||
OASIS_DEPOSIT_BINARY: /oasis-deposit -test-mnemonic -n 5 | ||
options: >- | ||
--rm | ||
--health-cmd="test -f /CONTAINER_READY" | ||
--health-start-period=90s | ||
env: | ||
SAPPHIRE_LOCALNET_HTTP_PROXY_PORT: 3001 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install jq | ||
run: sudo apt install -y jq | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
id: pnpm-install | ||
with: | ||
version: 8 | ||
run_install: false | ||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
run: | | ||
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v4 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Build JS client | ||
run: make -C clients/js build | ||
- name: Build Integrations | ||
run: make -C integrations build ## TODO build only | ||
- uses: JarvusInnovations/background-action@v1 | ||
name: RPC proxy will error if non-encrypted calls are made | ||
with: | ||
run: pnpm run proxy & | ||
wait-on: http://127.0.0.1:${{ env.SAPPHIRE_LOCALNET_HTTP_PROXY_PORT }} | ||
tail: true | ||
log-output-resume: true | ||
wait-for: 31sec | ||
log-output: true | ||
log-output-if: true | ||
working-directory: clients/js | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
# - name: Start example | ||
# run: pnpm dev & | ||
# working-directory: examples/wagmi-v2 | ||
# - name: Wait on Application | ||
# run: npx wait-on http://localhost:5173/ --timeout 60000 | ||
- name: Set up playwright tests | ||
run: pnpm playwright install | ||
- name: Run playwright tests | ||
working-directory: examples/wagmi-v2 | ||
run: pnpm test | ||
- name: 'Upload playwright test-results' | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: playwright-test-results | ||
path: playwright/test-results | ||
retention-days: 5 |
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 { defineConfig, devices } from "@playwright/test"; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
timeout: 2 * 60 * 1000, | ||
testDir: "./test/e2e/", | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: [["html"], ["list", { printSteps: true }]], | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
baseURL: process.env.FRONTEND_URL || "http://localhost:3000/", | ||
trace: "on-first-retry", | ||
headless: false, | ||
screenshot: { | ||
mode: "only-on-failure", | ||
fullPage: true, | ||
}, | ||
}, | ||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'main', | ||
testDir: './test/', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
}, | ||
}, | ||
], | ||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'pnpm run start:server', | ||
url: 'http://localhost:3000', | ||
reuseExistingServer: !process.env.CI, | ||
// stdout: 'ignore', | ||
stderr: 'pipe', | ||
}, | ||
}); |
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,50 @@ | ||
import { BrowserContext, expect, test as baseTest } from "@playwright/test"; | ||
import dappwright, { Dappwright, MetaMaskWallet } from "@tenkeylabs/dappwright"; | ||
|
||
export const test = baseTest.extend<{ | ||
context: BrowserContext; | ||
wallet: Dappwright; | ||
}>({ | ||
context: async ({}, use) => { | ||
// Launch context with extension | ||
const [wallet, _, context] = await dappwright.bootstrap("", { | ||
wallet: "metamask", | ||
version: MetaMaskWallet.recommendedVersion, | ||
seed: "test test test test test test test test test test test junk", // Hardhat's default https://hardhat.org/hardhat-network/docs/reference#accounts | ||
headless: false, | ||
}); | ||
|
||
// Add Hardhat as a custom network | ||
await wallet.addNetwork({ | ||
networkName: "Sapphire Localnet", | ||
rpc: "http://localhost:8545", | ||
chainId: 23293, | ||
symbol: "ROSE", | ||
}); | ||
|
||
await use(context); | ||
}, | ||
|
||
wallet: async ({ context }, use) => { | ||
const metamask = await dappwright.getWallet("metamask", context); | ||
|
||
await use(metamask); | ||
}, | ||
}); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:3000"); | ||
}); | ||
|
||
test("should be able to connect", async ({ wallet, page }) => { | ||
await page.click("#connect-button"); | ||
await wallet.approve(); | ||
|
||
const connectStatus = page.getByTestId("connect-status"); | ||
expect(connectStatus).toHaveValue("connected"); | ||
|
||
await page.click("#switch-network-button"); | ||
|
||
const networkStatus = page.getByTestId("network-status"); | ||
expect(networkStatus).toHaveValue("23293"); | ||
}); |
Oops, something went wrong.