CS-10009 PR 4: migrate root tests/ to explicit fixture#4819
Conversation
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>
There was a problem hiding this comment.
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/cards → tests/fixtures/realistic in a final PR.
Changes:
- Add explicit
fixture: 'simple' | 'blank'tosetupPermissionedRealmCachedcall sites. - Replace hand-rolled
copySync(join(__dirname, 'cards'), …)withcopySync(fixtureDir('simple'), …). - Switch
realm-endpoints-test.ts'sdemoFileSystemandcard-source-endpoints-test.ts'sperson-with-error.gtsread tofixtureDir('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.
Host Test Results 1 files ±0 1 suites ±0 1h 50m 0s ⏱️ + 1m 15s Results for commit 9df953b. ± Comparison against earlier commit 0f5c797. Realm Server Test Results 1 files ±0 1 suites ±0 9m 44s ⏱️ +7s 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>
Fourth slice of CS-10009. Stacked on #4798 — review/merge that one first; this PR's base will retarget to
mainonce it lands.Approach
The remaining realm-server test files live at the
packages/realm-server/tests/root. They split into three groups:setupPermissionedRealmCached/setupPermissionedRealmsCachedwith nofileSystem(implicit-default =realisticfor the duration of the migration). These get an explicitfixture: …option.copySync(tests/cards, …)consumers that build their realm directly viarunTestRealmServerand don't go through the helper. There's nofixture:option to set — we instead swap the literaljoin(__dirname, 'cards')forfixtureDir('simple'), which the final PR can flip to'realistic'once the directory is renamed.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
simplefirst and only escalates torealisticwhere the test code in the same file clearly needs a realistic-only file. CI verifies the rest.Per-file decisions
atomic-endpoints-test.tsboxel-domain-availability-test.tsfixtureDir('simple')card-dependencies-endpoint-test.ts/personcard-endpoints-test.tshassanandperson-1— escalate to realistic if CI failscard-source-endpoints-test.tsfixtureDir('realistic')for thereadFileSyncofperson-with-error.gts/person-with-error.gts; escalate that block to realistic if CI failsclaim-boxel-domain-test.tsfixtureDir('simple')delete-boxel-claimed-domain-test.tsfixtureDir('simple')get-boxel-claimed-domain-test.tsfixtureDir('simple')module-cache-race-test.tsopenrouter-passthrough-test.tsfixtureDir('simple')publish-unpublish-realm-test.tsfixtureDir('simple')for the copySyncsrealm-auth-test.tsrealm-endpoints-test.tsdemoFileSystemfixtureDir('simple')for the copySync;fixtureDir('realistic')for the demoFileSystem reads (realm.jsonis realistic-only)request-forward-test.tsfixtureDir('simple')types-endpoint-test.tsfixtureDir('simple')for the copySyncInline-
fileSystemfiles 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/cardsreferences inpackages/realm-server/tests/will be insidehelpers/index.ts(thefixtureDir('realistic')resolver itself). The final PR cangit mv tests/cards tests/fixtures/realisticwithout grepping for stragglers.Test plan
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 torealisticand re-run.fileSystemfiles unchanged.🤖 Generated with Claude Code