# Web app quality gates **Audience:** anyone changing the web app (`web/`). All commands run in `web/`. The browser gates start their own backend and practice app on a fresh, throwaway data folder (`e2e/playwright.config.ts`). Before the first run you need: - the Python virtual environment in `architecture/.venv` (or a global `python`); - `npx playwright install chromium`. | Gate | Checks | Run | Where | |---|---|---|---| | Type-check, lint, build | TypeScript, ESLint with 0 warnings, the Vite build | `npm run build`, `npm run lint` | CI (`web`) | | Unit tests | Vitest + Testing Library | `npm test` | CI (`web`) | | End-to-end | Consultant flow, RBAC/CSRF, live view, chat, brand and keyboard | `npm run e2e` | CI (`web-e2e`) | | Accessibility | axe-core on every main screen (signed out and in, including the run views) at 1280 and 375 px, light and dark | `npm run test:a11y` | CI (`web-e2e`) | | Visual regression | Sign-in, Home, Test runs, Ask and Settings at 1280 and 375 px against stored screenshots | `npm run test:visual` | Local | | Lighthouse | Sign-in page, desktop and mobile | `npm run lighthouse` (start the app first) | Local | | Pre-commit | ESLint on staged `.ts`/`.tsx`, type-check of both TS projects | Automatic on `git commit` | Local (husky) | | Dependencies | `npm audit` | `npm audit --omit=dev` | CI (`web`) | ## Budgets - **Accessibility:** - Fails on any serious or critical axe violation. - Moderate and minor findings appear as test annotations in the report, without failing. - **Visual regression:** a screen may differ by at most 1 % of its pixels (`maxDiffPixelRatio: 0.01`). These are masked: - times and dates; - run ids; - the version line; - 3D canvases. - **Lighthouse (sign-in page):** | Category | Minimum | |---|---| | Performance | 80 | | Accessibility | 95 | | Best practices | 90 | | SEO | 80 | Signed-in screens are covered by the accessibility gate instead. Lighthouse runs as `npx lighthouse@13.6.0` and is not a dependency (see `docs/DEPENDENCIES.md`). ## Visual baselines Baselines live next to the spec in `e2e/visual.e2e.ts-snapshots/`. When a screen changes on purpose: 1. Run `npm run test:visual:update`. 2. Open the new images and check each one. 3. Commit them together with the change. Screenshots differ between operating systems (fonts, anti-aliasing), so baselines are made and compared on the same platform. That is why visual regression is a local gate and not a CI one. ## Pre-commit hook `npm install` runs `prepare`, which points git at `web/.husky`. The hook runs `npx lint-staged`, configured in `web/lint-staged.config.js`. - It checks only staged files, except the type-check, which runs once for each project. - Skip it in an emergency with `HUSKY=0 git commit …`. - CI sets `HUSKY=0`. **Prettier is not used.** The codebase has its own consistent formatting, and adding Prettier now would reformat every file in one unrelated commit. ## Pending owner decisions - **Storybook:** the shared components (`DataTable`, `QueryState`, `NavTabs`, `CoworkerCard`, the `pw-*` surfaces) would benefit from it. It adds a large dev-dependency tree and a build to maintain, so it waits for an owner decision. - **Tooling majors:** vitest 5 and ESLint/typescript-eslint majors clear the remaining dev-only `npm audit` advisories (`docs/DEPENDENCIES.md`).