diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..5fe2459
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,10 @@
+version: 2
+updates:
+ # Keeps the SHA-pinned actions in .github/workflows up to date, including their version comments
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: weekly
+ groups:
+ github-actions:
+ patterns: ["*"]
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..7fe280c
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,49 @@
+name: Test
+
+on:
+ pull_request:
+ push:
+ branches: [main]
+
+# Actions are pinned to commit SHAs (the version is in the trailing comment) so a moved tag can't
+# change what runs
+permissions:
+ contents: read
+
+jobs:
+ e2e:
+ runs-on: ubuntu-24.04
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ # Installs the tools pinned in mise.toml (and mise.lock), so Node matches local development
+ - uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8
+ with:
+ version: 2026.9.15
+ - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ~/.npm
+ key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
+ restore-keys: npm-${{ runner.os }}-
+ - run: npm ci
+ - id: playwright-version
+ run: echo "version=$(npx playwright --version | awk '{print $2}')" >> "$GITHUB_OUTPUT"
+ - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ id: playwright-browsers-cache
+ with:
+ path: ~/.cache/ms-playwright
+ key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
+ # System libraries live outside the cached path, so they're installed on every run
+ - run: npx playwright install --with-deps chromium
+ if: steps.playwright-browsers-cache.outputs.cache-hit != 'true'
+ - run: npx playwright install-deps chromium
+ if: steps.playwright-browsers-cache.outputs.cache-hit == 'true'
+ - run: npm test
+ # On failure, keep Playwright's traces (recorded on the first retry) for debugging with
+ # `npx playwright show-trace`
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ if: failure()
+ with:
+ name: playwright-traces
+ path: test-results
diff --git a/.gitignore b/.gitignore
index 144349f..a1507db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,3 +70,7 @@ _site
.wrangler
.dev.vars
+
+# Playwright
+test-results
+playwright-report
diff --git a/README.md b/README.md
index 1de8b83..27f0a05 100644
--- a/README.md
+++ b/README.md
@@ -57,9 +57,9 @@ Preview versions are served from a `*-tools-passkeys-dev.passkeydeveloper.worker
### Deployment
-The site is a Cloudflare Worker serving the built `_site/` directory as static assets (see `wrangler.jsonc`). It is not a Pages project. In Cloudflare, connect the repository under Workers & Pages as a Worker (Workers Builds) with build command `npm run build`, deploy command `npx wrangler deploy`, and non-production branch deploy command `npx wrangler versions upload`.
+The site is a Cloudflare Worker serving the built `_site/` directory as static assets (see `wrangler.jsonc`). It is not a Pages project. In Cloudflare, connect the repository under Workers & Pages as a Worker (Workers Builds) with build command `npm run build`, deploy command `npx wrangler deploy`, and, for non-production branches, preview command `npx wrangler preview` (Worker Previews; the older `npx wrangler versions upload` fails the Workers Builds Worker check once previews are enabled).
-To deploy by hand, run `npm run deploy`. `npm run preview` uploads a version without promoting it and prints its preview URL.
+To deploy by hand, run `npm run deploy`. `npm run preview` creates a Preview deployment without promoting anything and prints its preview URL.
## Structure
diff --git a/package-lock.json b/package-lock.json
index e4a82f8..f26fefa 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11,6 +11,7 @@
"devDependencies": {
"@11ty/eleventy": "^3.1.5",
"@cloudflare/workers-types": "^5.20261103.1",
+ "@playwright/test": "^1.65.0",
"@quasibit/eleventy-plugin-sitemap": "^2.2.0",
"eleventy-plugin-metagen": "^1.8.4",
"luxon": "^3.7.2",
@@ -1393,6 +1394,22 @@
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
+ "node_modules/@playwright/test": {
+ "version": "1.65.0",
+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.0.tgz",
+ "integrity": "sha512-iGURLGuKDLakSEl7Pgfv8h7f+XLT+V861Wfhz0zlEl5nyFuKUopdkFBPKqTllTUp06aOwPuH8iuUEb3yp3MpbQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "playwright": "1.65.0"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
"node_modules/@poppinss/colors": {
"version": "4.1.6",
"resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz",
@@ -3098,6 +3115,35 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
+ "node_modules/playwright": {
+ "version": "1.65.0",
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.0.tgz",
+ "integrity": "sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "playwright-core": "1.65.0"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
+ "node_modules/playwright-core": {
+ "version": "1.65.0",
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.0.tgz",
+ "integrity": "sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "playwright-core": "cli.js"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
"node_modules/please-upgrade-node": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz",
diff --git a/package.json b/package.json
index 0f1104e..2a65173 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
"devDependencies": {
"@11ty/eleventy": "^3.1.5",
"@cloudflare/workers-types": "^5.20261103.1",
+ "@playwright/test": "^1.65.0",
"@quasibit/eleventy-plugin-sitemap": "^2.2.0",
"eleventy-plugin-metagen": "^1.8.4",
"luxon": "^3.7.2",
@@ -13,13 +14,13 @@
"wrangler": "^4.157.0"
},
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1",
+ "test": "playwright test",
"dev": "npm run build && wrangler dev",
"build": "npx @11ty/eleventy",
"build:watch": "npx @11ty/eleventy --watch",
"typecheck": "tsc --noEmit",
"deploy": "npm run typecheck && npm run build && wrangler deploy",
- "preview": "npm run typecheck && npm run build && wrangler versions upload",
+ "preview": "npm run typecheck && npm run build && wrangler preview",
"watch": "npx @11ty/eleventy --watch"
},
"repository": {
diff --git a/playwright.config.ts b/playwright.config.ts
new file mode 100644
index 0000000..fbede4c
--- /dev/null
+++ b/playwright.config.ts
@@ -0,0 +1,27 @@
+import { defineConfig, devices } from '@playwright/test';
+
+const PORT = 8090;
+
+export default defineConfig({
+ testDir: 'tests',
+ fullyParallel: true,
+ forbidOnly: !!process.env.CI,
+ retries: process.env.CI ? 1 : 0,
+ // A test that only passes on retry is still a failure; the retry exists to capture a trace
+ failOnFlakyTests: !!process.env.CI,
+ reporter: process.env.CI ? 'github' : 'list',
+ use: {
+ // `localhost` is a secure context, which WebAuthn requires
+ baseURL: `http://localhost:${PORT}`,
+ trace: 'on-first-retry',
+ },
+ // The virtual authenticator is driven through the Chrome DevTools Protocol
+ projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
+ // Only the static site is served; the API is mocked per test (see tests/helpers.ts) because the
+ // real one needs the webauthnapi-passkeys-dev Worker
+ webServer: {
+ command: `npx @11ty/eleventy --serve --quiet --port=${PORT}`,
+ url: `http://localhost:${PORT}`,
+ reuseExistingServer: !process.env.CI,
+ },
+});
diff --git a/src/_includes/layouts/base.njk b/src/_includes/layouts/base.njk
index f12eebb..9e1fb99 100644
--- a/src/_includes/layouts/base.njk
+++ b/src/_includes/layouts/base.njk
@@ -48,5 +48,14 @@
{% endfor %}
{% endif %}
+ {% if extra_modules %}
+ {% for script in extra_modules %}
+
+ {% endfor %}
+ {% endif %}
+ {# Deferred so it runs after module scripts, which have registered their `alpine:init` listeners #}
+ {% if alpine %}
+
+ {% endif %}