**Priority:** High (Final sprint before 27 Nov) **Source:** Peer feedback + pre-submission code, a11y & security audit + live NTNU VM check ## Problem 1. **Playwright E2E tests do not run in CI (`.github/workflows/ci.yml:16-434`, `e2e/playwright.config.ts:13-26`, `package.json:18,20`):** - `ci.yml` has zero references to `e2e`/Playwright (`pnpm -r test` skips `@t19/e2e`), and `playwright.config.ts` has no `webServer` block, so E2E regressions can silently land on `main` (cited by 5 reviewers). - **Operational VM constraint:** Live VM `/` disk usage is **86.5%** (18.52 / 21.43 GiB, ~2.9 GiB free) on the shared self-hosted runner — Playwright browser binaries and artifacts must be managed carefully. 2. **Missing E2E & jsdom accessibility coverage (`e2e/tests/search.spec.ts`, `filters.spec.ts`, `a11y.spec.ts:19-44`, `client/src/a11y.test.tsx:122-196`, `ReviewForm.test.tsx:152-155`):** - No E2E tests cover Your Crate (add → `/crate` → reload → remove), Search History keyboard selection, Load More pagination, Review form validation/editing, or direct shared multi-filter URLs. - Real-browser `axe` never scans `/crate`, dark mode (`colorScheme: 'dark'`), mobile viewports, open search-history combobox, or `ReviewForm` error state; jsdom `a11y.test.tsx` omits `AlbumDetailPage`, `CratePage`, open `RecentSearches`, and `ReviewForm` error state. 3. **Review & crate mutations lack real PostgreSQL integration tests (`server/src/reviews.test.ts:14-34`, `crate.test.ts:7-22`, `server/scripts/assert-postgres-tests.mjs:22-30`):** - Mutation unit tests pass `{} as never` as `db`; zero Postgres tests exercise `upsertReview`, `deleteReview` (cross-user protection, DB rating/timestamp triggers), `reviewsForAlbum` cursor pagination, or idempotent `addToCrate`/`removeFromCrate`. 4. **CI/CD & lint hardening gaps (`package.json:13`, `.github/workflows/ci.yml:1-25,105-118,222-254,277-434`, `docs/VM-setup.md`):** - Root `package.json:13` runs `"lint": "eslint ."` without `--max-warnings 0` despite `AGENTS.md:24`. - `Publish to Apache` (`ci.yml:247-248`) deletes `/var/www/html/project2` before copying new assets, and deploy runs `git checkout --force` over live `~/T19-Project-2` with no rollback of frontend or API on migration/restart/smoke failure. - `ci.yml` sets no `permissions:` block, pins Actions to mutable `@v4` tags instead of commit SHAs, and `docs/VM-setup.md` does not document the self-hosted PR runner trust boundary. ## Suggested solution - Add a Playwright E2E job to `.github/workflows/ci.yml` using a throwaway seeded Postgres DB, built API + static/preview client, and **Chromium only** (gating `deploy`), reusing a single cached Chromium install and cleaning artifacts/temp DBs so the VM's ~2.9 GiB free disk space is respected; optionally add `webServer` in `e2e/playwright.config.ts` when `E2E_BASE_URL` is unset. - Add idempotent Playwright E2E tests (`e2e/tests/crate.spec.ts`, `search.spec.ts`, `a11y.spec.ts`) and jsdom axe tests (`client/src/a11y.test.tsx`, `ReviewForm.test.tsx`) covering Crate persistence, Search History selection, Load More, Review validation/edit, shared multi-filter URLs, `/crate` + dark mode + mobile + open combobox + ReviewForm error axe scans. - Add `server/src/reviews.postgres.test.ts` and mutation cases in `server/src/crate.postgres.test.ts`, registered in `server/scripts/assert-postgres-tests.mjs`. - Enforce `"lint": "eslint . --max-warnings 0"` in root `package.json`. - Make VM deploys atomic with rollback: stage frontend in sibling `.new`/`.prev` directories, record previous API `HEAD` SHA before checkout, and restore both API (`checkout`/rebuild/`systemctl restart crate-api`) and frontend `.prev` if health/smoke checks fail. - Add top-level `permissions: { contents: read }`, pin Actions (`actions/checkout`, `pnpm/action-setup`, `actions/setup-node`) to full commit SHAs with version comments, and document the self-hosted PR runner trust boundary in `docs/VM-setup.md`. ## Acceptance criteria - [ ] Playwright E2E runs automatically in CI on PRs and pushes to `main` (blocking `deploy`), uses Chromium only without blowing VM disk space, and passes cleanly. - [ ] E2E suite covers Crate add/reload/remove, Search History selection, Load More pagination, Review validation/edit, shared multi-filter URLs, and Playwright `axe` scans for `/crate`, dark mode, mobile viewport, open history dropdown, and `ReviewForm` error state; jsdom `axe` covers `AlbumDetailPage`, `CratePage`, open `RecentSearches`, and `ReviewForm` errors. - [ ] Real PostgreSQL integration tests verify `upsertReview`, `deleteReview` (including cross-user protection and DB triggers), `reviewsForAlbum` cursor pagination, `addToCrate`, and `removeFromCrate`, and are guarded by `server/scripts/assert-postgres-tests.mjs`. - [ ] `pnpm lint` enforces `--max-warnings 0` and passes cleanly. - [ ] CI deploy stages frontend atomically (`.new`/`.prev`) and rolls back both API and frontend on failure; `ci.yml` sets `permissions: { contents: read }` and pins Actions to commit SHAs; `docs/VM-setup.md` documents the self-hosted PR runner trust boundary. ### Optional stretch (if time permits) - [ ] Clear `localStorage`/`sessionStorage` in `client/src/test/setup.ts`, add a local `test:integration` script invoking `assert-postgres-tests.mjs`, and relax brittle verbatim SQL string assertions in `server/src/search/search.test.ts`.