Skip to content

CS-10009 PR 4: migrate root tests/ to explicit fixture#4819

Merged
lukemelia merged 6 commits into
mainfrom
cs-10009-migrate-root-tests
May 14, 2026
Merged

CS-10009 PR 4: migrate root tests/ to explicit fixture#4819
lukemelia merged 6 commits into
mainfrom
cs-10009-migrate-root-tests

Conversation

@lukemelia
Copy link
Copy Markdown
Contributor

Fourth slice of CS-10009. Stacked on #4798 — review/merge that one first; this PR's base will retarget to main once it lands.

Approach

The remaining realm-server test files live at the packages/realm-server/tests/ root. They split into three groups:

  1. Helper consumers that call setupPermissionedRealmCached / setupPermissionedRealmsCached with no fileSystem (implicit-default = realistic for the duration of the migration). These get an explicit fixture: … option.
  2. Hand-rolled copySync(tests/cards, …) consumers that build their realm directly via runTestRealmServer and don't go through the helper. There's no fixture: option to set — we instead swap the literal join(__dirname, 'cards') for fixtureDir('simple'), which the final PR can flip to 'realistic' once the directory is renamed.
  3. Inline fileSystem: {...} builders (indexing-test, prerendering, prerender-server, search-prerendered, definition-lookup, file-watcher-events, load-links-batching) — left alone, per the PR plan and the PR 2/3 precedent.

Per the stated strategy (Linear plan + reviewer guidance), this PR defaults everything to simple first and only escalates to realistic where the test code in the same file clearly needs a realistic-only file. CI verifies the rest.

Per-file decisions

File Setup style Fixture chosen Notes
atomic-endpoints-test.ts helper × 3 (implicit) simple uses Person + writes new cards
boxel-domain-availability-test.ts hand-rolled copySync fixtureDir('simple') no helper
card-dependencies-endpoint-test.ts helper × 2 (implicit) simple reads /person
card-endpoints-test.ts helper × 11 (implicit) + 3 inline SKIP simple for helper blocks uses hassan and person-1 — escalate to realistic if CI fails
card-source-endpoints-test.ts helper × 11 (implicit) simple for setup + fixtureDir('realistic') for the readFileSync of person-with-error.gts first GET block tests /person-with-error.gts; escalate that block to realistic if CI fails
claim-boxel-domain-test.ts hand-rolled copySync fixtureDir('simple') no helper
delete-boxel-claimed-domain-test.ts hand-rolled copySync fixtureDir('simple') no helper
get-boxel-claimed-domain-test.ts hand-rolled copySync fixtureDir('simple') no helper
module-cache-race-test.ts helper × 2 (implicit) blank synthesizes its own card sources
openrouter-passthrough-test.ts hand-rolled copySync × 2 fixtureDir('simple') no helper
publish-unpublish-realm-test.ts helper + copySync × 2 simple for helper, fixtureDir('simple') for the copySyncs
realm-auth-test.ts helper × 1 (implicit) blank pure auth, no card refs
realm-endpoints-test.ts helper × 3 (implicit) + copySync + inline demoFileSystem simple for the three helpers, fixtureDir('simple') for the copySync; fixtureDir('realistic') for the demoFileSystem reads (realm.json is realistic-only) inline demoFileSystem itself stays inline
request-forward-test.ts hand-rolled copySync × 2 fixtureDir('simple') no helper
types-endpoint-test.ts helper + copySync simple for helper, fixtureDir('simple') for the copySync

Inline-fileSystem files left alone: definition-lookup-test.ts, file-watcher-events-test.ts, indexing-test.ts, load-links-batching-test.ts, prerender-server-test.ts, prerendering-test.ts, search-prerendered-test.ts.

After this PR lands, the only remaining tests/cards references in packages/realm-server/tests/ will be inside helpers/index.ts (the fixtureDir('realistic') resolver itself). The final PR can git mv tests/cards tests/fixtures/realistic without grepping for stragglers.

Test plan

  • CI runs every migrated file against the named fixture and they pass.
  • If a simple-defaulted file fails because the test code reaches for a realistic-only card (e.g. hassan, person-with-error.gts), escalate just that block to realistic and re-run.
  • CI runs the unmigrated inline-fileSystem files unchanged.

🤖 Generated with Claude Code

lukemelia and others added 5 commits May 12, 2026 17:35
Third slice of the CS-10009 plan. Stacked on PR 2 (realm-endpoints).

The bulk of these go through the shared `setupServerEndpointsTest`
helper. Extended it to accept an optional `fixture` parameter and
defaulted to `'blank'` — server-level endpoint tests (bot-commands,
webhooks, realm lifecycle, stripe sessions, etc.) almost universally
manage server state without inspecting the testRealm's card content,
so blank is the right default and individual consumers override only
when they truly need more.

Two consumers need realistic:
- screenshot-card-endpoint-test references `Person/fadhlan` from
  tests/cards/ — set `{ fixture: 'realistic' }` via the helper.
- index-responses-test's published-realm module asserts on a
  `data-test-home-card` substring, which only exists in
  tests/cards/home.gts — `fixture: 'realistic'` on its direct
  setupPermissionedRealmCached call.

Direct setupPermissionedRealmCached calls migrated:
- authentication-test: `fileSystem: {}` → `fixture: 'blank'`
- stripe-session-test: `fileSystem: {}` → `fixture: 'blank'`
- stripe-webhook-test: implicit default → `fixture: 'blank'`
- realm-lifecycle-test ("realm mounted at server origin" module):
  implicit default → `fixture: 'blank'`

Skipped (callers passing inline `fileSystem` per the plan):
federated-types-test, info-test, search-prerendered-test, search-test,
index-responses-test's first module, queue-status-test (already
migrated in PR 1).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI surfaced this: `_catalog-realms` returns the realm's `name` in
the response, and the test asserts it equals "Test Realm". That
value comes from tests/cards/realm.json's RealmConfig instance
(`cardInfo.name`), so the test needs `realistic`. Same gotcha PR 2
hit with info-test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
That change sneaked into the prior commit from a local benchmarking
session. Pinning to 4G is a regression on CI runners where the
default `--tmpfs` allocation is much larger; revert to the original
behavior. The MATRIX_REGISTRATION_SHARED_SECRET env-override in
measure-test-file.sh stays — that one is purely additive (default
unchanged at "fake") and lets local benchmarking against a real
synapse pass through the right secret.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* `ServerEndpointsTestOptions.fixture` now imports `RealmFixtureName`
  from the shared `tests/helpers` rather than re-declaring the literal
  union — fixture-name additions land in one place and can't drift.
* `user-and-catalog-test.ts`: drop the stale "Same pattern as info-test
  in PR 2 (#4790)" reference. The constraint above it (realistic-only)
  already states the why; PR-number links rot post-merge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fourth slice. Migrates every realm-server test file at the
`packages/realm-server/tests/` root level off the implicit
"copy the whole cards/ kitchen sink" default and onto an explicit
fixture choice (mostly `simple`, two on `blank`, none yet on
`realistic` — per the "default to simple first; escalate from CI"
strategy). After this, the only callers left on the implicit default
are the seven inline-`fileSystem` builders, which the PR plan
explicitly leaves alone.

Per-file decisions:

  Helper consumers (setupPermissionedRealmCached / *sCached):
    atomic-endpoints-test.ts             → simple (3 blocks)
    card-dependencies-endpoint-test.ts   → simple (2 blocks)
    card-endpoints-test.ts               → simple (11 implicit
                                           blocks; 3 inline blocks
                                           SKIP)
    card-source-endpoints-test.ts        → simple (11 blocks). The
                                           first GET block also tests
                                           /person-with-error.gts, a
                                           realistic-only file; if CI
                                           fails there, escalate that
                                           one block to realistic.
    module-cache-race-test.ts            → blank (2 blocks; this file
                                           synthesizes its own card
                                           sources)
    publish-unpublish-realm-test.ts      → simple
    realm-auth-test.ts                   → blank (no card content)
    realm-endpoints-test.ts              → simple (3 blocks)
    types-endpoint-test.ts               → simple

  Hand-rolled `copySync(tests/cards, …)` (no helper to receive a
  `fixture:` arg) — swap the literal path to `fixtureDir('simple')`
  so the final-PR rename of `tests/cards` → `tests/fixtures/realistic`
  is a pure `git mv`:
    boxel-domain-availability-test.ts
    claim-boxel-domain-test.ts
    delete-boxel-claimed-domain-test.ts
    get-boxel-claimed-domain-test.ts
    openrouter-passthrough-test.ts
    request-forward-test.ts
    publish-unpublish-realm-test.ts (also has helper above)
    realm-endpoints-test.ts (also has helpers above)
    types-endpoint-test.ts (also has helper above)

  Inline `readFileSync`/`readJSONSync` from `tests/cards` (path
  needs to stay valid after the final-PR rename):
    card-source-endpoints-test.ts  — person-with-error.gts reference
                                     → fixtureDir('realistic')
    realm-endpoints-test.ts        — demoFileSystem reads realm.json
                                     (realistic-only) and friends
                                     → fixtureDir('realistic')

After PR 4 lands, the only remaining `__dirname`/`tests/cards`
references in this package will be inside `tests/helpers/index.ts`
itself (the `fixtureDir('realistic')` resolver) — the final PR can
rename the directory without grepping for stragglers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fourth slice of CS-10009, migrating the remaining root-level packages/realm-server/tests/ files from implicit tests/cards references to the explicit fixture option or fixtureDir(...) helper. This is a mechanical refactor that keeps behavior unchanged while preparing for renaming tests/cardstests/fixtures/realistic in a final PR.

Changes:

  • Add explicit fixture: 'simple' | 'blank' to setupPermissionedRealmCached call sites.
  • Replace hand-rolled copySync(join(__dirname, 'cards'), …) with copySync(fixtureDir('simple'), …).
  • Switch realm-endpoints-test.ts's demoFileSystem and card-source-endpoints-test.ts's person-with-error.gts read to fixtureDir('realistic').

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
atomic-endpoints-test.ts Adds fixture: 'simple' to 3 helper calls
boxel-domain-availability-test.ts Swaps copySync source to fixtureDir('simple')
card-dependencies-endpoint-test.ts Adds fixture: 'simple' to 2 helper calls
card-endpoints-test.ts Adds fixture: 'simple' to 11 helper calls
card-source-endpoints-test.ts Adds fixture: 'simple' to helper calls; reads person-with-error.gts via fixtureDir('realistic')
claim-boxel-domain-test.ts Swaps copySync source to fixtureDir('simple')
delete-boxel-claimed-domain-test.ts Swaps copySync source to fixtureDir('simple')
get-boxel-claimed-domain-test.ts Swaps copySync source to fixtureDir('simple')
module-cache-race-test.ts Adds fixture: 'blank' to 2 helper calls (synthesizes own cards)
openrouter-passthrough-test.ts Swaps 2 copySync sources to fixtureDir('simple')
publish-unpublish-realm-test.ts Adds fixture: 'simple' to helper; swaps 2 copySync sources
realm-auth-test.ts Adds fixture: 'blank' (pure auth)
realm-endpoints-test.ts Adds fixture: 'simple' to helpers; swaps copySync to simple; demoFileSystem reads from fixtureDir('realistic')
request-forward-test.ts Swaps 2 copySync sources to fixtureDir('simple')
types-endpoint-test.ts Adds fixture: 'simple' to helper; swaps copySync source

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   1h 50m 0s ⏱️ + 1m 15s
2 658 tests ±0  2 643 ✅ ±0  15 💤 ±0  0 ❌ ±0 
2 677 runs  ±0  2 662 ✅ ±0  15 💤 ±0  0 ❌ ±0 

Results for commit 9df953b. ± Comparison against earlier commit 0f5c797.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   9m 44s ⏱️ +7s
1 328 tests ±0  1 328 ✅ +22  0 💤 ±0  0 ❌  - 22 
1 407 runs  ±0  1 407 ✅ +27  0 💤 ±0  0 ❌  - 27 

Results for commit 9df953b. ± Comparison against earlier commit 0f5c797.

CI on PR #4819 surfaced blocks whose assertions reach for realistic-only
content. Per the PR plan ("escalate just that block to realistic if CI
fails"), the following blocks now use the realistic fixture:

- card-dependencies-endpoint-test.ts: both blocks (endpoint requests
  /person instance, simple only has person-1)
- card-endpoints-test.ts: public-readable GET, published realm, public-
  writable GET, POST public-writable, PATCH public-writable (assertions
  on realmInfo.name = "Test Realm", error-card tests, and lid tests)
- card-source-endpoints-test.ts: public-readable GET (compares against
  cardSrc test-fixture; needs person-with-error.gts, hello.test.gts),
  DELETE public-writable, DELETE permissioned (delete /unused-card.gts)
- realm-endpoints-test.ts: main module + origin-mounted realm module
  (references /hassan, /nested/example.js, markdown card refs, and the
  realistic directory listing)
- types-endpoint-test.ts: /_types summary expects realistic card-type set

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lukemelia lukemelia changed the base branch from cs-10009-migrate-server-endpoints to main May 14, 2026 04:16
@lukemelia lukemelia requested review from a team and backspace May 14, 2026 04:16
@lukemelia lukemelia merged commit 191701c into main May 14, 2026
67 checks passed
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.

3 participants