Skip to content

Commit e667e2b

Browse files
ostenbomclaude
andcommitted
Add an owner invite test written with playwright-intent
The test's steps are plain-language intents. The code generated for each step is committed in .intent and replayed on every run. On a pull request, the agent repairs a step that no longer matches the app and commits the new step to the branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3a76283 commit e667e2b

12 files changed

Lines changed: 227 additions & 8 deletions

File tree

‎.github/workflows/e2e-intent.yml‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Playwright Intent
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- webinar/main
7+
8+
permissions:
9+
contents: write # the agent commits changed steps to the pull request
10+
id-token: write # used by the Vercel deployment action
11+
12+
jobs:
13+
e2e:
14+
if: github.repository == 'endformdev/playwright-tutorial'
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 30
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up pnpm
22+
uses: pnpm/action-setup@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 24
28+
cache: "pnpm"
29+
30+
- name: Install dependencies
31+
run: pnpm install
32+
33+
- name: Install Playwright browsers
34+
run: pnpm exec playwright install --with-deps chromium
35+
36+
- name: Wait for Vercel deployment
37+
uses: endformdev/actions/run-with-vercel-deployment@main
38+
with:
39+
project-name: endform-playwright-tutorial
40+
set-url-env-var: BASE_URL
41+
set-vercel-bypass-env-var: VERCEL_BYPASS_TOKEN
42+
43+
- name: Run intent tests
44+
run: pnpm exec playwright test -c playwright.intent.config.ts
45+
env:
46+
AI_GATEWAY_API_KEY: ${{ secrets.AI_GATEWAY_API_KEY }}
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ node_modules/
5151
.playwright-mcp/
5252

5353
.auth/
54+
/test-results-intent/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// intent: "check that the invitation was sent"
2+
// test: "should invite a teammate as an owner"
3+
import type { StepContext } from "playwright-intent";
4+
5+
export default async function ({ page, context, request, expect, vars }: StepContext): Promise<void> {
6+
await expect(page.getByText('Invitation sent successfully')).toBeVisible();
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// intent: "invite {email} to the team as an owner"
2+
// test: "should invite a teammate as an owner"
3+
import type { StepContext } from "playwright-intent";
4+
5+
export default async function ({ page, context, request, expect, vars }: StepContext): Promise<void> {
6+
await page.getByRole('textbox', { name: 'Email' }).fill(vars.email);
7+
await page.getByRole('radio', { name: 'Owner' }).check();
8+
await page.getByRole('button', { name: 'Invite Member' }).click();
9+
await expect(page.getByText('Invitation sent successfully')).toBeVisible();
10+
}

‎.oxfmtrc.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"**/.auth",
1818
"app/globals.css",
1919
"**/playwright-report",
20-
"**/test-results"
20+
"**/test-results",
21+
"**/.intent",
22+
"**/test-results-intent"
2123
],
2224
"overrides": [
2325
{

‎.oxlintrc.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ignorePatterns": [".intent/**"]
3+
}

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"endform": "^0.82.2",
5151
"oxfmt": "0.78.0",
5252
"oxlint": "1.93.0",
53+
"playwright-intent": "0.1.0",
5354
"playwright-opentelemetry": "^0.15.0",
5455
"tsx": "^4.23.15",
5556
"typescript": "^7.0.2"

‎playwright.intent.config.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
import type { IntentOptions, IntentUseOptions } from "playwright-intent";
3+
import { allow, commit, fileStore } from "playwright-intent/file-store";
4+
import { baseURL } from "./playwright.config";
5+
6+
// Steps live in .intent and are committed like any other code. Locally the
7+
// agent writes changed steps to disk for you to review. On a pull request it
8+
// commits them to the branch, so the change shows up in the diff.
9+
const intent = {
10+
store: fileStore({ updates: { local: allow(), ci: commit() } }),
11+
model: "openai/gpt-6-luna",
12+
} satisfies IntentOptions;
13+
14+
export default defineConfig<IntentUseOptions>({
15+
testDir: "./tests-intent",
16+
outputDir: "./test-results-intent",
17+
timeout: 120_000,
18+
// A repaired step can leave the page in a changed state, so the retry
19+
// replays the test from the start with the new step.
20+
retries: 2,
21+
reporter: [["list"], ["playwright-intent/reporter", intent]],
22+
use: {
23+
...devices["Desktop Chrome"],
24+
baseURL,
25+
extraHTTPHeaders: process.env.VERCEL_BYPASS_TOKEN
26+
? {
27+
"x-vercel-protection-bypass": process.env.VERCEL_BYPASS_TOKEN,
28+
"x-vercel-set-bypass-cookie": "true",
29+
}
30+
: undefined,
31+
trace: "on",
32+
intent,
33+
},
34+
});

‎pnpm-lock.yaml‎

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

‎pnpm-workspace.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ allowBuilds:
55

66
minimumReleaseAgeExclude:
77
- playwright-opentelemetry@0.15.0
8+
- playwright-intent@0.1.0
89

910
onlyBuiltDependencies:
1011
- better-sqlite3

0 commit comments

Comments
 (0)