From 925e68faed26713fc740e5cfec5d7a52b979f1ee Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Tue, 12 May 2026 13:20:21 -0400 Subject: [PATCH 1/2] CS-10009 PR 2: migrate realm-endpoints tests to explicit fixture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One PR per directory per the CS-10009 plan; this one covers packages/realm-server/tests/realm-endpoints/. Per-file migration: - cancel-indexing-job-test: fixture: 'blank' (job-queue ops only). - dependencies-test: fixture: 'blank' (writes its own file). - directory-test: fixture: 'realistic' (asserts on tests/cards/dir/ contents); the redundant `dirSync + copySync(cards)` hook ahead of setupPermissionedRealmCached was dead code (the local `dir` was immediately overwritten by args.dir in onRealmSetup) — removed. - info-test: fixture: 'blank' on all 4 modules; same dead-copySync removal as directory-test. - lint-test: fixture: 'blank' (POSTs source bodies, no realm reads). - mtimes-test: fixture: 'blank' (compares mtimes(testRealmPath) round-trip; works on any fixture). - permissions-test: fixture: 'blank' (was already fileSystem: {}); same dead-copySync removal. - search-test: fixture: 'simple' on all 4 implicit-default modules (they all query Person/Mango which the simple fixture has). The three modules that pass their own `fileSystem` inline are untouched. - user-test: fixture: 'blank' on both modules (GET and POST _user endpoints don't read realm card content); same dead-copySync removal. Skipped (per Linear plan: callers that pass their own `fileSystem` inline are left alone): invalidate-urls-test (already simple from PR 1), markdown-test, publishability-test, reindex-test. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../realm-endpoints/cancel-indexing-job-test.ts | 1 + .../tests/realm-endpoints/dependencies-test.ts | 1 + .../tests/realm-endpoints/directory-test.ts | 16 ++++------------ .../tests/realm-endpoints/info-test.ts | 16 +++++----------- .../tests/realm-endpoints/lint-test.ts | 1 + .../tests/realm-endpoints/mtimes-test.ts | 1 + .../tests/realm-endpoints/permissions-test.ts | 16 +++------------- .../tests/realm-endpoints/search-test.ts | 4 ++++ .../tests/realm-endpoints/user-test.ts | 16 +++------------- 9 files changed, 23 insertions(+), 49 deletions(-) diff --git a/packages/realm-server/tests/realm-endpoints/cancel-indexing-job-test.ts b/packages/realm-server/tests/realm-endpoints/cancel-indexing-job-test.ts index e85d27f5810..f500e5ce3b9 100644 --- a/packages/realm-server/tests/realm-endpoints/cancel-indexing-job-test.ts +++ b/packages/realm-server/tests/realm-endpoints/cancel-indexing-job-test.ts @@ -36,6 +36,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { } setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { writer: ['read', 'write'], reader: ['read'], diff --git a/packages/realm-server/tests/realm-endpoints/dependencies-test.ts b/packages/realm-server/tests/realm-endpoints/dependencies-test.ts index 7150953624d..e8616d00c9c 100644 --- a/packages/realm-server/tests/realm-endpoints/dependencies-test.ts +++ b/packages/realm-server/tests/realm-endpoints/dependencies-test.ts @@ -29,6 +29,7 @@ module(`realm-endpoints/${basename(__filename)}`, function (hooks) { }); setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { '*': ['read'], }, diff --git a/packages/realm-server/tests/realm-endpoints/directory-test.ts b/packages/realm-server/tests/realm-endpoints/directory-test.ts index 49c789728ae..70bea72f2ff 100644 --- a/packages/realm-server/tests/realm-endpoints/directory-test.ts +++ b/packages/realm-server/tests/realm-endpoints/directory-test.ts @@ -1,8 +1,6 @@ import { module, test } from 'qunit'; import type { Test, SuperTest } from 'supertest'; -import { join, basename } from 'path'; -import { dirSync, type DirResult } from 'tmp'; -import { copySync } from 'fs-extra'; +import { basename } from 'path'; import type { Realm } from '@cardstack/runtime-common'; import { setupPermissionedRealmCached, @@ -12,28 +10,21 @@ import { import '@cardstack/runtime-common/helpers/code-equality-assertion'; module(`realm-endpoints/${basename(__filename)}`, function () { - module('Realm-specific Endpoints | GET directory path', function (hooks) { + module('Realm-specific Endpoints | GET directory path', function () { let testRealm: Realm; let request: SuperTest; - let dir: DirResult; - - hooks.beforeEach(async function () { - dir = dirSync(); - copySync(join(__dirname, '..', 'cards'), dir.name); - }); function onRealmSetup(args: { testRealm: Realm; request: SuperTest; - dir: DirResult; }) { testRealm = args.testRealm; request = args.request; - dir = args.dir; } module('public readable realm', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'realistic', permissions: { '*': ['read'], }, @@ -102,6 +93,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('permissioned realm', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'realistic', permissions: { john: ['read'], '@node-test_realm:localhost': ['read', 'realm-owner'], diff --git a/packages/realm-server/tests/realm-endpoints/info-test.ts b/packages/realm-server/tests/realm-endpoints/info-test.ts index 841a52b2f70..31f3590637c 100644 --- a/packages/realm-server/tests/realm-endpoints/info-test.ts +++ b/packages/realm-server/tests/realm-endpoints/info-test.ts @@ -1,9 +1,7 @@ import { module, test } from 'qunit'; import type { Test, SuperTest } from 'supertest'; -import { join, basename } from 'path'; +import { basename } from 'path'; import type { Server } from 'http'; -import { dirSync, type DirResult } from 'tmp'; -import { copySync } from 'fs-extra'; import type { Realm } from '@cardstack/runtime-common'; import { setupPermissionedRealmCached, @@ -21,25 +19,17 @@ module(`realm-endpoints/${basename(__filename)}`, function () { let testRealm: Realm; let testRealmHttpServer: Server; let request: SuperTest; - let dir: DirResult; function onRealmSetup(args: { testRealm: Realm; testRealmHttpServer: Server; request: SuperTest; - dir: DirResult; }) { testRealm = args.testRealm; testRealmHttpServer = args.testRealmHttpServer; request = args.request; - dir = args.dir; } - hooks.beforeEach(async function () { - dir = dirSync(); - copySync(join(__dirname, '..', 'cards'), dir.name); - }); - hooks.afterEach(async function () { await closeServer(testRealmHttpServer); resetCatalogRealms(); @@ -47,6 +37,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('public readable realm', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { '*': ['read'], }, @@ -91,6 +82,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('permissioned realm', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { '@node-test_realm:localhost': ['read', 'realm-owner'], }, @@ -163,6 +155,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { 'shared realm because there is `users` permission', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { users: ['read'], '@node-test_realm:localhost': ['read', 'realm-owner'], @@ -204,6 +197,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('shared realm because there are multiple users', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { bob: ['read'], jane: ['read'], diff --git a/packages/realm-server/tests/realm-endpoints/lint-test.ts b/packages/realm-server/tests/realm-endpoints/lint-test.ts index 6a099a9ef26..a0934b8d7e9 100644 --- a/packages/realm-server/tests/realm-endpoints/lint-test.ts +++ b/packages/realm-server/tests/realm-endpoints/lint-test.ts @@ -26,6 +26,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { } setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { john: ['read', 'write'], '@node-test_realm:localhost': ['read', 'realm-owner'], diff --git a/packages/realm-server/tests/realm-endpoints/mtimes-test.ts b/packages/realm-server/tests/realm-endpoints/mtimes-test.ts index 80feb92620e..7035151d31b 100644 --- a/packages/realm-server/tests/realm-endpoints/mtimes-test.ts +++ b/packages/realm-server/tests/realm-endpoints/mtimes-test.ts @@ -28,6 +28,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { } setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { mary: ['read'], '@node-test_realm:localhost': ['read', 'realm-owner'], diff --git a/packages/realm-server/tests/realm-endpoints/permissions-test.ts b/packages/realm-server/tests/realm-endpoints/permissions-test.ts index a034b0a0c6e..0de2589888e 100644 --- a/packages/realm-server/tests/realm-endpoints/permissions-test.ts +++ b/packages/realm-server/tests/realm-endpoints/permissions-test.ts @@ -1,8 +1,6 @@ import { module, test } from 'qunit'; import type { Test, SuperTest } from 'supertest'; -import { join, basename } from 'path'; -import { dirSync, type DirResult } from 'tmp'; -import { copySync } from 'fs-extra'; +import { basename } from 'path'; import type { Realm } from '@cardstack/runtime-common'; import { fetchRealmPermissions } from '@cardstack/runtime-common'; import { @@ -15,32 +13,24 @@ import '@cardstack/runtime-common/helpers/code-equality-assertion'; import type { PgAdapter } from '@cardstack/postgres'; module(`realm-endpoints/${basename(__filename)}`, function () { - module('Realm-specific Endpoints | _permissions', function (hooks) { + module('Realm-specific Endpoints | _permissions', function () { let testRealm: Realm; let request: SuperTest; - let dir: DirResult; let dbAdapter: PgAdapter; function onRealmSetup(args: { testRealm: Realm; request: SuperTest; dbAdapter: PgAdapter; - dir: DirResult; }) { testRealm = args.testRealm; request = args.request; dbAdapter = args.dbAdapter; - dir = args.dir; } - hooks.beforeEach(async function () { - dir = dirSync(); - copySync(join(__dirname, '..', 'cards'), dir.name); - }); - module('permissions requests', function (hooks) { setupPermissionedRealmCached(hooks, { - fileSystem: {}, + fixture: 'blank', permissions: { mary: ['read', 'write', 'realm-owner'], bob: ['read', 'write'], diff --git a/packages/realm-server/tests/realm-endpoints/search-test.ts b/packages/realm-server/tests/realm-endpoints/search-test.ts index 88951a82ae5..6be9eca1542 100644 --- a/packages/realm-server/tests/realm-endpoints/search-test.ts +++ b/packages/realm-server/tests/realm-endpoints/search-test.ts @@ -59,6 +59,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('public readable realm', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'simple', permissions: { '*': ['read'], }, @@ -753,6 +754,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('public readable realm', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'simple', permissions: { '*': ['read'], }, @@ -829,6 +831,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('permissioned realm', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'simple', permissions: { john: ['read'], '@node-test_realm:localhost': ['read', 'realm-owner'], @@ -886,6 +889,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('search query validation', function (hooks) { setupPermissionedRealmCached(hooks, { + fixture: 'simple', permissions: { '*': ['read'], '@node-test_realm:localhost': ['read', 'realm-owner'], diff --git a/packages/realm-server/tests/realm-endpoints/user-test.ts b/packages/realm-server/tests/realm-endpoints/user-test.ts index 437659f98fd..8a22fa869ec 100644 --- a/packages/realm-server/tests/realm-endpoints/user-test.ts +++ b/packages/realm-server/tests/realm-endpoints/user-test.ts @@ -1,9 +1,7 @@ import { module, test } from 'qunit'; import type { Test, SuperTest } from 'supertest'; -import { join, basename } from 'path'; +import { basename } from 'path'; import type { Server } from 'http'; -import { dirSync, type DirResult } from 'tmp'; -import { copySync } from 'fs-extra'; import type { Realm } from '@cardstack/runtime-common'; import { setupPermissionedRealmCached, @@ -28,7 +26,6 @@ module(`realm-endpoints/${basename(__filename)}`, function () { let testRealm: Realm; let testRealmHttpServer: Server; let request: SuperTest; - let dir: DirResult; let dbAdapter: PgAdapter; let originalLowCreditThreshold: string | undefined; @@ -37,20 +34,16 @@ module(`realm-endpoints/${basename(__filename)}`, function () { testRealmHttpServer: Server; request: SuperTest; dbAdapter: PgAdapter; - dir: DirResult; }) { testRealm = args.testRealm; testRealmHttpServer = args.testRealmHttpServer; request = args.request; dbAdapter = args.dbAdapter; - dir = args.dir; } hooks.beforeEach(async function () { originalLowCreditThreshold = process.env.LOW_CREDIT_THRESHOLD; process.env.LOW_CREDIT_THRESHOLD = '2000'; - dir = dirSync(); - copySync(join(__dirname, '..', 'cards'), dir.name); }); hooks.afterEach(async function () { @@ -64,6 +57,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { }); setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { john: ['read', 'write'], '@node-test_realm:localhost': ['read', 'realm-owner'], @@ -450,7 +444,6 @@ module(`realm-endpoints/${basename(__filename)}`, function () { let testRealm: Realm; let testRealmHttpServer: Server; let request: SuperTest; - let dir: DirResult; let dbAdapter: PgAdapter; let originalLowCreditThreshold: string | undefined; @@ -459,20 +452,16 @@ module(`realm-endpoints/${basename(__filename)}`, function () { testRealmHttpServer: Server; request: SuperTest; dbAdapter: PgAdapter; - dir: DirResult; }) { testRealm = args.testRealm; testRealmHttpServer = args.testRealmHttpServer; request = args.request; dbAdapter = args.dbAdapter; - dir = args.dir; } hooks.beforeEach(async function () { originalLowCreditThreshold = process.env.LOW_CREDIT_THRESHOLD; process.env.LOW_CREDIT_THRESHOLD = '2000'; - dir = dirSync(); - copySync(join(__dirname, '..', 'cards'), dir.name); }); hooks.afterEach(async function () { @@ -486,6 +475,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { }); setupPermissionedRealmCached(hooks, { + fixture: 'blank', permissions: { john: ['read', 'write'], '@node-test_realm:localhost': ['read', 'realm-owner'], From 20868f4f5db358b72a610719886fb2abc61d6b7b Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Tue, 12 May 2026 16:41:06 -0400 Subject: [PATCH 2/2] Revert info-test + search-test public-readable to realistic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI surfaced two miscategorizations from the initial survey: info-test depends on `testRealmInfo.name === 'Test Realm'`, which comes from the `realm.json` RealmConfig card instance in tests/cards/, NOT from `.realm.json`. Neither `blank` nor `simple` ships that instance, so the realm boots with the "Unnamed Workspace" fallback and every 200-with-permission assertion fails the deepEqual. All 4 info-test modules now use `realistic`. search-test's `QUERY request (public realm) > public readable realm` module exercises pagination (expects 3 Person results), file-meta filtering across multiple FileDefs, and sparse-fieldset backward-compat — all of which need the kitchen-sink content. Reverted just that one sub-module to `realistic`; the other three search-test modules only ever query for Mango and stay on `simple`. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/realm-server/tests/realm-endpoints/info-test.ts | 8 ++++---- .../realm-server/tests/realm-endpoints/search-test.ts | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/realm-server/tests/realm-endpoints/info-test.ts b/packages/realm-server/tests/realm-endpoints/info-test.ts index 31f3590637c..fee220e9e2d 100644 --- a/packages/realm-server/tests/realm-endpoints/info-test.ts +++ b/packages/realm-server/tests/realm-endpoints/info-test.ts @@ -37,7 +37,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('public readable realm', function (hooks) { setupPermissionedRealmCached(hooks, { - fixture: 'blank', + fixture: 'realistic', permissions: { '*': ['read'], }, @@ -82,7 +82,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('permissioned realm', function (hooks) { setupPermissionedRealmCached(hooks, { - fixture: 'blank', + fixture: 'realistic', permissions: { '@node-test_realm:localhost': ['read', 'realm-owner'], }, @@ -155,7 +155,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { 'shared realm because there is `users` permission', function (hooks) { setupPermissionedRealmCached(hooks, { - fixture: 'blank', + fixture: 'realistic', permissions: { users: ['read'], '@node-test_realm:localhost': ['read', 'realm-owner'], @@ -197,7 +197,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () { module('shared realm because there are multiple users', function (hooks) { setupPermissionedRealmCached(hooks, { - fixture: 'blank', + fixture: 'realistic', permissions: { bob: ['read'], jane: ['read'], diff --git a/packages/realm-server/tests/realm-endpoints/search-test.ts b/packages/realm-server/tests/realm-endpoints/search-test.ts index 6be9eca1542..c5ec4822dd1 100644 --- a/packages/realm-server/tests/realm-endpoints/search-test.ts +++ b/packages/realm-server/tests/realm-endpoints/search-test.ts @@ -58,8 +58,13 @@ module(`realm-endpoints/${basename(__filename)}`, function () { let query = () => buildPersonQuery('Mango'); module('public readable realm', function (hooks) { + // Uses `realistic` because tests in this module depend on + // multiple Person instances (pagination), FileDef instances + // beyond person.gts (file-meta queries), and the kitchen-sink + // content variety (sparse-fieldsets backward-compat). Sibling + // modules below only ever query for Mango and stay on `simple`. setupPermissionedRealmCached(hooks, { - fixture: 'simple', + fixture: 'realistic', permissions: { '*': ['read'], },