--- name: website-qa description: > The pre-launch QA gate for a new site: run the starter's basic tests (a11y light+dark, seo, navigation, images, tone, positioning, placeholders, email, links and the rest of tests/*.spec.ts), fix to green, then handle technical SEO / performance — run Lighthouse on the deployed site (PageSpeed Insights as the fallback) and act on First Contentful Paint (FCP) and Largest Contentful Paint (LCP). Use before launch (steps 7–8 of the new-website pipeline) and after any code/copy change. Delegates Core Web Vitals / crawl depth to seo-audit. Trigger phrases: "run the tests", "QA the site", "is the site launch ready", "a11y check", "accessibility test", "Lighthouse", "PageSpeed", "FCP", "LCP", "page speed", "Core Web Vitals", "performance check", "are the tests green". --- # Website QA The gate every page passes before launch, and the check re-run after any edit. Two parts: the **automated basic tests**, then the **performance check**. ## 1. Basic tests (fix to green) `npm test` runs the Playwright suite from the `new-website` skill's `templates/astro/` overlay against a production build (`astro build && astro preview` — the static output Cloudflare serves). Test the contract, not the cosmetics; red → green → commit. - `a11y.spec.ts` — axe WCAG 2 A/AA + best-practice on every page, **light AND dark**; zero violations. Text axe cannot measure (over an image or a gradient) is not a violation: the spec prints each such element as a warning (selector and axe's reason); look at it by eye in both themes. - `seo.spec.ts` — title ≤60 / description 120–160 (hard floor AND cap); og/twitter mirror title/description; canonical == og:url == absolute URL; one `
`, no other file under `src/` may hold the line, and the line must keep to that skill's limits (eight words, 50 characters). |
| Exposed email/phone | it's rendered via `EmailLink` — assert the built HTML has **no plaintext `mailto:` or literal `@`-address** (crawler/spam protection; see `website-design-system`). |
Keep it thin: a marketing site needs a high-value harness, not 1000 unit tests. Don't test a
cosmetic you'll change next week; do pin every contract a third party could silently break.
## 1c. Enforce the gate on push (the pre-push hook)
The baseline only protects the site if it actually runs before a deploy. The scaffold ships
a **`pre-push` git hook** (`scripts/hooks/pre-push`) that runs `scripts/verify.mjs` (the same
as `npm run verify`: `npm ci` only on its first run or when `package.json` or `package-lock.json` changed, `npm run check`, then
`npm test`, which builds once; short output) and `check_seo.py` (if present), and **refuses the
push if anything is red**. A site without
`scripts/verify.mjs` gets the older `npm run build` + `npm test`. It's wired automatically: the `prepare` script in
`package.json` (`node scripts/wire-hooks.mjs`, a line with no shell syntax) points
`core.hooksPath` at `scripts/hooks` on `npm install` — when the site is the root of its git
repo. In a subfolder of a bigger repo it leaves that repo's hooks alone, so the gate is not
wired there; say so rather than assume it runs.
This is the local complement to CI: Cloudflare builds on push **independently of CI**,
so without this hook a red test would still deploy. The hook runs before each push from a
clone where it is installed (unless skipped with `--no-verify`), including the owner's own
direct push to `main` on a single-owner site (`PUBLISHING.md`). It tests the files on disk, not
the commit being pushed, so a fix left uncommitted can hide a red commit: commit before you
push. Apart from the site's first upload, assistants never push to `main` that way: they open
pull requests (`AGENTS.md` §2), and CI checks those.
**Offer it as a choice — never silently impose or remove it (Rule 1/Rule 12).** When setting
up or handing off a site, surface both directions:
- **Relax for one push:** `git push --no-verify` (skips the hook for that push only).
- **Disable entirely:** `git config --unset core.hooksPath` (re-enable with
`npm install`, or `git config core.hooksPath scripts/hooks`).
- **Tune what it runs:** edit `scripts/hooks/pre-push` (e.g. leave out a slow step; CI still
runs everything).
An owner who pushes directly and wants the safety of the gate keeps it on; a solo
builder mid-experiment may want it off. Make the call explicit with the user; don't decide for
them. (Requires the per-machine `npx playwright install chromium` from SETUP.md, or the test
step errors — a fail-loud, fixable by setup, not a reason to drop the hook.)
## 2. Performance — Lighthouse / PageSpeed (FCP & LCP)
The agent runs Lighthouse itself; the user is asked only when it cannot.
1. **Install it in a scratch folder outside the site**, so the site's `package.json` and its
pre-push hook stay untouched: `npm init -y && npm install lighthouse@13` there (without the
`npm init`, npm walks up to the nearest `package.json` and installs into it). Lighthouse
needs Chrome; use Playwright's, whose path this prints when run **in the site folder**:
`node -e "import('@playwright/test').then(m=>console.log(m.chromium.executablePath()))"`.
2. **Run it in the scratch folder** (there `npx` finds that install, not the latest version),
five times, then print the median run's score, FCP and LCP:
```bash
for i in 1 2 3 4 5; do CHROME_PATH="