Skip to main content
# Testing Architecture & Quality Gates This document maps every automated test surface in Uptime Watcher—unit, integration, property-based, fuzzing, Storybook component and runner suites, and Playwright E2E—in one place. Each diagram references the actual configs and directories so contributors can trace where data flows and how coverage gates are enforced. ## Test Suite Topology The first diagram connects the NPM scripts, Vitest projects, Storybook runner, and Playwright projects to the code they exercise. Nodes use the same naming found in `package.json` and the dedicated Vitest configs (`vitest.config.ts`, `vitest.electron.config.ts`, `vitest.shared.config.ts`, `vitest.storybook.config.ts`).## Property & Fuzz Validation Pipelines Shared and Electron tests use `@fast-check/vitest` (see `shared/test/setup.ts`, `electron/test/setup.ts`, `src/test/dom-setup.ts`) to hammer the Zod schemas, monitor factories, and error-handling routines. The diagram outlines how arbitraries feed into validators and what invariants each suite asserts.## Playwright & Electron End-to-End Flow Playwright projects exercise the packaged Electron app. Global setup builds the main process, fixtures launch Electron via `_electron.launch`, and each project records artefacts (`playwright/test-results`, `playwright/reports/html-report`). The sequence diagram captures the control flow for a typical E2E run.## Coverage & Quality Gates - **Front-end Vitest**: 90% line/function thresholds enforced by default reporter (`vitest.config.ts`). DOM helpers and `useSite*` hooks are covered through component tests such as `src/test/App.comprehensive.test.tsx`. - **Electron Vitest**: `vitest.electron.config.ts` enforces 90%+ coverage with mocked Electron APIs and ensures `UptimeOrchestrator` event propagation is verified (`electron/test/UptimeOrchestrator.test.ts`). - **Shared Utilities**: Property-based and fuzz suites under `shared/test` guard serialization, schema validation, and error handling (`jsonSafety.property.test.ts`, `errorHandling.fuzz.test.ts`). - **Storybook Vitest**: `vitest.storybook.config.ts` uses `@storybook/addon-vitest` so Storybook stories are regression tested alongside UI snapshots. - **Playwright**: Projects in `playwright/tests` span main-process boot, renderer workflows, accessibility, and UI regression. Traces/snapshots are retained for first retry or failure as configured in `playwright.config.ts`. ## Running the Matrix Common commands: - `npm run test:all` — Runs frontend, Electron, shared, and Storybook suites without coverage noise. - `npm run test:all:coverage` — Same as above but produces HTML/LCOV reports per suite (`coverage/frontend`, `coverage/electron`, `coverage/shared`, `coverage/storybook`). - `npm run test:e2e` — Executes the Playwright matrix with single worker + Electron HEADLESS mode. - `npm run fuzz` — Filters Vitest to any test name containing `fuzz` or `fuzzing`, ideal for quick property regression sweeps. By following the diagrams and commands above, contributors can reason about where to place new tests, how existing suites interact, and which quality gates will guard their changes.