Skip to content

Commit 34de1c4

Browse files
authored
Add and pass an automated aria playwright CI (#48)
* Add and pass an automated aria playwright CI * fix cwd in playwright ci * longer goto timeout * increase the per-test time to match
1 parent 797b343 commit 34de1c4

File tree

26 files changed

+588
-118
lines changed

26 files changed

+588
-118
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ jobs:
7171
- uses: browser-actions/setup-firefox@latest
7272
- run: cargo test --workspace
7373

74-
7574
fmt:
7675
if: github.event.pull_request.draft == false
7776
name: Rustfmt

.github/workflows/playwright.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Playwright Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- /**
9+
- preview/**/*.rs
10+
- preview/**/Cargo.toml
11+
- primitives/**/*.rs
12+
- primitives/**/Cargo.toml
13+
- .github/**
14+
- Cargo.toml
15+
16+
pull_request:
17+
types: [opened, synchronize, reopened, ready_for_review]
18+
branches:
19+
- main
20+
paths:
21+
- /**
22+
- preview/**/*.rs
23+
- preview/**/Cargo.toml
24+
- primitives/**/*.rs
25+
- primitives/**/Cargo.toml
26+
- .github/**
27+
- Cargo.toml
28+
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
test:
35+
if: github.event.pull_request.draft == false
36+
timeout-minutes: 60
37+
runs-on: ubuntu-latest
38+
steps:
39+
# Do our best to cache the toolchain and node install steps
40+
- uses: actions/checkout@v4
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: lts/*
44+
- name: Install Rust
45+
uses: dtolnay/[email protected]
46+
with:
47+
targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
48+
- uses: Swatinem/rust-cache@v2
49+
with:
50+
cache-all-crates: "true"
51+
cache-on-failure: "true"
52+
- name: Clear base path
53+
run: rm -f preview/Dioxus.toml
54+
- name: Install dx
55+
run: cargo install [email protected]
56+
- name: Install dependencies
57+
run: cd ./playwright && npm ci
58+
- name: Install Playwright Browsers
59+
run: cd ./playwright && npx playwright install --with-deps
60+
- name: Run Playwright tests
61+
run: cd ./playwright && npx playwright test
62+
- uses: actions/upload-artifact@v4
63+
if: ${{ !cancelled() }}
64+
with:
65+
name: playwright-report
66+
path: playwright-report/
67+
retention-days: 30

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
target
22

33
**/.claude/settings.local.json
4+
node_modules
5+
6+
# Playwright
7+
/test-results/
8+
/playwright/playwright-report/
9+
/playwright/test-results/
10+
/blob-report/
11+
/playwright/.cache/

playwright/package-lock.json

Lines changed: 216 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playwright/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"devDependencies": {
3+
"@axe-core/playwright": "^4.10.2",
4+
"@playwright/test": "^1.53.0",
5+
"axe-playwright": "^2.1.0",
6+
"playwright": "^1.53.0"
7+
}
8+
}

playwright/playwright.config.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
const path = require("path");
3+
4+
/**
5+
* Read environment variables from file.
6+
* https://github.com/motdotla/dotenv
7+
*/
8+
// import dotenv from 'dotenv';
9+
// import path from 'path';
10+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
11+
12+
/**
13+
* See https://playwright.dev/docs/test-configuration.
14+
*/
15+
export default defineConfig({
16+
testDir: ".",
17+
/* Run tests in files in parallel */
18+
fullyParallel: true,
19+
/* Fail the build on CI if you accidentally left test.only in the source code. */
20+
forbidOnly: !!process.env.CI,
21+
/* Retry on CI only */
22+
retries: process.env.CI ? 2 : 0,
23+
/* Opt out of parallel tests on CI. */
24+
workers: process.env.CI ? 1 : undefined,
25+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
26+
reporter: "html",
27+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
28+
use: {
29+
/* Base URL to use in actions like `await page.goto('/')`. */
30+
// baseURL: 'http://localhost:3000',
31+
32+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
33+
trace: "on-first-retry",
34+
},
35+
36+
// Each test is given 20 minutes.
37+
timeout: 20 * 60 * 1000,
38+
39+
/* Configure projects for major browsers */
40+
projects: [
41+
{
42+
name: "chromium",
43+
use: { ...devices["Desktop Chrome"] },
44+
},
45+
46+
{
47+
name: "firefox",
48+
use: { ...devices["Desktop Firefox"] },
49+
},
50+
51+
{
52+
name: "webkit",
53+
use: { ...devices["Desktop Safari"] },
54+
},
55+
56+
/* Test against mobile viewports. */
57+
{
58+
name: "Mobile Chrome",
59+
use: { ...devices["Pixel 5"] },
60+
},
61+
{
62+
name: "Mobile Safari",
63+
use: { ...devices["iPhone 12"] },
64+
},
65+
],
66+
67+
/* Run your local dev server before starting the tests */
68+
webServer: {
69+
cwd: path.join(process.cwd(), "../preview"),
70+
command: "dx serve --platform web",
71+
port: 8080,
72+
timeout: 50 * 60 * 1000,
73+
reuseExistingServer: !process.env.CI,
74+
stdout: "pipe",
75+
},
76+
});

0 commit comments

Comments
 (0)