Run Playwright browser tests on pages affected by current PR or branch
Run Playwright browser tests on pages affected by your PR or branch changes. Use it to catch JavaScript integration bugs, CSS regressions, and workflow breakages before deploying. Requires local server running and Playwright MCP connected.
/plugin marketplace add EveryInc/compound-engineering-plugin/plugin install compound-engineering@every-marketplace[PR number, branch name, or 'current' for current branch]<command_purpose>Run end-to-end browser tests on pages affected by a PR or branch changes using Playwright MCP.</command_purpose>
<role>QA Engineer specializing in browser-based end-to-end testing</role>
This command tests affected pages in a real browser, catching issues that unit tests miss:
<test_target> $ARGUMENTS </test_target>
<determine_scope>
If PR number provided:
gh pr view [number] --json files -q '.files[].path'
If 'current' or empty:
git diff --name-only main...HEAD
If branch name provided:
git diff --name-only main...[branch]
</determine_scope>
<file_to_route_mapping>
Map changed files to testable routes:
| File Pattern | Route(s) |
|---|---|
app/views/users/* | /users, /users/:id, /users/new |
app/controllers/settings_controller.rb | /settings |
app/javascript/controllers/*_controller.js | Pages using that Stimulus controller |
app/components/*_component.rb | Pages rendering that component |
app/views/layouts/* | All pages (test homepage at minimum) |
app/assets/stylesheets/* | Visual regression on key pages |
app/helpers/*_helper.rb | Pages using that helper |
Build a list of URLs to test based on the mapping.
</file_to_route_mapping>
<check_server>
Before testing, verify the local server is accessible:
mcp__playwright__browser_navigate({ url: "http://localhost:3000" })
mcp__playwright__browser_snapshot({})
If server is not running, inform user:
**Server not running**
Please start your development server:
- Rails: `bin/dev` or `rails server`
- Node: `npm run dev`
Then run `/playwright-test` again.
</check_server>
<test_pages>
For each affected route:
Step 1: Navigate and capture snapshot
mcp__playwright__browser_navigate({ url: "http://localhost:3000/[route]" })
mcp__playwright__browser_snapshot({})
Step 2: Check for errors
mcp__playwright__browser_console_messages({ level: "error" })
Step 3: Verify key elements
Step 4: Test critical interactions (if applicable)
mcp__playwright__browser_click({ element: "[description]", ref: "[ref]" })
mcp__playwright__browser_snapshot({})
</test_pages>
<human_verification>
Pause for human input when testing touches:
| Flow Type | What to Ask |
|---|---|
| OAuth | "Please sign in with [provider] and confirm it works" |
| "Check your inbox for the test email and confirm receipt" | |
| Payments | "Complete a test purchase in sandbox mode" |
| SMS | "Verify you received the SMS code" |
| External APIs | "Confirm the [service] integration is working" |
Use AskUserQuestion:
**Human Verification Needed**
This test touches the [flow type]. Please:
1. [Action to take]
2. [What to verify]
Did it work correctly?
1. Yes - continue testing
2. No - describe the issue
</human_verification>
<failure_handling>
When a test fails:
Document the failure:
Ask user how to proceed:
**Test Failed: [route]**
Issue: [description]
Console errors: [if any]
How to proceed?
1. Fix now - I'll help debug and fix
2. Create todo - Add to todos/ for later
3. Skip - Continue testing other pages
If "Fix now":
If "Create todo":
{id}-pending-p1-playwright-{description}.mdIf "Skip":
</failure_handling>
<test_summary>
After all tests complete, present summary:
## 🎭 Playwright Test Results
**Test Scope:** PR #[number] / [branch name]
**Server:** http://localhost:3000
### Pages Tested: [count]
| Route | Status | Notes |
|-------|--------|-------|
| `/users` | ✅ Pass | |
| `/settings` | ✅ Pass | |
| `/dashboard` | ❌ Fail | Console error: [msg] |
| `/checkout` | ⏭️ Skip | Requires payment credentials |
### Console Errors: [count]
- [List any errors found]
### Human Verifications: [count]
- OAuth flow: ✅ Confirmed
- Email delivery: ✅ Confirmed
### Failures: [count]
- `/dashboard` - [issue description]
### Created Todos: [count]
- `005-pending-p1-playwright-dashboard-error.md`
### Result: [PASS / FAIL / PARTIAL]
</test_summary>
# Test current branch changes
/playwright-test
# Test specific PR
/playwright-test 847
# Test specific branch
/playwright-test feature/new-dashboard