Skip to content

test: establish a testing strategy (local fast tests + CI smoke) - #7

Merged
Ardnived merged 12 commits into
mainfrom
test/testing-strategy
Jun 18, 2026
Merged

Ardnived merged 12 commits into
mainfrom
test/testing-strategy

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Summary

Establishes the tiered testing strategy from #4: a fast node-only unit lane
for our logic/contracts and an expanded smoke lane for the deploy — wired
into the CI gate, the pre-PR gates, and the edit loop.

  • Adds a Vitest unit lane (vitest.config.ts, pnpm test / test:run) with
    37 co-located specs covering the high-value Tier 1 targets, and grows the
    smoke suite to guard the SPA deep-link fallback.
  • Closes the type-check gap (tests + scripts were unchecked) and updates the
    docs/skills that claimed "no test suite yet".

Changes

By acceptance criterion:

  • Decision recorded — node-only Vitest, no jsdom/Testing Library (mirrors
    WeMeditateWeb); presentational components assert SSR markup via
    renderToStaticMarkup. Captured in .claude/rules/tests.md, with
    src/components/atoms/Icons/Icons.test.tsx as the template.
  • Unit lane — vitest.config.ts (separate from vitest.smoke.config.ts),
    scripts test (watch) / test:run (one-shot).
  • Tier 1 specs — zod schemas (every entity + *Slim + Client +
    Registration), zustand stores, i18n-options %{var} interpolation + en
    fallback, and the axios request interceptor (Authorization + locale).
  • CI gate — pnpm test:run added: lint + typecheck + test:run + build + ladle:build.
  • Type-check tests & scripts — tsconfig.test.json (covers tests/** +
    scripts/**, allowJs/checkJs for the .mjs); typecheck now runs both
    projects. Co-located src/**/*.test.ts(x) are covered by the app project.
  • Smoke — tests/smoke/spa-fallback.smoke.test.ts (GET /search → 200 +
    SPA shell, guards public/_redirects) + shared tests/smoke/_helpers/preview.ts.
  • Docs/skills — CLAUDE.md, README.md, and the pr-prep /
    implement-issue skills (+ their gate scripts) now run/reference the unit lane.
  • Edit-loop hook — .claude/hooks/unit-test.mjs runs the lane on src/**
    edits (non-blocking), mirroring the sy-devs-cms Tier 1 hook.

Verification

  • Lint: ✓ No errors (pnpm lint)
  • Types: ✓ Clean (pnpm typecheck — both projects)
  • Tests: ✓ 37 unit specs pass (pnpm test:run, ~0.5s); smoke specs skip locally
    (no PREVIEW_URL) and run on the CI preview
  • Build: ✓ Success (pnpm build) + pnpm ladle:build — test files are not
    bundled

Notes for reviewer

  • Fixtures: per the WeMeditateWeb pattern, fixtures are inline/factory-based
    and the event specs reuse the schema-typed src/mocks/events.ts — no separate
    tests/fixtures/ dir (the issue listed it as optional/cross-cutting).
  • Specs are co-located under src/ (not tests/unit/), so they're
    type-checked by the app tsconfig and excluded from the bundle by Vite.
  • tsconfig.test.json sets noImplicitAny: false so checkJs doesn't demand
    annotating the intentionally-untyped .mjs build scripts; .ts specs under
    src/ stay strict via the app project.
  • Ran /simplify (extracted the smoke helper, strengthened weak assertions) and
    /code-review (fixed a unit-test-hook timeout edge so a >60s/spawn failure
    isn't misreported as a test failure).

Closes #4

🤖 Generated with Claude Code

Ardnived and others added 11 commits June 18, 2026 18:56
Adds a node-only unit lane separate from the network smoke lane: co-located
`src/**/*.test.ts(x)` specs, run via `pnpm test` (watch) / `pnpm test:run`
(one-shot). Mirrors WeMeditateWeb's vitest setup; `vite-tsconfig-paths`
resolves the `@/` alias.

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Covers every Atlas API contract: Country/Region/Area/Venue/Event (+ their
*Slim list variants), Client, and Registration. Each spec parses a
representative payload and asserts malformed input rejects, so a backend
shape change surfaces as a parse error rather than a deep runtime crash.
Reuses the schema-typed Ladle mocks (src/mocks/events.ts) for the event
fixtures and proves z.coerce.date() coercion from the wire format.

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- store.test.ts: view/navigation/search reducers (drives the vanilla zustand
  stores directly via getState, no React)
- i18n-options.test.ts: boots a standalone i18next instance to lock the
  Ruby-style %{var} interpolation + en fallback contract (no HTTP backend)
- fetch.test.ts: mocks axios + i18n to capture and assert the request
  interceptor attaches Authorization + locale to every request

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Establishes the component-test pattern for this repo: assert SSR markup with
react-dom/server's renderToStaticMarkup instead of booting jsdom/Testing
Library (node-only, mirrors WeMeditateWeb). Serves as the template referenced
by the recorded testing decision.

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
tsconfig.json only includes src/.ladle, so test/script type errors slipped
through. Adds tsconfig.test.json covering tests/** and scripts/** (allowJs +
checkJs for the .mjs build scripts) and runs it as the second half of
`pnpm typecheck`. Co-located unit specs under src/ are already checked by the
app project.

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Gate is now lint + typecheck + unit + build + ladle:build, so logic
regressions block merge. Smoke specs stay in their own job (network, against
the Cloudflare preview).

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adds a smoke spec asserting GET /search returns 200 + the SPA shell on the
Cloudflare preview, validating the public/_redirects fallback that the
standalone BrowserRouter build deep-links rely on. Also gives the smoke lane
retry: 2 / bail: 0 so transient network blips don't flake the job.

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adds a non-blocking unit-test hook that runs `pnpm test:run` after editing a
src/**/*.{ts,tsx} file (co-located specs included; Ladle stories skipped),
surfacing failures as context without aborting the edit. Mirrors the
sy-devs-cms Tier 1 hook pattern.

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Add .claude/rules/tests.md recording the node-only (no jsdom) decision, the
  two lanes, co-location/fixture/mocking conventions, and the type-check setup
- CLAUDE.md / README.md: replace "no test suite yet" with the real test
  commands and lane description
- pr-prep & implement-issue skills: add the unit lane to the lean pre-PR gate
  (check.sh / validate.sh) and update the gate docs

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Extract tests/smoke/_helpers/preview.ts (PREVIEW_URL + skip flag + fetch
  helper) and use it in both smoke specs, mirroring WeMeditateWeb's
  _helpers/preview.ts (dedups the PREVIEW_URL parsing)
- Strengthen happy-path schema specs: capture the parsed value and assert a
  field instead of a bare .not.toThrow()
- vitest.config.ts: use the repo-wide include + meaningful exclude (matches
  WeMeditateWeb's shape) rather than a src-scoped include with a redundant
  exclude

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
spawnSync returns status === null on timeout or spawn failure (not a test
failure); treat that as silent rather than surfacing a misleading "tests
failed" context. Also fall back to process.cwd() when CLAUDE_PROJECT_DIR is
unset. Per /code-review.

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Deploying atlas-legacy with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2036150
Status: ✅  Deploy successful!
Preview URL: https://56de0a6a.syatlas.pages.dev
Branch Preview URL: https://test-testing-strategy.syatlas.pages.dev

View logs

Per /review: add vitest.config.ts / vitest.smoke.config.ts to the test
project's include so the test infra is type-checked too, and clarify in
.claude/rules/tests.md that the "use it" convention is unit-lane scoped (smoke
specs keep test/test.skipIf).

Part of #4

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit d4ce226 into main Jun 18, 2026
3 checks passed
@Ardnived
Ardnived deleted the test/testing-strategy branch June 18, 2026 11:37
Ardnived added a commit that referenced this pull request Nov 7, 2026
…eep (#371)

* fix(map): remember where a fly is going, not where it left

Prague search, open the Brno class, close it, open another straight away, close
that: the list said Prague but the map settled on Brno. The saved camera came from
the store, which only updates when the map stops, so a click during the fly-back
recorded the old place. Save the destination of a move in flight instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(search): a new place search drops the country chosen earlier

United Kingdom, then Tuesday, then a search for Prague kept region=gb, so the
list looked for Prague inside the United Kingdom and said "No events within
150 km". The place-search builder carried every filter across, the region
included. The region is a Where, so it now goes with the old place in
preserveSearchState, for the search box, Near me and the IP suggestion alike.
The other filters still travel.

Ported from 2160576 on ux/fix-filters.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(search): typing in the search field leaves the URL alone until a place is picked

On the results page the field wrote every keystroke into ?q, and the cards read
their "from" place from there. Clearing a London search and typing "Prag" made
every card say "5.1 km from Prag" over London's classes. The field now keeps
what is typed to itself, and the URL changes only when a place is picked (or
Near me names one). Every other field already opted out with
syncToUrl={false}, so the option goes with the behaviour, and the comments that
claimed per-keystroke ?q churn are corrected.

Ported from the MapSearch part of 3300572 on ux/first-screen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(filters): apply URL filters to browse lists and counts

A link carrying filters (/gb/south-east/london?format=online, /gb?days=2)
showed the filter badge and filtered pins over an unfiltered list and counts:
London listed all 19 in-person classes with no pins on the map, and the UK page
counted every class per region. The country, region and online lists now run
the map's own matchesFilters check, show the removable filter pills, offer the
no-results state with Clear filters, and keep the filters on the links one
level down. Framing still covers every class, and the unfiltered query keys
stay as they were, so live preview's writer still lands.

Ported from 032f476 on ux/states.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(nav): a typed or old address climbs the real places behind it

A place resolves by its last slug alone, so /united-kingdom/south-east/london
opens London even though the UK's slug is gb. The panels behind it were built
from the typed words, so the first X opened /united-kingdom/south-east, the
second "We couldn't find that place", and the peek strip read "Back to
united-kingdom". placedPathname swaps the deepest place's address for the one
the region tree gives it, and the strips and the climb read that, so they name
and lead to United Kingdom at /gb. The top view and the address bar keep the
typed address, so nothing remounts when the tree arrives.

After 19637c6 on ux/navigation, rebuilt on main's stack (that commit's own
targets, the Back label and breadcrumbs, are proposal files).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(registration): offer autofill on the name and email fields

The sign-up form's Name and Email fields carried no autocomplete token, so
phones didn't offer the visitor's own name and email. They now say
autocomplete="name" and "email".

The other half of the report's finding, making "privacy policy" a link inside
the consent sentence, needs a %{link} slot in SahajCloud's copy first, so it
is left for a SahajCloud change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(search): suggest places in the country being looked at first

Suggestions were ranked from the middle of the map with no country limit, so
"Hampstead" from the UK page offered four streets near Manchester, then
Hampstead, Quebec, and never the London district; from the home page Quebec
came first. The field now asks for places, not bare streets, and stays in one
country: the one on screen, else the searched place's (?cc), else the last
country page shown (DrawerStack records it, since /search names none), else
the client's home country. A search that finds nothing there repeats itself
everywhere, so Prague is still one search away from the UK page. With no
country to stay in, results rank from the visitor's own area instead of the
middle of a world map.

After f0b3a1a on ux/first-screen; its "search all countries" button needed new
copy, so the release happens by itself instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(search): say so when a typed place doesn't exist

Typing a place that doesn't exist ("zzqqxx") left the country list as it was,
with no answer at all. The field now says "We couldn't find that place." under
itself once the search, widened to every country, comes back empty. The line
reuses the existing not-found copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(search): no distance on results when no place was searched

/search?days=2&region=gb, opened from the filters with no town searched,
printed "5,652 km away" on every UK class: with no searched place the list is
measured from wherever the middle of the map was, and "away" reads as "from
you". The list already knows nothing was searched (hasSearchCenter), so it now
tells its cards not to print a distance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(first-screen): a late "Looking for classes near…" line no longer moves the list

The location notice appears once the visitor's rough location comes back. On a
slow lookup it landed after the list had painted and pushed the rows 48px down
under the visitor's finger. Each list now mounts it twice: above the list only
if the answer was known at the first paint, below the list only if it came
later, where it moves nothing.

The layout half of 21f1592 on ux/first-screen; its "show it only where it
helps" change is a proposal and stays out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(nav): a dead place link offers only its way out

/gb/no-such-place said "We couldn't find that place" under a header with no
title but working Calendar, Search and Filters buttons, all scoped to a place
that doesn't exist. The error chrome now leaves those three out when the page
failed because the place isn't there. A region that failed to load (offline,
server) keeps them, since there they still lead where the visitor wanted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(turnstile): wait longer before calling the security check blocked

When the hidden Turnstile check didn't answer within 10 seconds, the whole
Atlas became "This Atlas can't run on this page", which a slow load did by
itself about once in 30 loads on an iPhone. The error screen stays (#182's
decision), but the handshake now waits 20 seconds, and the page-wide check
gives a silent frame one fresh retry before deciding. A frame that answers
"error" (SahajCloud refusing this page's domain) is still believed at once, so
a partner site on no client's allowed list hears it as fast as before.

docs/embedding.md now says how long a refusing CSP takes to show.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(registration): give the collapsed captcha slot no gap of its own

Since #366 the captcha frame is 0px tall until Cloudflare asks for a click,
which is what most visitors see. The slot was still a flex item, so it took
its column's gap on both sides: the registration form showed 24px of blank
where 12px belonged, while the report form cancelled the same gap by hand
with -mt-4. useTurnstile, which already owns the slot and the frame's height,
now takes the slot out of flow while the frame is collapsed (and when the
check is disabled), and puts it back when Cloudflare wants a click. Neither
form reads `interactive` for spacing any more.

Measured on the register route with a challenge that never answers: fields,
then the buttons 20px below (the 12px gap plus the bar's own 8px), where the
collapsed slot used to add another 12px.

The captcha-slot half of #367; its AddToCalendar follow-ups are untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(embed): a deep link into a hidden tab waits for the tab to open

A host page that keeps the Atlas in a closed tab or accordion broke when the
visitor arrived from a shared link (?atlas=/gb). A page route makes the loader
mount at once, and the widget decides its layout once, from its element's size
at its first render. Inside display:none that was 0x0, which reads as an
unsized embed, so when the tab opened the panel floated over the host page in
the top-left corner, the map was a 400x300 patch, and the host's box stayed
blank. The same page without ?atlas= worked, because a lazy mount waits for
the element to intersect the viewport.

The loader now mounts a deep link at once only into an element that has a box
(getClientRects), and otherwise waits for it to be shown, as a lazy one does.
Checked on a local host page: the live embed reproduces the fault, this build
fills the 1232x644 box with the UK page and its map.

docs/embedding.md says so under Sizing and beside the deep-link rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(changelog): the hidden-tab deep link and the longer security-check wait

Both are visible to a host: an embed in a closed tab now loads when shown, and
a refusing CSP shows the blocked screen after about 40 seconds instead of 10.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(search): release the country scope for one query only

The release was a bare country code and nothing cleared it, so the first search
that came back empty inside the country — the typo that proves #34 — handed
every later search in that field the worldwide ranking. Mapbox puts Hampstead,
Quebec above Hampstead, London once no country is given, so one miss undid the
country scope for the rest of the session.

`searchCountryScope` keys the release to the query that earned it, so the next
query starts inside the country again.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW53aCCKJirBwMxQS8

* fix(filters): count online classes under the region cut

The home list's online badge filtered the cached feed in the view, with
`matchesFilters` and no region matcher. That reads a selected region as no
restriction, so on `/?region=gb` the badge counted online classes worldwide
while every card below it honoured the cut — the disagreement #7 exists to
close.

`getOnlineCount` derives it through `visibleFeatures`, the same predicate the
country counts and the map's pins use. `['countries']` keeps its plain key, so
the stories' own seeding still lands.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW53aCCKJirBwMxQS8

* fix(filters): name the active-filters question once

Three spellings of one predicate had appeared across the browse views —
`filterSearch`, `Boolean(filterSearch)` and `hasActiveFilters(filters)`. The
first two read a filter set through the query string it serializes to, which is
a different question. `hasActiveFilters` is what the data layer gates on, so
every view asks it now.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW53aCCKJirBwMxQS8

* refactor(search): stop the live-region local shadowing the country scope

The hoist effect called its element `scope`, the name the country restriction
above it already has. Two unrelated meanings under one name in one component.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW53aCCKJirBwMxQS8

* docs(state): say why the browsed country is a store, not the URL

The state rule still counted six stores and listed neither of the two this
branch adds, and nothing said why the browsed country sits outside the URL when
the rule puts search state in it — `?cc` already carries a country, so the
answer is not obvious. Both reasons are written down now: what a link must
reproduce, and which question `?cc` answers instead.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW53aCCKJirBwMxQS8

* fix(registration): link the privacy policy inside the consent line

"privacy policy" in the sign-up consent line was plain text. A translation
can now mark the words that link as <link>…</link>, and the form renders them
as a link to https://wemeditate.com/privacy, wherever the language puts them.
The code owns the href, and nothing in the string is rendered as markup.

The existing key, registration.form.privacy_policy, keeps working unmarked:
it reads as plain text, as it does today, until an admin adds the span to it
in SahajCloud.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(data-layer): list the online-count fetcher

The fetcher list is what tells the next author where a derived count comes
from, and `getOnlineCount` was missing from it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW53aCCKJirBwMxQS8

* docs(embedding): say what the geocoder now sends

The place search changed what it asks Mapbox for: a country to stay inside, and
at world zoom a request to rank by the visitor's own IP rather than a map centre
that says nothing there. The privacy section still described the old pair, and it
is the only page a host reads before writing their own notice.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW53aCCKJirBwMxQS8

---------

Co-authored-by: antontcymbal <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: establish a testing strategy (local fast tests + CI smoke)

1 participant