Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: Playwright e2e #442

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
73 changes: 73 additions & 0 deletions .github/workflows/ci-playwright.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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 & Test integrations
run: make -C integrations
- name: Checkout code
uses: actions/checkout@v4
- name: Start example
run: pnpm dev &
working-directory: examples/wagmi-v2
- run: npx wait-on http://localhost:5173/ --timeout 60000
- name: Run playwright tests
working-directory: examples/wagmi-v2
run: make 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
2 changes: 2 additions & 0 deletions examples/wagmi-v2/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ stats.html
node_modules
dist
dist-ssr
playwright-report
test-results
*.local

# Editor directories and files
Expand Down
2 changes: 1 addition & 1 deletion examples/wagmi-v2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
full: dependencies build

test:
@echo Please make tests for wagmi-v2 example!
$(NPM) run e2e:test

run:
$(NPM) run dev
Expand Down
6 changes: 4 additions & 2 deletions examples/wagmi-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"lint": "biome check .",
"format": "biome format --write .",
"preview": "vite preview",
"start:server": "vite --port 3000"
"start:server": "vite --port 3000",
"e2e:test": "playwright test"
},
"dependencies": {
"@oasisprotocol/sapphire-wagmi-v2": "workspace:^",
"@oasisprotocol/sapphire-paratime": "workspace:^",
"@oasisprotocol/sapphire-wagmi-v2": "workspace:^",
"@playwright/test": "^1.48.0",
"@tanstack/react-query": "5.0.5",
"abitype": "^1.0.2",
"react": "^18.2.0",
Expand Down
38 changes: 38 additions & 0 deletions examples/wagmi-v2/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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:5173/",
trace: "on-first-retry",
headless: false,
screenshot: {
mode: "only-on-failure",
fullPage: true,
},
},
/* Configure projects for major browsers */
projects: [
{
name: 'main',
testDir: './test/e2e/',
use: {
...devices['Desktop Chrome'],
},
},
],
});
2 changes: 1 addition & 1 deletion examples/wagmi-v2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function App() {
abi: StorageABI,
address: contractAddress,
functionName: "store",
args: [BigInt(Math.round((Math.random() * 100000)))],
args: [BigInt(40367)],
} as const;
const result = await walletClient!.writeContract({
...callArgs,
Expand Down
Loading
Loading