Ask your agent
What it does
This runs a Playwright pre-ship gate across desktop and mobile viewports. It checks runtime and network failures, broken images, overflow, touch targets, keyboard focus, form validation, and double-submit behavior, then captures evidence and tears down temporary servers.
SKILL.md
---
name: autonomous-playwright-qa-gate
description: Zero-offload pre-ship quality assurance gate using Playwright for web applications, landing pages, and SaaS frontends. Enforces five automated verification checks before release — zero console or network errors, zero broken images or horizontal overflow across desktop (1440px) and mobile (375px), interactive form and double-submit verification, WCAG 2.2 keyboard accessibility smoke checks, and deterministic visual evidence capture. Use before declaring any frontend feature, redesign, or deployment complete.
---
# Autonomous Playwright QA Gate
> Evidence before assertions. Never ship or hand off a frontend route until an automated Playwright pass verifies runtime health, mobile geometry, form idempotency, and keyboard accessibility.
---
## 1. The Pre-Delivery Gate Standard
Every production change must pass five non-negotiable checks in a real headless browser before merge or deployment:
1. **Zero Runtime & Asset Failures:** Zero `console.error`, zero uncaught `pageerror`, zero unexpected `4xx`/`5xx` network responses on critical assets, and zero unloaded `<img>` tags (`naturalWidth === 0`).
2. **Dual-Viewport Geometry Lock:** Verify both desktop (`1440×900`) and compact mobile (`375×812`) with strict horizontal overflow detection (`scrollWidth <= innerWidth`).
3. **Interactive & Form Idempotency:** Exercise real user flows (validation errors, successful submission state, and double-click submission locking) rather than checking static HTML alone.
4. **WCAG 2.2 Keyboard & Control Smoke:** Confirm interactive controls are reachable via `Tab`, respond to `Enter`/`Space`/`Escape`, expose accessible names, and meet minimum `44×44px` touch target sizing on mobile.
5. **Proof & Teardown:** Capture clean post-fix viewport screenshots and terminate all temporary local preview servers immediately after verification.
---
## 2. Production Playwright Gate Harness (`tests/qa-gate.spec.ts`)
Drop this self-contained Playwright suite into any Next.js, Vite, or Astro project and run it against your local preview or staging URL (`BASE_URL=https://preview.example.com npx playwright test tests/qa-gate.spec.ts`):
```ts
import { test, expect } from '@playwright/test';
const BASE_URL = process.env.BASE_URL || 'http://127.0.0.1:3000';
const ROUTES = ['/', '/pricing'];
const VIEWPORTS = [
{ name: 'desktop', width: 1440, height: 900 },
{ name: 'mobile', width: 375, height: 812 },
];
for (const route of ROUTES) {
for (const vp of VIEWPORTS) {
test(`QA Gate [${route}] @ ${vp.name} (${vp.width}x${vp.height})`, async ({ page }) => {
const consoleErrors: string[] = [];
const pageErrors: string[] = [];
const failedRequests: string[] = [];
page.on('console', (msg) => {
if (msg.type() === 'error') consoleErrors.push(msg.text());
});
page.on('pageerror', (err) => {
pageErrors.push(err.message);
});
page.on('response', (res) => {
const status = res.status();
const url = res.url();
if (status >= 400 && !url.includes('favicon.ico')) {
failedRequests.push(`${status} ${url}`);
}
});
await page.setViewportSize({ width: vp.width, height: vp.height });
const response = await page.goto(`${BASE_URL}${route}`, {
waitUntil: 'networkidle',
});
// 1. Primary document returns HTTP 200
expect(response?.status(), `Non-200 status on ${route}`).toBe(200);
// 2. Zero horizontal overflow
const overflow = await page.evaluate(() => ({
scrollWidth: document.documentElement.scrollWidth,
innerWidth: window.innerWidth,
}));
expect(
overflow.scrollWidth,
`Horizontal overflow detected on ${route} (${vp.name})`
).toBeLessThanOrEqual(overflow.innerWidth);
// 3. Every visible image loaded cleanly
const brokenImages = await page.evaluate(() => {
return Array.from(document.querySelectorAll('img'))
.filter((img) => {
const rect = img.getBoundingClientRect();
return rect.width > 0 && rect.height > 0;
})
.filter((img) => !img.complete || img.naturalWidth === 0)
.map((img) => img.currentSrc || img.src);
});
expect(brokenImages, 'Broken visible images found').toEqual([]);
// 4. Primary interactive buttons meet mobile touch-target guard
if (vp.name === 'mobile') {
const tinyButtons = await page.evaluate(() => {
return Array.from(document.querySelectorAll('button, a[role="button"]'))
.filter((el) => {
const style = window.getComputedStyle(el);
const rect = el.getBoundingClientRect();
return style.visibility !== 'hidden' && rect.width > 0 && rect.height > 0;
})
.filter((el) => {
const rect = el.getBoundingClientRect();
return rect.height < 40 || rect.width < 40;
})
.map((el) => ({
text: (el.textContent || '').trim().slice(0, 40),
w: Math.round(el.getBoundingClientRect().width),
h: Math.round(el.getBoundingClientRect().height),
}));
});
expect(tinyButtons, 'Undersized mobile touch targets').toEqual([]);
}
// 5. Keyboard focus-visible smoke check
await page.keyboard.press('Tab');
const focusedTag = await page.evaluate(() => document.activeElement?.tagName || 'NONE');
expect(focusedTag).not.toBe('BODY');
// 6. Zero console/runtime/network failures
expect(consoleErrors, 'Console errors detected').toEqual([]);
expect(pageErrors, 'Uncaught page errors detected').toEqual([]);
expect(failedRequests, 'Failed asset/API requests detected').toEqual([]);
});
}
}
```
---
## 3. Form, State & Anti-Double-Submit Testing Pattern
Never rely on client-side happy-path clicks alone. Validate both invalid input rejection and rapid double-submit protection:
```ts
test('Form validation and double-submit idempotency', async ({ page }) => {
let submitCalls = 0;
await page.route('**/api/contact', async (route) => {
submitCalls += 1;
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ ok: true }),
});
});
await page.goto(`${BASE_URL}/`);
// Attempt empty submit — must surface accessible validation error, zero API calls
await page.getByRole('button', { name: /submit|send/i }).click();
expect(submitCalls).toBe(0);
// Fill valid fields and double-click submit rapidly
await page.getByLabel(/name/i).fill('Alex Mercer');
await page.getByLabel(/email/i).fill('alex@example.com');
const submitBtn = page.getByRole('button', { name: /submit|send/i });
await submitBtn.dblclick();
// Confirm idempotent single dispatch
await expect.poll(() => submitCalls).toBe(1);
});
```
---
## 4. Defect Triage & Fix Loop Discipline
When any assertion fails:
1. **Localize Root Cause First:** Read the failing stack trace, DOM box model, or network response before editing code. Never silence failures with empty `try/catch` blocks or relaxed assertions.
2. **Fix at the Source:** Patch the underlying layout constraint, missing `width`/`height`, broken ARIA label, or missing submit lock.
3. **Re-Run the Full Gate:** Every edit requires a fresh end-to-end pass across both desktop and mobile viewports.
4. **Teardown Ephemeral Servers:** Never leave local `next dev`, `vite`, or preview servers orphaned after verification finishes.
---
## 5. Pre-Ship Verification Sign-Off
- [ ] Desktop (`1440×900`) and mobile (`375×812`) pass with zero horizontal scroll (`scrollWidth <= innerWidth`).
- [ ] Zero `console.error`, zero `pageerror`, zero unexpected `4xx`/`5xx` asset responses.
- [ ] Every visible `<img>` reports `naturalWidth > 0` and uses optimized WebP/AVIF formats where supported.
- [ ] Primary forms verify empty validation, successful state rendering (without unsafe `innerHTML`), and double-submit locking.
- [ ] Keyboard navigation (`Tab`, `Enter`, `Escape`, arrow keys on custom sliders) verified in headless browser.
- [ ] Temporary local test servers stopped cleanly.
---
Authored by **ASSEMBLAGE** — High-End Interactive Architecture & Sovereign AI Systems
https://point-of-assemblage.vercel.app
1 file
- SKILL.md8.2 KB