Playwright e2e

From hmislk/hmis · View interactive version

Playwright e2e is an AI agent skill from the GitHub repository hmislk/hmis. Drive the running HMIS app with the Playwright MCP server for end-to-end verification of a feature (login, department selection, PrimeFaces AJAX forms, confirm dialogs, DB-backed verification). Use when asked to test, verify, or screenshot a feature in the browser, or to confirm a fix works end-to-e

How to use this skill

Skill file

Playwright E2E Testing (HMIS)

Full operational workflow lives in

Playwright E2E Testing Workflow —

read it before driving the browser. This skill is the entry point and adds the

rebuild/redeploy and permission context.

For general MCP tool mechanics (tool reference, clicking/dropdown/file-upload

patterns, common errors) see the companion

Playwright MCP Guide —

the workflow doc above is HMIS-specific; the guide is generic Playwright MCP usage.

🚨 Never navigate by URL

Only ever type a URL for the application root / login page. Every inner page

must be reached by clicking through the menus, exactly as a user would. Real

users have no other way in — some terminals are kiosks with no address bar.

This is not cosmetic. HMIS pages are backed by @SessionScoped controllers whose

state is set by the navigation method (toSearchServiceBill(),

toManageDepartmentPreferences(), …), not by the page. Load the page by URL and

that state is null, or a lazily-created transient placeholder — so the page can

500, render blank, or run pathologically slowly in a way no user can ever hit.

Anything you observe that way is an artifact, not a defect.

Establish the menu path before testing and record it in the issue/PR in the

form the user can follow, e.g. *Menu → Inpatient → Search → Service Bill → set

From Date → Search Bill → click Bill No → Return*. If no menu path exists, that

is the finding — the page is unreachable in production. Do not fall back to the

URL to get on with the test. See

§2.

If the Playwright MCP server shows as unavailable

An MCP server that failed to connect at session start (e.g. a system-reminder

saying playwright (CONNECT_TIMEOUT) or similar) will not self-heal

mid-session — a session's MCP connections are established once at startup, so

retrying a Playwright tool call again later in the same session wastes a

round-trip and always fails the same way.

Instead, immediately and without asking the user, run:

claude mcp list

This performs a fresh, independent health check outside the current session's

stale connection state. claude mcp list reports one of several distinct

statuses per server — treat each differently rather than collapsing them into

a binary "healthy or not":

was specific to this session's startup timing, not a real outage. Tell the

user briefly that the initial connection attempt timed out but the server

is confirmed healthy, then fall back to claude-in-chrome for this

session (per [[feedback-prefer-playwright-over-claude-in-chrome]] project

memory) and recommend starting a fresh session next time to pick up the

working connection.

header the current session hasn't provided. Tell the user it needs

re-authentication (/mcp panel or claude mcp login) rather than treating

it as down.

tell the user to run claude interactively to approve it, not a real

outage either.

tool listing errored; this is a real (if partial) problem worth surfacing,

distinct from a clean outage.

as a genuine outage. Say so explicitly and ask the user how to proceed (fix

the server, proceed with claude-in-chrome, or skip live browser testing)

rather than silently substituting one tool for the other.

(Statuses per the Claude Code MCP docs as of this writing — reconfirm against

current documentation if claude mcp list's output format has changed.)

Never silently swap in claude-in-chrome without first running this check and

telling the user which case applies — claude-in-chrome cannot handle native

confirm()/alert()/prompt() dialogs (they freeze the extension), which

HMIS billing/save flows trigger routinely, so the substitution carries real

risk the user should know about upfront.

Workflow

A coordinating session may hand the browser work (steps 3-7) to the

hmis-qa-verifier subagent, which preloads this skill and returns a PASS/FAIL

table. If you are that subagent, skip this paragraph.

  1. Confirm the target with the user: which feature/page, which local

deployment URL, and whether the code under test is already deployed.

  1. If not yet deployed, rebuild and redeploy — see

§0a Rebuild and redeploy.

A redeploy invalidates the session, so this must happen before login.

  1. Login + department selection — see

§1.

Then reach the page under test through the menus only — never by URL

(see above).

  1. Drive the feature using accessibility snapshots (browser_snapshot)

to locate elements, real key events for PrimeFaces inputs (§3), and

browser_handle_dialog for confirm() guards (§4). Wait on the expected

result (browser_wait_for) rather than fixed sleeps (§5a). Watch for

§12

(required-field validation blocking unrelated nav buttons),

§13

(p:selectOneMenu click-option pattern), and

§14

(non-AJAX search clicks that time out but still succeed).

If a click "succeeds" but nothing happens (no POST, menu/accordion

won't open), check devicePixelRatio first — a zoomed MCP profile

makes clicks no-ops. Switch to the local Node rig; see

§146.

  1. If the DB lacks suitable test data, generate it through the app — see

§15.

Never fall back to "code looks correct" as evidence.

Then leave it there. Test records are not litter — do not clean up, and

do not offer to, unless explicitly asked; just say what you created. A

request to test is also never a request to test in production: if a

verification step is about to write to a production environment, stop and

confirm the target. See

§15a.

  1. Verify in the database — read-only mysql queries against the local

DB per §6.

Credentials come from C:\Credentials\ (outside the repo).

  1. Capture evidence outside the repo: pass browser_take_screenshot an

absolute filename in the machine's out-of-repo directory (two-tier temp

policy in CLAUDE.md), since Playwright MCP otherwise writes to

.playwright-mcp/ inside the repo. Then follow

§8

for anything destined for the wiki/issue. Remove temp screenshots from the

repo afterward.

  1. If Playwright can't find a control, treat it as a product accessibility gap

(§7) — fix the page, not the test.

  1. If a report is slow or times out while you test, file a GitHub issue for it

(fast DTO-based report as the default, legacy report kept for cross-check).

See the performance-optimization skill.

Required permissions

This skill needs, beyond the defaults:

the local rebuild step (paths in CLAUDE.md § Local build tools).

If any of these prompt for approval, the user's settings.local.json should

already allow them for this project — flag it if a prompt appears repeatedly.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.