# Test Plan and Results

Last run: 2026-11-26 on Windows / PHP 8.2.12 / Node 22 / Playwright 1.64.

## How to run

```bash
php artisan test                                   # PHPUnit, SQLite in memory
vendor/bin/pint --test                             # code style
npm run build                                      # production assets
node tests/e2e/audit.mjs chromium|firefox|webkit   # axe WCAG A/AA, links, headings, images, LCP/CLS
ENGINE=webkit node tests/e2e/screens.mjs <outDir> 1920,1366,1024,768,390,360   # screenshots, overflow, console errors
E2E_EMAIL=... E2E_PASSWORD=... ENGINE=firefox node tests/e2e/smoke.mjs        # public + CMS smoke test
E2E_EMAIL=... E2E_PASSWORD=... E2E_IMAGE=<jpg> node tests/e2e/admin-flows.mjs # CMS workflows
php artisan enquiries:prune --dry-run              # retention command
```
The browser scripts need a CMS account. Use a temporary local account and delete it afterwards. Running them creates test enquiries; delete those after testing.

## Automated results

**PHPUnit: 87 tests, 369 assertions, all passing.**

| Suite | What it covers |
|---|---|
| `PublicPagesTest` | each Figma page renders with canonical tag and security headers; non-Figma URLs return 404; form variant per page; unpublished page hidden; drafts not leaked; hidden sections not rendered; sitemap and robots; buttons without links not rendered |
| `EnquirySubmissionTest` | submissions saved and normalised; job queued; required fields per variant; invalid phone, email and name; campus allowlist; honeypot; too-fast and tampered token; rate limit; web/CSRF middleware; both emails sent exactly once; enquiry kept when mail fails; markdown escaped in email |
| `AdminAuthTest` | guest redirect; noindex; login and logging; failed login logged without password; inactive blocked; throttle; deactivated session ended; idle timeout; logout; reset link without account enumeration; single-use token; weak password rejected |
| `AuthorizationTest` | Admin vs Super Admin access (GET and POST); Admin cannot delete enquiries; user creation; last Super Admin protected; no self-deactivation; role not mass assignable |
| `CmsContentTest` | every section editor opens; draft only; preview noindex; publish; save and publish; XSS escaped; dangerous links rejected; unknown fields dropped; validation; repeater limits; IDOR via scoped bindings; hide on publish; form sections cannot be hidden; reorder scoped; discard; home cannot be unpublished; SEO; settings |
| `MediaLibraryTest` | WebP conversion and variants; PHP-as-JPG, SVG and PDF rejected; in-use media protected; guest upload blocked; picker JSON |
| `EnquiryAdminTest` | search and filters; status, notes and follow-up logged; invalid status; archive, restore and delete; CSV formula escaping; guest blocked |
| `PerformanceTest` | every public page runs 6 or fewer database queries (no N+1) |
| `SecurityHeadersAndRetentionTest` | CSP with a nonce that matches the inline script; CSP on admin; `enquiries:prune` deletes only old archived enquiries and refuses periods under 30 days |
| `ContentSafetyTest` (unit) | URL allowlist; tel/mailto detection; video embed allowlist; markdown escaping; schema sanitising |

**Browser checks**

| Check | Chromium | Firefox | WebKit (Safari engine) |
|---|---|---|---|
| `smoke.mjs` (14 checks: forms, tabs, menu, timeline, login, editor, picker, repeater, enquiries) | 14/14 | 14/14 | 14/14 |
| `admin-flows.mjs` (11 checks: picker upload and select, enquiry status, settings, users, activity, alt text, delete, mobile sidebar, logout) | 11/11 | not run | not run |
| Console errors with CSP on (7 URLs) | 0 | 0 | 0 |
| Broken internal links | 0 | 0 | 0 |
| Broken images / images without alt | 0 / 0 | 0 / 0 | 0 / 0 |
| Horizontal overflow (1920 to 360 px) | none | none (1366) | none (390, 1366) |
| YouTube embed under CSP | works | not run | not run |

**Accessibility (axe-core, WCAG 2.1 A/AA)**
- Admin: all 13 screens pass with 0 violations.
- Public: every page has one `h1` and no skipped heading levels. The only remaining violation is **colour contrast from the Figma palette** (see report).

**Performance (Chromium, local XAMPP, no throttling)**

| Page | LCP | CLS | Requests |
|---|---|---|---|
| Home | 1.31 s | 0.035 | 24 |
| About | 1.36 s | 0 | 19 |
| History | 1.07 s | 0 | 16 |
| Campuses | 1.25 s | 0.001 | 20 |
| Contact | 1.30 s | 0 | 15 |

These are local numbers. Measure again on the real hosting.

**Dependencies:** `composer audit` and `npm audit` found 0 vulnerabilities.

## Manual checks done
- Desktop (1920) compared with the Figma frames for all five pages.
- Mobile (390) reviewed in Chromium and WebKit, tablet (768) in Chromium.

## Not done yet
| Check | Why |
|---|---|
| Real SMTP delivery | needs SMTP credentials |
| Real iPhone / Android devices | only desktop browser engines were available |
| Screen reader (NVDA / VoiceOver) | needs a person; ARIA roles and labels are in place |
| Lighthouse on the real server | needs hosting |
