Repository navigation
Description
Summary
We just bootstrapped testing in this repo: vitest (v2, vite-5 compatible), a
single root-page smoke test (tests/smoke/root.smoke.test.ts) that runs in
CI against the live Cloudflare Pages preview, and a preview-URL discovery script
(scripts/get-cloudflare-preview-url.mjs). That gives us a "is the deploy alive"
signal but no fast local tests and only one trivial smoke assertion.
This ticket proposes a deliberate, tiered testing strategy covering both local
fast tests (run on every change / pre-PR) and CI (gate + smoke), so we can
grow coverage without slowing the inner loop. It is a strategy/umbrella ticket —
each tier below can become its own follow-up PR.
Current state
- ✅
vitestinstalled;test:smokescript; dedicatedvitest.smoke.config.ts - ✅ CI
smokejob discovers the CF Pages preview and fetches/(asserts 200 +
SPA shell) - ❌ No unit or component tests, and no
testscript for a fast local lane - ❌ CI gate is
lint + typecheck + buildonly — no tests run on the gate ⚠️ tsconfig.jsonhas"include": ["src"], sopnpm typecheckdoes not
type-checktests/**orscripts/**— test/script type errors slip through⚠️ Two entry points are untested: the embeddable widget (src/Widget.tsx,
HashRouter) and the standalone build (src/main.tsx,BrowserRouter)
Proposed strategy (three tiers)
Tier 1 — Local fast tests (unit / logic), < ~5s
Pure, dependency-light tests that run on every change and pre-PR. High-value
targets:
- zod schemas (
src/types/*) — parse representative API fixtures (incl.
the*Slimlist variants andClient), and assert malformed payloads reject - geo / map helpers — turf-based math and the cluster/selection logic
extracted fromsrc/components/mapbox/ - zustand stores (
src/config/store.ts) —useViewState/useNavigationState
(prev/current path) /useSearchStatereducers - i18n (
src/config/i18n.ts) —%{var}(Ruby-style) interpolation and
locale fallback behavior - api layer (
src/config/api/fetch.ts) — the request interceptor attaches
Authorization+locale(mock axios)
Decision needed: component tests or node-only? WeMeditateWeb deliberately
runs node-only (no jsdom / Testing Library). Options:
- (a) node-only logic tests +
renderToStaticMarkupfor presentational
components (no jsdom) - (b) add
jsdom+@testing-library/reactfor interactive component tests
Recommendation: start with (a) to keep the lane fast; add (b) only if a
component genuinely needs DOM/interaction coverage.
Tier 2 — CI gate
Add the fast lane to the PR gate so logic regressions block merge:
lint + typecheck + unit + build. Add test / test:run scripts and a
vitest.config.ts for the unit lane (separate from vitest.smoke.config.ts).
Optionally add a PostToolUse hook that runs the unit lane after editing
src/** (mirrors the sy-devs-cms "Tier 1 hook" pattern) for instant feedback.
Tier 3 — CI smoke (expand)
Grow tests/smoke/ beyond the root page, still fetch-based against the CF
preview:
- SPA deep-link fallback —
GET /search(and an entity route) returns 200,
validatingpublic/_redirectsworks on Cloudflare (guards the fix from PR chore(claude): add Claude Code config + harmonize lint/format/typecheck #3) - Static assets —
embed.js(the widget bundle) and apublic/locales/...
JSON load with 200 + correct content-type - 404 / unknown asset behavior
- Consider a Playwright smoke (1–2 specs) for actual map render / click,
since fetch only sees the SPA shell of this client-rendered app
Cross-cutting items
- Type-check tests & scripts: add a
tsconfigthat includestests/**and
scripts/**(or a vitest typecheck project) so they're covered by CI - What NOT to test: don't test NextUI / react-map-gl / library internals —
cover our logic and contracts only - Fixtures: a small
tests/fixtures/of real API responses to keep schema
tests honest against the Atlas API shape - Smoke discovery hardening: confirm graceful skip on forked PRs (no token)
and tune the discovery timeout
Acceptance criteria
- Decision recorded: component-test approach (node-only vs. jsdom + RTL)
- Unit lane exists (
vitest.config.ts+test/test:runscripts),
separate from the smoke lane - At least the high-value Tier 1 targets above have unit tests (schemas,
stores, i18n interpolation, api interceptor) - CI gate runs the unit lane (
lint + typecheck + unit + build) -
tests/**andscripts/**are type-checked in CI - Smoke suite covers the SPA deep-link fallback (
/search→ 200) in addition
to the root page - README/CLAUDE.md +
.claude/skills/pr-prep&implement-issueupdated to
reference the real test commands (they currently note "no test suite yet")
Files affected (expected)
vitest.config.ts(new),package.json(scripts/deps)tests/unit/**(new),tests/fixtures/**(new),tests/smoke/**(expand).github/workflows/ci.yml(add unit to gate)tsconfigfor tests/scripts (new or adjusted)- Possibly
.claude/hooks/(unit-test PostToolUse hook),.claude/rules/(a
tests.md), and.claude/skills/{pr-prep,implement-issue}
References
- Smoke infra added in PR chore(claude): add Claude Code config + harmonize lint/format/typecheck #3 (branch
chore/claude-config):
tests/smoke/root.smoke.test.ts,vitest.smoke.config.ts,
scripts/get-cloudflare-preview-url.mjs, the CIsmokejob - Tiered-testing prior art:
sy-devs-cms(Tier 1 hook / Tier 2 pre-PR / Tier 3
CI) andWeMeditateWeb(node-only vitest, fetch smoke vs. CF preview)
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
test(ts): type-check the vitest config files; clarify it/test rule