From ed2450845098118f21971e01732df469e96feaf2 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Fri, 12 Dec 2025 18:46:01 +0000 Subject: [PATCH 01/17] Need to rerun this for tests that import from the base realm --- packages/host/tests/helpers/base-realm.ts | 6 ---- packages/host/tests/helpers/snapshot-realm.ts | 29 +++++++++---------- .../integration/commands/patch-code-test.gts | 8 ++--- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/packages/host/tests/helpers/base-realm.ts b/packages/host/tests/helpers/base-realm.ts index 66eac42178..e084a79ba1 100644 --- a/packages/host/tests/helpers/base-realm.ts +++ b/packages/host/tests/helpers/base-realm.ts @@ -105,12 +105,8 @@ let enumField: (typeof EnumModule)['default']; let enumOptions: (typeof EnumModule)['enumOptions']; let enumValues: (typeof EnumModule)['enumValues']; let enumConfig: (typeof EnumModule)['enumConfig']; -let initialised = false; async function initialize() { - if (initialised) { - return; - } let loader = getService('loader-service').loader; StringField = ( @@ -230,8 +226,6 @@ async function initialize() { enumOptions = enumModule.enumOptions; enumValues = enumModule.enumValues; enumConfig = enumModule.enumConfig; - - initialised = true; } export async function setupBaseRealm(hooks: NestedHooks) { diff --git a/packages/host/tests/helpers/snapshot-realm.ts b/packages/host/tests/helpers/snapshot-realm.ts index 745934d7eb..eb5473a6d5 100644 --- a/packages/host/tests/helpers/snapshot-realm.ts +++ b/packages/host/tests/helpers/snapshot-realm.ts @@ -12,11 +12,10 @@ import { captureDbSnapshot, restoreDbSnapshot, deleteSnapshot, - createTimingLogger, setupRendering, } from '.'; -import { setupBaseRealm } from '../helpers/base-realm'; +import { setupBaseRealm } from './base-realm'; export interface SnapshotBuildContext { isInitialBuild: boolean; @@ -49,16 +48,22 @@ export function setupSnapshotRealm( let cache: SnapshotCache | undefined; let latestState: T | undefined; - setupBaseRealm(hooks); hooks.beforeEach(async function () { setupRendering(options.acceptanceTest!!); }); + hooks.beforeEach(async function () { + let loaderService = getService('loader-service'); + if (cache) { + loaderService.loader = Loader.cloneLoader(cache.loaderSnapshot, { + includeEvaluatedModules: true, + }); + } + }); + setupBaseRealm(hooks); hooks.beforeEach(async function () { - let timer = createTimingLogger('setupSnapshotRealm'); setupUserSubscription(); setupAuthEndpoints(options.realmPermissions); - timer.step('setupAuthEndpoints'); let loaderService = getService('loader-service'); @@ -67,31 +72,25 @@ export function setupSnapshotRealm( if (options.mockMatrixUtils) { options.mockMatrixUtils.restoreServerState(cache.matrixState); } - loaderService.loader = Loader.cloneLoader(cache.loaderSnapshot, { - includeEvaluatedModules: true, - }); - timer.step('restored from snapshot'); } latestState = await options.build({ isInitialBuild: !cache, loader: loaderService.loader, mockMatrixUtils: options.mockMatrixUtils, }); - timer.step('built latest state'); if (!cache) { + let clonedLoader = Loader.cloneLoader(loaderService.loader, { + includeEvaluatedModules: true, + }); cache = { - loaderSnapshot: Loader.cloneLoader(loaderService.loader, { - includeEvaluatedModules: true, - }), + loaderSnapshot: clonedLoader, dbSnapshot: await captureDbSnapshot(), matrixState: options.mockMatrixUtils ? options.mockMatrixUtils.captureServerState() : undefined, }; - timer.step('captured snapshot'); } - timer.finish(); }); hooks.after(async function () { diff --git a/packages/host/tests/integration/commands/patch-code-test.gts b/packages/host/tests/integration/commands/patch-code-test.gts index 7fa6894458..4c98ef54e6 100644 --- a/packages/host/tests/integration/commands/patch-code-test.gts +++ b/packages/host/tests/integration/commands/patch-code-test.gts @@ -26,6 +26,10 @@ import { setupMockMatrix } from '../../helpers/mock-matrix'; import { setupRenderingTest } from '../../helpers/setup'; module('Integration | commands | patch-code', function (hooks) { + const testFileName = 'task.gts'; + const fileUrl = `${testRealmURL}${testFileName}`; + let adapter: any; + setupRenderingTest(hooks); setupLocalIndexing(hooks); @@ -61,10 +65,6 @@ export class Task extends CardDef { }, }); - const testFileName = 'task.gts'; - const fileUrl = `${testRealmURL}${testFileName}`; - let adapter: any; - hooks.beforeEach(function () { ({ adapter } = snapshot.get()); adapter.lintStub = async ( From b2ed369ec02b141510d7f3c0604a2d955e112153 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Fri, 12 Dec 2025 18:49:43 +0000 Subject: [PATCH 02/17] Optional base realm setup, not needed for all tests and costs time --- packages/host/tests/helpers/snapshot-realm.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/host/tests/helpers/snapshot-realm.ts b/packages/host/tests/helpers/snapshot-realm.ts index eb5473a6d5..8f0abfaeab 100644 --- a/packages/host/tests/helpers/snapshot-realm.ts +++ b/packages/host/tests/helpers/snapshot-realm.ts @@ -37,6 +37,7 @@ export interface SnapshotRealmHandle { interface SetupSnapshotRealmOptions { build: (context: SnapshotBuildContext) => Promise; mockMatrixUtils: MockUtils; + setupBaseRealm?: boolean; // TODO: default to false, allow opt-in realmPermissions?: Record; acceptanceTest?: boolean; } @@ -59,7 +60,9 @@ export function setupSnapshotRealm( }); } }); - setupBaseRealm(hooks); + if (options.setupBaseRealm !== false) { + setupBaseRealm(hooks); + } hooks.beforeEach(async function () { setupUserSubscription(); From 7f9c2c46b21e612dc9a7e1c967e39f9bed99cc99 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Fri, 12 Dec 2025 21:13:13 +0000 Subject: [PATCH 03/17] Fix up some tests --- .../commands/preview-format-test.gts | 4 +- .../commands/search-command-test.gts | 63 ++++++++++--------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/packages/host/tests/integration/commands/preview-format-test.gts b/packages/host/tests/integration/commands/preview-format-test.gts index 462062e63e..bacfd30496 100644 --- a/packages/host/tests/integration/commands/preview-format-test.gts +++ b/packages/host/tests/integration/commands/preview-format-test.gts @@ -36,6 +36,7 @@ class StubRealmService extends RealmService { module('Integration | Command | preview-format', function (hooks) { setupRenderingTest(hooks); setupWindowMock(hooks); + setupLocalIndexing(hooks); const realmName = 'Preview Format Test Realm'; let loader: Loader; @@ -47,8 +48,6 @@ module('Integration | Command | preview-format', function (hooks) { let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; await setupIntegrationTestRealm({ mockMatrixUtils, contents: { @@ -103,7 +102,6 @@ module('Integration | Command | preview-format', function (hooks) { ({ loader, command } = snapshot.get()); }); - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/commands/search-command-test.gts b/packages/host/tests/integration/commands/search-command-test.gts index f86ac9aa2c..4c3a47794c 100644 --- a/packages/host/tests/integration/commands/search-command-test.gts +++ b/packages/host/tests/integration/commands/search-command-test.gts @@ -20,6 +20,19 @@ import { import { setupMockMatrix } from '../../helpers/mock-matrix'; import { setupRenderingTest } from '../../helpers/setup'; +import { + StringField, + NumberField, + field, + contains, + CardDef, + Component, + FieldDef, + containsMany, + linksTo, + linksToMany, +} from '../../helpers/base-realm'; + module('Integration | commands | search', function (hooks) { setupRenderingTest(hooks); @@ -30,7 +43,10 @@ module('Integration | commands | search', function (hooks) { setupOnSave(hooks); setupCardLogs( hooks, - async () => await loader.import(`${baseRealm.url}card-api`), + async () => + await getService('loader-service').loader.import( + `${baseRealm.url}card-api`, + ), ); let mockMatrixUtils = setupMockMatrix(hooks, { @@ -41,23 +57,12 @@ module('Integration | commands | search', function (hooks) { let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - let cardApi: typeof import('https://cardstack.com/base/card-api'); - let string: typeof import('https://cardstack.com/base/string'); - - cardApi = await loader.import(`${baseRealm.url}card-api`); - string = await loader.import(`${baseRealm.url}string`); - - let { field, contains, CardDef } = cardApi; - let { default: StringField } = string; - - class Author extends CardDef { - static displayName = 'Author'; + class CustomAuthor extends CardDef { + static displayName = 'CustomAuthor'; @field firstName = contains(StringField); @field lastName = contains(StringField); @field title = contains(StringField, { - computeVia: function (this: Author) { + computeVia: function (this: CustomAuthor) { return [this.firstName, this.lastName].filter(Boolean).join(' '); }, }); @@ -65,9 +70,9 @@ module('Integration | commands | search', function (hooks) { await setupIntegrationTestRealm({ mockMatrixUtils, contents: { - 'author.gts': { Author }, - 'Author/r2.json': new Author({ firstName: 'R2-D2' }), - 'Author/mark.json': new Author({ + 'custom-author.gts': { CustomAuthor }, + 'CustomAuthor/r2.json': new CustomAuthor({ firstName: 'R2-D2' }), + 'CustomAuthor/mark.json': new CustomAuthor({ firstName: 'Mark', lastName: 'Jackson', }), @@ -75,14 +80,10 @@ module('Integration | commands | search', function (hooks) { }, loader, }); - return { loader }; + return {}; }, }); - hooks.beforeEach(function () { - ({ loader } = snapshot.get()); - }); - test('search for a title', async function (assert) { let commandService = getService('command-service'); let searchCommand = new SearchCardsByTypeAndTitleCommand( @@ -93,7 +94,10 @@ module('Integration | commands | search', function (hooks) { cardType: undefined, }); assert.strictEqual(result.cardIds.length, 1); - assert.strictEqual(result.cardIds[0], 'http://test-realm/test/Author/mark'); + assert.strictEqual( + result.cardIds[0], + 'http://test-realm/test/CustomAuthor/mark', + ); }); test('search for a card type', async function (assert) { @@ -102,13 +106,13 @@ module('Integration | commands | search', function (hooks) { commandService.commandContext, ); let result = await searchCommand.execute({ - cardType: 'Author', + cardType: 'CustomAuthor', title: undefined, }); assert.ok(result.cardIds.length > 0, 'Should return at least one result'); assert.ok( - result.cardIds.every((id) => id.includes('Author')), - 'All results should be Author cards', + result.cardIds.every((id) => id.includes('CustomAuthor')), + 'All results should be Custom Author cards', ); }); @@ -121,7 +125,10 @@ module('Integration | commands | search', function (hooks) { query: { filter: { eq: { firstName: 'R2-D2' }, - on: { module: 'http://test-realm/test/author', name: 'Author' }, + on: { + module: 'http://test-realm/test/custom-author', + name: 'CustomAuthor', + }, }, }, }); From 41e447562ee0be49f6dd585716f966c0fb03a777 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Fri, 12 Dec 2025 21:13:34 +0000 Subject: [PATCH 04/17] Error on card type --- .../host/tests/integration/commands/search-command-test.gts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/host/tests/integration/commands/search-command-test.gts b/packages/host/tests/integration/commands/search-command-test.gts index 4c3a47794c..b631d3cabc 100644 --- a/packages/host/tests/integration/commands/search-command-test.gts +++ b/packages/host/tests/integration/commands/search-command-test.gts @@ -133,6 +133,9 @@ module('Integration | commands | search', function (hooks) { }, }); assert.strictEqual(result.cardIds.length, 1); - assert.strictEqual(result.cardIds[0], 'http://test-realm/test/Author/r2'); + assert.strictEqual( + result.cardIds[0], + 'http://test-realm/test/CustomAuthor/r2', + ); }); }); From 694f42037029bd826f74520eca0f75de77a05adb Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Fri, 12 Dec 2025 21:14:56 +0000 Subject: [PATCH 05/17] Use local urls --- .../integration/commands/search-google-images-test.gts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/host/tests/integration/commands/search-google-images-test.gts b/packages/host/tests/integration/commands/search-google-images-test.gts index 48d20e800b..b9a810349b 100644 --- a/packages/host/tests/integration/commands/search-google-images-test.gts +++ b/packages/host/tests/integration/commands/search-google-images-test.gts @@ -207,17 +207,17 @@ module('Integration | commands | search-google-images', function (hooks) { ); assert.strictEqual( firstImage.imageUrl, - 'https://example.com/image1.jpg', + 'http://localhost:4200/i-do-not-exist/image1.jpg', 'Should have correct image URL', ); assert.strictEqual( firstImage.thumbnailUrl, - 'https://example.com/thumb1.jpg', + 'http://localhost:4200/i-do-not-exist/thumb1.jpg', 'Should have correct thumbnail URL', ); assert.strictEqual( firstImage.contextUrl, - 'https://example.com/page1', + 'http://localhost:4200/i-do-not-exist/page1', 'Should have correct context URL', ); assert.strictEqual(firstImage.width, 800, 'Should have correct width'); @@ -249,7 +249,7 @@ module('Integration | commands | search-google-images', function (hooks) { ); assert.strictEqual( firstImage.displayLink, - 'example.com', + 'localhost', 'Should have correct display link', ); assert.strictEqual( From 1b4570d5cfe6dcbebc10e4d6c3ae42e070aaa97e Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Fri, 12 Dec 2025 21:18:41 +0000 Subject: [PATCH 06/17] Start matrix --- .../commands/send-ai-assistant-message-test.gts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/host/tests/integration/commands/send-ai-assistant-message-test.gts b/packages/host/tests/integration/commands/send-ai-assistant-message-test.gts index a4680635ec..2bc0ce1af0 100644 --- a/packages/host/tests/integration/commands/send-ai-assistant-message-test.gts +++ b/packages/host/tests/integration/commands/send-ai-assistant-message-test.gts @@ -37,12 +37,11 @@ module('Integration | commands | send-ai-assistant-message', function (hooks) { let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', activeRealms: [testRealmURL], + autostart: true, }); let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; await setupIntegrationTestRealm({ mockMatrixUtils, contents: {}, @@ -58,10 +57,6 @@ module('Integration | commands | send-ai-assistant-message', function (hooks) { getOwner(this)!.register('service:realm', StubRealmService); }); - hooks.beforeEach(function () { - snapshot.get(); - }); - test('send an ai assistant message', async function (assert) { let roomId = createAndJoinRoom({ sender: '@testuser:localhost', From 7cab6308756e4c8ba781343a5aaebb1b128064e4 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Fri, 12 Dec 2025 21:42:07 +0000 Subject: [PATCH 07/17] Always setup local indexing --- .../tests/acceptance/ai-assistant-test.gts | 2 +- packages/host/tests/acceptance/basic-test.gts | 1 - .../tests/acceptance/catalog-app-test.gts | 4 +- .../tests/acceptance/code-patches-test.gts | 2 +- .../tests/acceptance/code-submode-test.ts | 714 +++++++++--------- .../code-submode/card-playground-test.gts | 4 +- .../code-submode/create-file-test.gts | 2 +- .../acceptance/code-submode/editor-test.ts | 2 +- .../code-submode/field-playground-test.gts | 7 +- .../acceptance/code-submode/file-tree-test.ts | 1 - .../acceptance/code-submode/inspector-test.ts | 2 +- .../code-submode/recent-files-test.ts | 1 - .../code-submode/schema-editor-test.ts | 2 +- .../acceptance/code-submode/spec-test.gts | 2 +- .../host/tests/acceptance/commands-test.gts | 2 +- .../host/tests/acceptance/host-mode-test.gts | 2 +- .../tests/acceptance/host-submode-test.gts | 2 +- .../interact-submode/create-file-test.gts | 2 +- .../operator-mode-acceptance-test.gts | 2 +- .../tests/acceptance/prerender-html-test.gts | 2 +- .../tests/acceptance/prerender-meta-test.gts | 2 +- .../acceptance/prerender-module-test.gts | 2 +- .../acceptance/real-catalog-app-test.gts | 2 +- .../tests/acceptance/site-config-test.gts | 2 +- .../host/tests/acceptance/theme-card-test.gts | 2 +- .../workspace-delete-multiple-test.gts | 2 +- .../tests/helpers/interact-submode-setup.gts | 286 +++---- packages/host/tests/helpers/snapshot-realm.ts | 13 + ...-field-to-card-definition-command-test.gts | 2 +- .../commands/check-correctness-test.gts | 2 +- .../commands/copy-and-edit-test.gts | 1 - .../integration/commands/copy-card-test.gts | 1 - .../integration/commands/copy-source-test.gts | 1 - .../integration/commands/create-spec-test.gts | 1 - .../generate-example-cards-one-shot-test.gts | 1 - .../commands/open-workspace-test.gts | 1 - .../integration/commands/patch-code-test.gts | 1 - .../commands/patch-fields-test.gts | 2 +- .../commands/patch-instance-test.gts | 1 - .../commands/preview-format-test.gts | 1 - .../read-card-for-ai-assistant-test.gts | 1 - .../read-file-for-ai-assistant-test.gts | 1 - .../integration/commands/read-source-test.gts | 1 - .../commands/read-text-file-test.gts | 1 - .../commands/search-command-test.gts | 1 - .../commands/search-google-images-test.gts | 1 - .../send-ai-assistant-message-test.gts | 1 - .../commands/send-request-via-proxy-test.gts | 1 - .../commands/set-user-system-card-test.gts | 1 - .../integration/commands/show-card-test.gts | 21 +- .../commands/summarize-session-test.gts | 1 - .../commands/switch-submode-test.gts | 1 - .../commands/transform-cards-test.gts | 16 +- .../commands/update-room-skills-test.gts | 2 - .../commands/upload-image-test.gts | 1 - .../commands/use-ai-assistant-test.gts | 1 - .../commands/write-text-file-test.gts | 1 - .../ai-assistant-panel/codeblocks-test.gts | 2 - .../ai-assistant-panel/commands-test.gts | 1 - .../ai-assistant-panel/debug-message-test.gts | 1 - .../ai-assistant-panel/general-test.gts | 1 - .../ai-assistant-panel/past-sessions-test.gts | 1 - .../ai-assistant-panel/reasoning-test.gts | 1 - .../ai-assistant-panel/scrolling-test.gts | 1 - .../ai-assistant-panel/sending-test.gts | 1 - .../ai-assistant-panel/skills-test.gts | 1 - .../components/ai-module-creation-test.gts | 1 - .../integration/components/ask-ai-test.gts | 1 - .../integration/components/card-api-test.gts | 1 - .../components/card-catalog-test.gts | 1 - .../integration/components/card-copy-test.gts | 1 - .../card-def-field-def-relationships-test.gts | 1 - .../components/card-delete-test.gts | 2 +- .../integration/components/computed-test.gts | 1 - .../integration/components/loading-test.gts | 1 - .../components/operator-mode-test.gts | 2 - .../prerendered-card-search-test.gts | 1 - .../components/serialization-test.gts | 2 - .../components/text-input-validator-test.gts | 2 +- .../components/text-suggestion-test.gts | 1 - .../integration/field-configuration-test.gts | 1 - .../message-service-subscription-test.gts | 1 - .../tests/integration/realm-indexing-test.gts | 2 - .../tests/integration/realm-querying-test.gts | 1 - .../host/tests/integration/realm-test.gts | 1 - .../integration/resources/search-test.ts | 1 - .../host/tests/integration/store-test.gts | 8 +- 87 files changed, 564 insertions(+), 616 deletions(-) diff --git a/packages/host/tests/acceptance/ai-assistant-test.gts b/packages/host/tests/acceptance/ai-assistant-test.gts index b83461d6e2..b5f5fcd1ee 100644 --- a/packages/host/tests/acceptance/ai-assistant-test.gts +++ b/packages/host/tests/acceptance/ai-assistant-test.gts @@ -119,7 +119,7 @@ function modelNameFor(llmId: string): string { module('Acceptance | AI Assistant tests', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/basic-test.gts b/packages/host/tests/acceptance/basic-test.gts index 34654033a9..c3c259ea90 100644 --- a/packages/host/tests/acceptance/basic-test.gts +++ b/packages/host/tests/acceptance/basic-test.gts @@ -16,7 +16,6 @@ import { setupApplicationTest } from '../helpers/setup'; module('Acceptance | basic tests', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/acceptance/catalog-app-test.gts b/packages/host/tests/acceptance/catalog-app-test.gts index 5b609c056c..6f0ffb6c02 100644 --- a/packages/host/tests/acceptance/catalog-app-test.gts +++ b/packages/host/tests/acceptance/catalog-app-test.gts @@ -163,7 +163,7 @@ const cardWithUnrecognisedImports = ` module('Acceptance | Catalog | catalog app tests', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { @@ -792,7 +792,7 @@ module('Acceptance | Catalog | catalog app tests', function (hooks) { snapshot.get(); }); -/** + /** * Selects a tab by name within the catalog app */ async function selectTab(tabName: string) { diff --git a/packages/host/tests/acceptance/code-patches-test.gts b/packages/host/tests/acceptance/code-patches-test.gts index 3e55c99edf..27094eb94b 100644 --- a/packages/host/tests/acceptance/code-patches-test.gts +++ b/packages/host/tests/acceptance/code-patches-test.gts @@ -62,7 +62,7 @@ export class TestCard extends CardDef { module('Acceptance | Code patches tests', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/code-submode-test.ts b/packages/host/tests/acceptance/code-submode-test.ts index 373528c79d..cb0011b623 100644 --- a/packages/host/tests/acceptance/code-submode-test.ts +++ b/packages/host/tests/acceptance/code-submode-test.ts @@ -426,119 +426,124 @@ module('Acceptance | code submode tests', function (_hooks) { let catalogRealmURL: string; setupApplicationTest(hooks); - setupLocalIndexing(hooks); - let mockMatrixUtils = setupMockMatrix(hooks, { - loggedInAs: '@testuser:localhost', - }); + let mockMatrixUtils = setupMockMatrix(hooks, { + loggedInAs: '@testuser:localhost', + }); - let { setActiveRealms, createAndJoinRoom } = mockMatrixUtils; - let defaultMatrixRoomId: string; - let snapshot = setupSnapshotRealm<{ - personalRealmURL: string; - additionalRealmURL: string; - catalogRealmURL: string; - }>(hooks, { - mockMatrixUtils, - acceptanceTest: true, - async build({ loader, isInitialBuild }) { - if (isInitialBuild || !defaultMatrixRoomId) { - defaultMatrixRoomId = createAndJoinRoom({ - sender: '@testuser:localhost', - name: 'room-test', - }); - } + let { setActiveRealms, createAndJoinRoom } = mockMatrixUtils; + let defaultMatrixRoomId: string; + let snapshot = setupSnapshotRealm<{ + personalRealmURL: string; + additionalRealmURL: string; + catalogRealmURL: string; + }>(hooks, { + mockMatrixUtils, + acceptanceTest: true, + async build({ loader, isInitialBuild }) { + if (isInitialBuild || !defaultMatrixRoomId) { + defaultMatrixRoomId = createAndJoinRoom({ + sender: '@testuser:localhost', + name: 'room-test', + }); + } - let realmServerService = getService('realm-server'); - personalRealmURL = `${realmServerService.url}testuser/personal/`; - additionalRealmURL = `${realmServerService.url}testuser/aaa/`; - catalogRealmURL = `${realmServerService.url}catalog/`; - setActiveRealms([catalogRealmURL, additionalRealmURL, personalRealmURL]); + let realmServerService = getService('realm-server'); + personalRealmURL = `${realmServerService.url}testuser/personal/`; + additionalRealmURL = `${realmServerService.url}testuser/aaa/`; + catalogRealmURL = `${realmServerService.url}catalog/`; + setActiveRealms([ + catalogRealmURL, + additionalRealmURL, + personalRealmURL, + ]); - await setupAcceptanceTestRealm({ - mockMatrixUtils, - loader, - realmURL: personalRealmURL, - permissions: { - '@testuser:localhost': ['read', 'write', 'realm-owner'], - }, - contents: { - ...SYSTEM_CARD_FIXTURE_CONTENTS, - 'hello.txt': txtSource, - '.realm.json': { - name: `Test User's Workspace`, - backgroundURL: 'https://i.postimg.cc/NjcjbyD3/4k-origami-flock.jpg', - iconURL: 'https://i.postimg.cc/Rq550Bwv/T.png', + await setupAcceptanceTestRealm({ + mockMatrixUtils, + loader, + realmURL: personalRealmURL, + permissions: { + '@testuser:localhost': ['read', 'write', 'realm-owner'], }, - }, - }); - await setupAcceptanceTestRealm({ - mockMatrixUtils, - loader, - realmURL: additionalRealmURL, - permissions: { - '@testuser:localhost': ['read', 'write', 'realm-owner'], - }, - contents: { - ...SYSTEM_CARD_FIXTURE_CONTENTS, - 'hello.txt': txtSource, - '.realm.json': { - name: `Additional Workspace`, - backgroundURL: 'https://i.postimg.cc/4ycXQZ94/4k-powder-puff.jpg', - iconURL: 'https://i.postimg.cc/BZwv0LyC/A.png', + contents: { + ...SYSTEM_CARD_FIXTURE_CONTENTS, + 'hello.txt': txtSource, + '.realm.json': { + name: `Test User's Workspace`, + backgroundURL: + 'https://i.postimg.cc/NjcjbyD3/4k-origami-flock.jpg', + iconURL: 'https://i.postimg.cc/Rq550Bwv/T.png', + }, }, - }, - }); - await setupAcceptanceTestRealm({ - mockMatrixUtils, - loader, - realmURL: catalogRealmURL, - permissions: { - '*': ['read'], - }, - contents: { - ...SYSTEM_CARD_FIXTURE_CONTENTS, - 'hello.txt': txtSource, - '.realm.json': { - name: `Catalog Realm`, - backgroundURL: 'https://i.postimg.cc/zXsXLmqb/C.png', - iconURL: 'https://i.postimg.cc/qv4pyPM0/4k-watercolor-splashes.jpg', + }); + await setupAcceptanceTestRealm({ + mockMatrixUtils, + loader, + realmURL: additionalRealmURL, + permissions: { + '@testuser:localhost': ['read', 'write', 'realm-owner'], }, - }, - }); - await setupAcceptanceTestRealm({ - mockMatrixUtils, - loader, - realmURL: testRealmURL, - permissions: { - '@testuser:localhost': ['read', 'write', 'realm-owner'], - }, - contents: { - ...SYSTEM_CARD_FIXTURE_CONTENTS, - }, - }); - return { personalRealmURL, additionalRealmURL, catalogRealmURL }; - }, - }); + contents: { + ...SYSTEM_CARD_FIXTURE_CONTENTS, + 'hello.txt': txtSource, + '.realm.json': { + name: `Additional Workspace`, + backgroundURL: 'https://i.postimg.cc/4ycXQZ94/4k-powder-puff.jpg', + iconURL: 'https://i.postimg.cc/BZwv0LyC/A.png', + }, + }, + }); + await setupAcceptanceTestRealm({ + mockMatrixUtils, + loader, + realmURL: catalogRealmURL, + permissions: { + '*': ['read'], + }, + contents: { + ...SYSTEM_CARD_FIXTURE_CONTENTS, + 'hello.txt': txtSource, + '.realm.json': { + name: `Catalog Realm`, + backgroundURL: 'https://i.postimg.cc/zXsXLmqb/C.png', + iconURL: + 'https://i.postimg.cc/qv4pyPM0/4k-watercolor-splashes.jpg', + }, + }, + }); + await setupAcceptanceTestRealm({ + mockMatrixUtils, + loader, + realmURL: testRealmURL, + permissions: { + '@testuser:localhost': ['read', 'write', 'realm-owner'], + }, + contents: { + ...SYSTEM_CARD_FIXTURE_CONTENTS, + }, + }); + return { personalRealmURL, additionalRealmURL, catalogRealmURL }; + }, + }); - async function openNewFileModal(menuSelection: string) { - await waitFor('[data-test-new-file-button]'); - await click('[data-test-new-file-button]'); - await click(`[data-test-boxel-menu-item-text="${menuSelection}"]`); - } + async function openNewFileModal(menuSelection: string) { + await waitFor('[data-test-new-file-button]'); + await click('[data-test-new-file-button]'); + await click(`[data-test-boxel-menu-item-text="${menuSelection}"]`); + } - hooks.beforeEach(function () { - let snapshotState = snapshot.get(); - personalRealmURL = snapshotState.personalRealmURL; - additionalRealmURL = snapshotState.additionalRealmURL; - catalogRealmURL = snapshotState.catalogRealmURL; - removePlaygroundSelections(); - removeSpecSelection(); - window.localStorage.removeItem(ModuleInspectorSelections); - window.localStorage.removeItem(PlaygroundSelections); - window.localStorage.removeItem(SpecSelection); - setActiveRealms([catalogRealmURL, additionalRealmURL, personalRealmURL]); - }); + hooks.beforeEach(function () { + let snapshotState = snapshot.get(); + personalRealmURL = snapshotState.personalRealmURL; + additionalRealmURL = snapshotState.additionalRealmURL; + catalogRealmURL = snapshotState.catalogRealmURL; + removePlaygroundSelections(); + removeSpecSelection(); + window.localStorage.removeItem(ModuleInspectorSelections); + window.localStorage.removeItem(PlaygroundSelections); + window.localStorage.removeItem(SpecSelection); + setActiveRealms([catalogRealmURL, additionalRealmURL, personalRealmURL]); + }); test('default realm is the personal realm', async function (assert) { await visitOperatorMode({ @@ -582,310 +587,309 @@ module('Acceptance | code submode tests', function (_hooks) { let monacoService: MonacoService; setupApplicationTest(hooks); - setupLocalIndexing(hooks); - let mockMatrixUtils = setupMockMatrix(hooks, { - loggedInAs: '@testuser:localhost', - activeRealms: [testRealmURL], - }); + let mockMatrixUtils = setupMockMatrix(hooks, { + loggedInAs: '@testuser:localhost', + activeRealms: [testRealmURL], + }); - let { createAndJoinRoom, setActiveRealms } = mockMatrixUtils; - let defaultMatrixRoomId: string; - let snapshot = setupSnapshotRealm<{ - monacoService: MonacoService; - realm: Realm; - }>(hooks, { - mockMatrixUtils, - acceptanceTest: true, - async build({ loader, isInitialBuild }) { - if (isInitialBuild || !defaultMatrixRoomId) { - defaultMatrixRoomId = createAndJoinRoom({ - sender: '@testuser:localhost', - name: 'room-test', - }); - } + let { createAndJoinRoom, setActiveRealms } = mockMatrixUtils; + let defaultMatrixRoomId: string; + let snapshot = setupSnapshotRealm<{ + monacoService: MonacoService; + realm: Realm; + }>(hooks, { + mockMatrixUtils, + acceptanceTest: true, + async build({ loader, isInitialBuild }) { + if (isInitialBuild || !defaultMatrixRoomId) { + defaultMatrixRoomId = createAndJoinRoom({ + sender: '@testuser:localhost', + name: 'room-test', + }); + } - monacoService = getService('monaco-service'); - - // this seeds the loader used during index which obtains url mappings - // from the global loader - ({ realm } = await setupAcceptanceTestRealm({ - mockMatrixUtils, - loader, - contents: { - ...SYSTEM_CARD_FIXTURE_CONTENTS, - 'index.gts': indexCardSource, - 'pet-person.gts': personCardSource, - 'person.gts': personCardSource, - 'pet.gts': petCardSource, - 'friend.gts': friendCardSource, - 'employee.gts': employeeCardSource, - 'in-this-file.gts': inThisFileSource, - 'postal-code.gts': postalCodeFieldSource, - 'address.gts': addressFieldSource, - 'country.gts': countryCardSource, - 'trips.gts': tripsFieldSource, - 'broken.gts': brokenSource, - 'broken-country.gts': brokenCountryCardSource, - 'broken-adoption-instance.json': brokenAdoptionInstance, - 'not-found-adoption-instance.json': notFoundAdoptionInstance, - 'person-entry.json': { - data: { - type: 'card', - attributes: { - title: 'Person', - description: 'Spec', - specType: 'card', - ref: { - module: `./person`, - name: 'Person', + monacoService = getService('monaco-service'); + + // this seeds the loader used during index which obtains url mappings + // from the global loader + ({ realm } = await setupAcceptanceTestRealm({ + mockMatrixUtils, + loader, + contents: { + ...SYSTEM_CARD_FIXTURE_CONTENTS, + 'index.gts': indexCardSource, + 'pet-person.gts': personCardSource, + 'person.gts': personCardSource, + 'pet.gts': petCardSource, + 'friend.gts': friendCardSource, + 'employee.gts': employeeCardSource, + 'in-this-file.gts': inThisFileSource, + 'postal-code.gts': postalCodeFieldSource, + 'address.gts': addressFieldSource, + 'country.gts': countryCardSource, + 'trips.gts': tripsFieldSource, + 'broken.gts': brokenSource, + 'broken-country.gts': brokenCountryCardSource, + 'broken-adoption-instance.json': brokenAdoptionInstance, + 'not-found-adoption-instance.json': notFoundAdoptionInstance, + 'person-entry.json': { + data: { + type: 'card', + attributes: { + title: 'Person', + description: 'Spec', + specType: 'card', + ref: { + module: `./person`, + name: 'Person', + }, }, - }, - meta: { - adoptsFrom: { - module: `${baseRealm.url}spec`, - name: 'Spec', + meta: { + adoptsFrom: { + module: `${baseRealm.url}spec`, + name: 'Spec', + }, }, }, }, - }, - 'pet-entry.json': { - data: { - type: 'card', - attributes: { - specType: 'card', - ref: { - module: `./pet`, - name: 'Pet', + 'pet-entry.json': { + data: { + type: 'card', + attributes: { + specType: 'card', + ref: { + module: `./pet`, + name: 'Pet', + }, }, - }, - meta: { - adoptsFrom: { - module: `${baseRealm.url}spec`, - name: 'Spec', + meta: { + adoptsFrom: { + module: `${baseRealm.url}spec`, + name: 'Spec', + }, }, }, }, - }, - 'pet-entry-2.json': { - data: { - type: 'card', - attributes: { - specType: 'card', - ref: { - module: `./pet`, - name: 'Pet', + 'pet-entry-2.json': { + data: { + type: 'card', + attributes: { + specType: 'card', + ref: { + module: `./pet`, + name: 'Pet', + }, }, - }, - meta: { - adoptsFrom: { - module: `${baseRealm.url}spec`, - name: 'Spec', + meta: { + adoptsFrom: { + module: `${baseRealm.url}spec`, + name: 'Spec', + }, }, }, }, - }, - 'index.json': { - data: { - type: 'card', - attributes: {}, - meta: { - adoptsFrom: { - module: './index', - name: 'Index', + 'index.json': { + data: { + type: 'card', + attributes: {}, + meta: { + adoptsFrom: { + module: './index', + name: 'Index', + }, }, }, }, - }, - 'not-json.json': 'I am not JSON.', - 'Person/fadhlan.json': { - data: { - attributes: { - firstName: 'Fadhlan', - address: [ - { - city: 'Bandung', - country: 'Indonesia', - shippingInfo: { - preferredCarrier: 'DHL', - remarks: `Don't let bob deliver the package--he's always bringing it to the wrong address`, + 'not-json.json': 'I am not JSON.', + 'Person/fadhlan.json': { + data: { + attributes: { + firstName: 'Fadhlan', + address: [ + { + city: 'Bandung', + country: 'Indonesia', + shippingInfo: { + preferredCarrier: 'DHL', + remarks: `Don't let bob deliver the package--he's always bringing it to the wrong address`, + }, + }, + ], + }, + relationships: { + pet: { + links: { + self: `${testRealmURL}Pet/mango`, }, - }, - ], - }, - relationships: { - pet: { - links: { - self: `${testRealmURL}Pet/mango`, }, }, - }, - meta: { - adoptsFrom: { - module: `${testRealmURL}person`, - name: 'Person', + meta: { + adoptsFrom: { + module: `${testRealmURL}person`, + name: 'Person', + }, }, }, }, - }, - 'Person/1.json': { - data: { - type: 'card', - attributes: { - firstName: 'Hassan', - lastName: 'Abdel-Rahman', - }, - meta: { - adoptsFrom: { - module: '../person', - name: 'Person', + 'Person/1.json': { + data: { + type: 'card', + attributes: { + firstName: 'Hassan', + lastName: 'Abdel-Rahman', + }, + meta: { + adoptsFrom: { + module: '../person', + name: 'Person', + }, }, }, }, - }, - 'Pet/mango.json': { - data: { - attributes: { - name: 'Mango', - }, - meta: { - adoptsFrom: { - module: `${testRealmURL}pet`, - name: 'Pet', + 'Pet/mango.json': { + data: { + attributes: { + name: 'Mango', + }, + meta: { + adoptsFrom: { + module: `${testRealmURL}pet`, + name: 'Pet', + }, }, }, }, - }, - 'Friend/amy.json': { - data: { - attributes: { - name: 'Amy', - }, - relationships: { - friend: { - links: { - self: `${testRealmURL}Friend/bob`, + 'Friend/amy.json': { + data: { + attributes: { + name: 'Amy', + }, + relationships: { + friend: { + links: { + self: `${testRealmURL}Friend/bob`, + }, }, }, - }, - meta: { - adoptsFrom: { - module: `${testRealmURL}friend`, - name: 'Friend', + meta: { + adoptsFrom: { + module: `${testRealmURL}friend`, + name: 'Friend', + }, }, }, }, - }, - 'Friend/bob.json': { - data: { - attributes: { - name: 'Bob', - }, - relationships: {}, - meta: { - adoptsFrom: { - module: `${testRealmURL}friend`, - name: 'Friend', + 'Friend/bob.json': { + data: { + attributes: { + name: 'Bob', + }, + relationships: {}, + meta: { + adoptsFrom: { + module: `${testRealmURL}friend`, + name: 'Friend', + }, }, }, }, - }, - 'Person/with-friends.json': { - data: { - attributes: { - firstName: 'With', - lastName: 'Friends', - }, - relationships: { - 'friends.0': { - links: { - self: `${testRealmURL}Friend/amy`, - }, + 'Person/with-friends.json': { + data: { + attributes: { + firstName: 'With', + lastName: 'Friends', }, - 'friends.1': { - links: { - self: `${testRealmURL}Friend/bob`, + relationships: { + 'friends.0': { + links: { + self: `${testRealmURL}Friend/amy`, + }, + }, + 'friends.1': { + links: { + self: `${testRealmURL}Friend/bob`, + }, }, }, - }, - meta: { - adoptsFrom: { - module: `${testRealmURL}person`, - name: 'Person', + meta: { + adoptsFrom: { + module: `${testRealmURL}person`, + name: 'Person', + }, }, }, }, - }, - 'Country/united-states.json': { - data: { - type: 'card', - attributes: { - name: 'United States', - description: null, - thumbnailURL: null, - }, - meta: { - adoptsFrom: { - module: '../country', - name: 'Country', + 'Country/united-states.json': { + data: { + type: 'card', + attributes: { + name: 'United States', + description: null, + thumbnailURL: null, + }, + meta: { + adoptsFrom: { + module: '../country', + name: 'Country', + }, }, }, }, - }, - 'BrokenCountry/broken-country.json': { - data: { - type: 'card', - attributes: { - name: 'Broken Country', - }, - meta: { - adoptsFrom: { - module: '../broken-country', - name: 'Country', + 'BrokenCountry/broken-country.json': { + data: { + type: 'card', + attributes: { + name: 'Broken Country', + }, + meta: { + adoptsFrom: { + module: '../broken-country', + name: 'Country', + }, }, }, }, + 'hello.txt': txtSource, + 'z00.json': '{}', + 'z01.json': '{}', + 'z02.json': '{}', + 'z03.json': '{}', + 'z04.json': '{}', + 'z05.json': '{}', + 'z06.json': '{}', + 'z07.json': '{}', + 'z08.json': '{}', + 'z09.json': '{}', + 'z10.json': '{}', + 'z11.json': '{}', + 'z12.json': '{}', + 'z13.json': '{}', + 'z14.json': '{}', + 'z15.json': '{}', + 'z16.json': '{}', + 'z17.json': '{}', + 'z18.json': '{}', + 'z19.json': '{}', + 'zzz/zzz/file.json': '{}', + '.realm.json': { + name: 'Test Workspace B', + backgroundURL: + 'https://i.postimg.cc/VNvHH93M/pawel-czerwinski-Ly-ZLa-A5jti-Y-unsplash.jpg', + iconURL: 'https://i.postimg.cc/L8yXRvws/icon.png', + }, + 'noop.gts': `export function noop() {};\nclass NoopClass {}`, }, - 'hello.txt': txtSource, - 'z00.json': '{}', - 'z01.json': '{}', - 'z02.json': '{}', - 'z03.json': '{}', - 'z04.json': '{}', - 'z05.json': '{}', - 'z06.json': '{}', - 'z07.json': '{}', - 'z08.json': '{}', - 'z09.json': '{}', - 'z10.json': '{}', - 'z11.json': '{}', - 'z12.json': '{}', - 'z13.json': '{}', - 'z14.json': '{}', - 'z15.json': '{}', - 'z16.json': '{}', - 'z17.json': '{}', - 'z18.json': '{}', - 'z19.json': '{}', - 'zzz/zzz/file.json': '{}', - '.realm.json': { - name: 'Test Workspace B', - backgroundURL: - 'https://i.postimg.cc/VNvHH93M/pawel-czerwinski-Ly-ZLa-A5jti-Y-unsplash.jpg', - iconURL: 'https://i.postimg.cc/L8yXRvws/icon.png', - }, - 'noop.gts': `export function noop() {};\nclass NoopClass {}`, - }, - })); + })); - return { monacoService, realm }; - }, - }); + return { monacoService, realm }; + }, + }); - hooks.beforeEach(function () { - ({ monacoService, realm } = snapshot.get()); - setActiveRealms([testRealmURL]); - }); + hooks.beforeEach(function () { + ({ monacoService, realm } = snapshot.get()); + setActiveRealms([testRealmURL]); + }); test('defaults to inheritance view and can toggle to file view', async function (assert) { await visitOperatorMode({ diff --git a/packages/host/tests/acceptance/code-submode/card-playground-test.gts b/packages/host/tests/acceptance/code-submode/card-playground-test.gts index df13587311..679cc029c7 100644 --- a/packages/host/tests/acceptance/code-submode/card-playground-test.gts +++ b/packages/host/tests/acceptance/code-submode/card-playground-test.gts @@ -177,7 +177,6 @@ module('Acceptance | code-submode | card playground', function (_hooks) { let realm: Realm; setupApplicationTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', @@ -1469,7 +1468,6 @@ module('Acceptance | code-submode | card playground', function (_hooks) { let additionalRealmURL: string; setupApplicationTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', @@ -1633,7 +1631,7 @@ module('Acceptance | code-submode | card playground', function (_hooks) { module('error handling', function (hooks) { let realm: Realm; setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/code-submode/create-file-test.gts b/packages/host/tests/acceptance/code-submode/create-file-test.gts index 5af56de13e..195cf18993 100644 --- a/packages/host/tests/acceptance/code-submode/create-file-test.gts +++ b/packages/host/tests/acceptance/code-submode/create-file-test.gts @@ -203,7 +203,7 @@ module('Acceptance | code submode | create-file tests', function (hooks) { }; setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/code-submode/editor-test.ts b/packages/host/tests/acceptance/code-submode/editor-test.ts index 9747dc98b7..749f43ca3e 100644 --- a/packages/host/tests/acceptance/code-submode/editor-test.ts +++ b/packages/host/tests/acceptance/code-submode/editor-test.ts @@ -42,7 +42,7 @@ module('Acceptance | code submode | editor tests', function (hooks) { let adapter: TestRealmAdapter; setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/acceptance/code-submode/field-playground-test.gts b/packages/host/tests/acceptance/code-submode/field-playground-test.gts index d40d4be239..e62660434d 100644 --- a/packages/host/tests/acceptance/code-submode/field-playground-test.gts +++ b/packages/host/tests/acceptance/code-submode/field-playground-test.gts @@ -295,7 +295,6 @@ module('Acceptance | code-submode | field playground', function (_hooks) { module('single realm', function (hooks) { let realm: Realm; setupApplicationTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', @@ -305,7 +304,6 @@ module('Acceptance | code-submode | field playground', function (_hooks) { let { setRealmPermissions, setActiveRealms, createAndJoinRoom } = mockMatrixUtils; - let defaultMatrixRoomId: string; let snapshot = setupSnapshotRealm<{ realm: Realm }>(hooks, { mockMatrixUtils, @@ -1096,7 +1094,6 @@ module('Acceptance | code-submode | field playground', function (_hooks) { let additionalRealmURL = `${origin}/testuser/aaa/`; // writeable realm that is lexically before the personal realm setupApplicationTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', @@ -1104,7 +1101,6 @@ module('Acceptance | code-submode | field playground', function (_hooks) { }); let { setRealmPermissions, createAndJoinRoom } = mockMatrixUtils; - let defaultMatrixRoomId: string; let multiRealmSnapshot = setupSnapshotRealm<{ realm: Realm }>(hooks, { mockMatrixUtils, @@ -1131,7 +1127,8 @@ module('Acceptance | code-submode | field playground', function (_hooks) { 'author.gts': authorCard, '.realm.json': { name: `Test User's Workspace`, - backgroundURL: 'https://i.postimg.cc/NjcjbyD3/4k-origami-flock.jpg', + backgroundURL: + 'https://i.postimg.cc/NjcjbyD3/4k-origami-flock.jpg', iconURL: 'https://i.postimg.cc/Rq550Bwv/T.png', }, }, diff --git a/packages/host/tests/acceptance/code-submode/file-tree-test.ts b/packages/host/tests/acceptance/code-submode/file-tree-test.ts index dd4031f0eb..85d0cd50fd 100644 --- a/packages/host/tests/acceptance/code-submode/file-tree-test.ts +++ b/packages/host/tests/acceptance/code-submode/file-tree-test.ts @@ -198,7 +198,6 @@ const realmInfo = { module('Acceptance | code submode | file-tree tests', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/acceptance/code-submode/inspector-test.ts b/packages/host/tests/acceptance/code-submode/inspector-test.ts index fcc923e18c..0117285275 100644 --- a/packages/host/tests/acceptance/code-submode/inspector-test.ts +++ b/packages/host/tests/acceptance/code-submode/inspector-test.ts @@ -419,7 +419,7 @@ module('Acceptance | code submode | inspector tests', function (hooks) { let monacoService: MonacoService; setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/code-submode/recent-files-test.ts b/packages/host/tests/acceptance/code-submode/recent-files-test.ts index 456b649bb5..43634a7c9a 100644 --- a/packages/host/tests/acceptance/code-submode/recent-files-test.ts +++ b/packages/host/tests/acceptance/code-submode/recent-files-test.ts @@ -191,7 +191,6 @@ const friendCardSource = ` let monacoService: MonacoService; module('Acceptance | code submode | recent files tests', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/acceptance/code-submode/schema-editor-test.ts b/packages/host/tests/acceptance/code-submode/schema-editor-test.ts index 3ab2f5b8fc..bb18996144 100644 --- a/packages/host/tests/acceptance/code-submode/schema-editor-test.ts +++ b/packages/host/tests/acceptance/code-submode/schema-editor-test.ts @@ -245,7 +245,7 @@ module('Acceptance | code submode | schema editor tests', function (hooks) { let monacoService: MonacoService; setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/code-submode/spec-test.gts b/packages/host/tests/acceptance/code-submode/spec-test.gts index a1d0349a95..9cd0890de5 100644 --- a/packages/host/tests/acceptance/code-submode/spec-test.gts +++ b/packages/host/tests/acceptance/code-submode/spec-test.gts @@ -268,7 +268,7 @@ const polymorphicFieldCardSource = ` module('Acceptance | Spec preview', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/commands-test.gts b/packages/host/tests/acceptance/commands-test.gts index 2f6a47a1a0..676c69e06d 100644 --- a/packages/host/tests/acceptance/commands-test.gts +++ b/packages/host/tests/acceptance/commands-test.gts @@ -81,7 +81,7 @@ let maybeBoomShouldBoom = true; module('Acceptance | Commands tests', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/host-mode-test.gts b/packages/host/tests/acceptance/host-mode-test.gts index f5eb6ea7e1..9083a1386c 100644 --- a/packages/host/tests/acceptance/host-mode-test.gts +++ b/packages/host/tests/acceptance/host-mode-test.gts @@ -52,7 +52,7 @@ class StubCustomSubdomainHostModeService extends StubHostModeService { module('Acceptance | host mode tests', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/host-submode-test.gts b/packages/host/tests/acceptance/host-submode-test.gts index 33d2620786..008fdda461 100644 --- a/packages/host/tests/acceptance/host-submode-test.gts +++ b/packages/host/tests/acceptance/host-submode-test.gts @@ -75,7 +75,7 @@ function withUpdatedTestRealmInfo( module('Acceptance | host submode', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/interact-submode/create-file-test.gts b/packages/host/tests/acceptance/interact-submode/create-file-test.gts index 23e1284c99..f244fd6e8c 100644 --- a/packages/host/tests/acceptance/interact-submode/create-file-test.gts +++ b/packages/host/tests/acceptance/interact-submode/create-file-test.gts @@ -204,7 +204,7 @@ const userRealmFiles: Record = { module('Acceptance | interact submode | create-file tests', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/operator-mode-acceptance-test.gts b/packages/host/tests/acceptance/operator-mode-acceptance-test.gts index aaae6472af..0eee2d7cb6 100644 --- a/packages/host/tests/acceptance/operator-mode-acceptance-test.gts +++ b/packages/host/tests/acceptance/operator-mode-acceptance-test.gts @@ -81,7 +81,7 @@ module('Acceptance | operator mode tests', function (hooks) { matrixRoomId: string; }; setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); setupBaseRealm(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/prerender-html-test.gts b/packages/host/tests/acceptance/prerender-html-test.gts index dc229e9236..489d5bc614 100644 --- a/packages/host/tests/acceptance/prerender-html-test.gts +++ b/packages/host/tests/acceptance/prerender-html-test.gts @@ -26,7 +26,7 @@ import { setupApplicationTest } from '../helpers/setup'; module('Acceptance | prerender | html', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/prerender-meta-test.gts b/packages/host/tests/acceptance/prerender-meta-test.gts index 596a362618..3b14f7a108 100644 --- a/packages/host/tests/acceptance/prerender-meta-test.gts +++ b/packages/host/tests/acceptance/prerender-meta-test.gts @@ -24,7 +24,7 @@ import { setupApplicationTest } from '../helpers/setup'; module('Acceptance | prerender | meta', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/prerender-module-test.gts b/packages/host/tests/acceptance/prerender-module-test.gts index de55e5db4a..93a050f966 100644 --- a/packages/host/tests/acceptance/prerender-module-test.gts +++ b/packages/host/tests/acceptance/prerender-module-test.gts @@ -28,7 +28,7 @@ import type { TestRealmAdapter } from '../helpers/adapter'; module('Acceptance | prerender | module', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/real-catalog-app-test.gts b/packages/host/tests/acceptance/real-catalog-app-test.gts index 2dc17de80e..8b5309b3bd 100644 --- a/packages/host/tests/acceptance/real-catalog-app-test.gts +++ b/packages/host/tests/acceptance/real-catalog-app-test.gts @@ -27,7 +27,7 @@ class StubHostModeService extends HostModeService { module('Acceptance | Catalog | real catalog app', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + let snapshot = setupSnapshotRealm(hooks, { acceptanceTest: true, async build() { diff --git a/packages/host/tests/acceptance/site-config-test.gts b/packages/host/tests/acceptance/site-config-test.gts index d927810e65..df45cc07a4 100644 --- a/packages/host/tests/acceptance/site-config-test.gts +++ b/packages/host/tests/acceptance/site-config-test.gts @@ -47,7 +47,7 @@ function removeTrailingSlash(url: string): string { module('Acceptance | site config home page', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/theme-card-test.gts b/packages/host/tests/acceptance/theme-card-test.gts index 75a0041f75..43ecf2d6f2 100644 --- a/packages/host/tests/acceptance/theme-card-test.gts +++ b/packages/host/tests/acceptance/theme-card-test.gts @@ -147,7 +147,7 @@ const SOFT_POP_VARS = `:root { module('Acceptance | theme-card-test', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/acceptance/workspace-delete-multiple-test.gts b/packages/host/tests/acceptance/workspace-delete-multiple-test.gts index e1e483e4f7..2aa7937e57 100644 --- a/packages/host/tests/acceptance/workspace-delete-multiple-test.gts +++ b/packages/host/tests/acceptance/workspace-delete-multiple-test.gts @@ -19,7 +19,7 @@ import { setupApplicationTest } from '../helpers/setup'; module('Acceptance | workspace-delete-multiple', function (hooks) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupBaseRealm(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/helpers/interact-submode-setup.gts b/packages/host/tests/helpers/interact-submode-setup.gts index 8e17724bfd..dd7f5da6af 100644 --- a/packages/host/tests/helpers/interact-submode-setup.gts +++ b/packages/host/tests/helpers/interact-submode-setup.gts @@ -31,7 +31,7 @@ export function setupInteractSubmodeTests( { setRealm }: InteractSubmodeSetupOptions, ) { setupApplicationTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { @@ -81,38 +81,38 @@ export function setupInteractSubmodeTests( @field name = contains(StringField); @field favoriteTreat = contains(StringField); - @field title = contains(StringField, { - computeVia: function (this: Pet) { - return this.name; - }, - }); - static fitted = class Fitted extends Component { - - }; - static isolated = class Isolated extends Component { - + }; + } class Puppy extends Pet { static displayName = 'Puppy'; @@ -121,124 +121,130 @@ export function setupInteractSubmodeTests( class ShippingInfo extends FieldDef { static displayName = 'Shipping Info'; - @field preferredCarrier = contains(StringField); - @field remarks = contains(StringField); - @field title = contains(StringField, { - computeVia: function (this: ShippingInfo) { - return this.preferredCarrier; - }, - }); - static embedded = class Embedded extends Component { - - }; - } + @field preferredCarrier = contains(StringField); + @field remarks = contains(StringField); + @field title = contains(StringField, { + computeVia: function (this: ShippingInfo) { + return this.preferredCarrier; + }, + }); + static embedded = class Embedded extends Component { + + }; + } class Address extends FieldDef { static displayName = 'Address'; - @field city = contains(StringField); - @field country = contains(StringField); - @field shippingInfo = contains(ShippingInfo); - static embedded = class Embedded extends Component { - + }; - static edit = class Edit extends Component { - - }; - } + static edit = class Edit extends Component { + + }; + } class Person extends CardDef { static displayName = 'Person'; - @field firstName = contains(StringField); - @field pet = linksTo(Pet); - @field friends = linksToMany(Pet); - @field firstLetterOfTheName = contains(StringField, { - computeVia: function (this: Person) { - if (!this.firstName) { - return; - } - return this.firstName[0]; - }, - }); - @field title = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName; - }, - }); - @field primaryAddress = contains(Address); - @field additionalAddresses = containsMany(Address); + @field firstName = contains(StringField); + @field pet = linksTo(Pet); + @field friends = linksToMany(Pet); + @field firstLetterOfTheName = contains(StringField, { + computeVia: function (this: Person) { + if (!this.firstName) { + return; + } + return this.firstName[0]; + }, + }); + @field title = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName; + }, + }); + @field primaryAddress = contains(Address); + @field additionalAddresses = containsMany(Address); - static isolated = class Isolated extends Component { - updateAndSavePet = () => { - let pet = this.args.model.pet; - if (pet) { - pet.name = 'Updated Pet'; - this.args.saveCard?.(pet.id); - } - }; - - }; - } + }; + + }; + } class Personnel extends Person { static displayName = 'Personnel'; diff --git a/packages/host/tests/helpers/snapshot-realm.ts b/packages/host/tests/helpers/snapshot-realm.ts index 8f0abfaeab..1c0b0fb694 100644 --- a/packages/host/tests/helpers/snapshot-realm.ts +++ b/packages/host/tests/helpers/snapshot-realm.ts @@ -2,6 +2,7 @@ import { getService } from '@universal-ember/test-support'; import type { RealmAction } from '@cardstack/runtime-common'; import { Loader } from '@cardstack/runtime-common/loader'; +import { baseRealm } from '@cardstack/runtime-common'; import type { SerializedServerState } from './mock-matrix/_server-state'; import type { MockUtils } from './mock-matrix/_utils'; @@ -9,6 +10,9 @@ import { type DbSnapshot, setupUserSubscription, setupAuthEndpoints, + setupLocalIndexing, + setupCardLogs, + type NestedHooks, captureDbSnapshot, restoreDbSnapshot, deleteSnapshot, @@ -16,6 +20,7 @@ import { } from '.'; import { setupBaseRealm } from './base-realm'; +import { setup } from 'qunit-dom'; export interface SnapshotBuildContext { isInitialBuild: boolean; @@ -49,6 +54,13 @@ export function setupSnapshotRealm( let cache: SnapshotCache | undefined; let latestState: T | undefined; + setupCardLogs( + hooks, + async () => + await getService('loader-service').loader.import( + `${baseRealm.url}card-api`, + ), + ); hooks.beforeEach(async function () { setupRendering(options.acceptanceTest!!); }); @@ -60,6 +72,7 @@ export function setupSnapshotRealm( }); } }); + setupLocalIndexing(hooks); if (options.setupBaseRealm !== false) { setupBaseRealm(hooks); } diff --git a/packages/host/tests/integration/commands/add-field-to-card-definition-command-test.gts b/packages/host/tests/integration/commands/add-field-to-card-definition-command-test.gts index e012834d71..f98428201e 100644 --- a/packages/host/tests/integration/commands/add-field-to-card-definition-command-test.gts +++ b/packages/host/tests/integration/commands/add-field-to-card-definition-command-test.gts @@ -31,7 +31,7 @@ module( 'Integration | commands | add-field-to-card-definition', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); + let mockMatrixUtils = setupMockMatrix(hooks); let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, diff --git a/packages/host/tests/integration/commands/check-correctness-test.gts b/packages/host/tests/integration/commands/check-correctness-test.gts index d9a15c323f..ea1cc478bd 100644 --- a/packages/host/tests/integration/commands/check-correctness-test.gts +++ b/packages/host/tests/integration/commands/check-correctness-test.gts @@ -18,7 +18,7 @@ import { getService } from '@universal-ember/test-support'; module('Integration | commands | check-correctness', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); + let mockMatrixUtils = setupMockMatrix(hooks, { autostart: true, loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/copy-and-edit-test.gts b/packages/host/tests/integration/commands/copy-and-edit-test.gts index 7dda1ef4c3..d189c2882d 100644 --- a/packages/host/tests/integration/commands/copy-and-edit-test.gts +++ b/packages/host/tests/integration/commands/copy-and-edit-test.gts @@ -26,7 +26,6 @@ const otherRealmURL = 'http://other-realm/test2/'; module('Integration | commands | copy-and-edit', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/copy-card-test.gts b/packages/host/tests/integration/commands/copy-card-test.gts index 2721948f1f..fe414183b8 100644 --- a/packages/host/tests/integration/commands/copy-card-test.gts +++ b/packages/host/tests/integration/commands/copy-card-test.gts @@ -25,7 +25,6 @@ const testRealm2URL = 'http://test-realm/test2/'; module('Integration | commands | copy-card', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/copy-source-test.gts b/packages/host/tests/integration/commands/copy-source-test.gts index 04a4f44dbd..c434c31595 100644 --- a/packages/host/tests/integration/commands/copy-source-test.gts +++ b/packages/host/tests/integration/commands/copy-source-test.gts @@ -32,7 +32,6 @@ class StubRealmService extends RealmService { module('Integration | commands | copy-source', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks); diff --git a/packages/host/tests/integration/commands/create-spec-test.gts b/packages/host/tests/integration/commands/create-spec-test.gts index d76dcd5e82..1b537dce0b 100644 --- a/packages/host/tests/integration/commands/create-spec-test.gts +++ b/packages/host/tests/integration/commands/create-spec-test.gts @@ -55,7 +55,6 @@ module('Integration | Command | create-specs', function (hooks) { }, ]); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', activeRealms: [testRealmURL], diff --git a/packages/host/tests/integration/commands/generate-example-cards-one-shot-test.gts b/packages/host/tests/integration/commands/generate-example-cards-one-shot-test.gts index af3a704ca8..8b3823e68b 100644 --- a/packages/host/tests/integration/commands/generate-example-cards-one-shot-test.gts +++ b/packages/host/tests/integration/commands/generate-example-cards-one-shot-test.gts @@ -17,7 +17,6 @@ module( 'Integration | Command | generate-example-cards (one-shot)', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/open-workspace-test.gts b/packages/host/tests/integration/commands/open-workspace-test.gts index 5088e5e8e2..1bf417142d 100644 --- a/packages/host/tests/integration/commands/open-workspace-test.gts +++ b/packages/host/tests/integration/commands/open-workspace-test.gts @@ -14,7 +14,6 @@ import { setupRenderingTest } from '../../helpers/setup'; module('Integration | commands | open-workspace', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/patch-code-test.gts b/packages/host/tests/integration/commands/patch-code-test.gts index 4c98ef54e6..0e29f1129d 100644 --- a/packages/host/tests/integration/commands/patch-code-test.gts +++ b/packages/host/tests/integration/commands/patch-code-test.gts @@ -32,7 +32,6 @@ module('Integration | commands | patch-code', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { autostart: true }); let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, diff --git a/packages/host/tests/integration/commands/patch-fields-test.gts b/packages/host/tests/integration/commands/patch-fields-test.gts index 8b2a239c31..970d100aab 100644 --- a/packages/host/tests/integration/commands/patch-fields-test.gts +++ b/packages/host/tests/integration/commands/patch-fields-test.gts @@ -35,7 +35,7 @@ import { setupRenderingTest } from '../../helpers/setup'; module('Integration | Command | patch-fields', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let commandService: CommandService; let store: StoreService; diff --git a/packages/host/tests/integration/commands/patch-instance-test.gts b/packages/host/tests/integration/commands/patch-instance-test.gts index f7adab334c..dc65614d04 100644 --- a/packages/host/tests/integration/commands/patch-instance-test.gts +++ b/packages/host/tests/integration/commands/patch-instance-test.gts @@ -37,7 +37,6 @@ import { setupRenderingTest } from '../../helpers/setup'; module('Integration | commands | patch-instance', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { autostart: true }); let commandService: CommandService; diff --git a/packages/host/tests/integration/commands/preview-format-test.gts b/packages/host/tests/integration/commands/preview-format-test.gts index bacfd30496..467f3a87ee 100644 --- a/packages/host/tests/integration/commands/preview-format-test.gts +++ b/packages/host/tests/integration/commands/preview-format-test.gts @@ -36,7 +36,6 @@ class StubRealmService extends RealmService { module('Integration | Command | preview-format', function (hooks) { setupRenderingTest(hooks); setupWindowMock(hooks); - setupLocalIndexing(hooks); const realmName = 'Preview Format Test Realm'; let loader: Loader; diff --git a/packages/host/tests/integration/commands/read-card-for-ai-assistant-test.gts b/packages/host/tests/integration/commands/read-card-for-ai-assistant-test.gts index 93a0bafea4..e52d763a18 100644 --- a/packages/host/tests/integration/commands/read-card-for-ai-assistant-test.gts +++ b/packages/host/tests/integration/commands/read-card-for-ai-assistant-test.gts @@ -32,7 +32,6 @@ class StubRealmService extends RealmService { module('Integration | commands | read-card-for-ai-assistant', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/read-file-for-ai-assistant-test.gts b/packages/host/tests/integration/commands/read-file-for-ai-assistant-test.gts index 5ae5c504d9..e23baf1d38 100644 --- a/packages/host/tests/integration/commands/read-file-for-ai-assistant-test.gts +++ b/packages/host/tests/integration/commands/read-file-for-ai-assistant-test.gts @@ -30,7 +30,6 @@ class StubRealmService extends RealmService { module('Integration | commands | read-file-for-ai-assistant', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/read-source-test.gts b/packages/host/tests/integration/commands/read-source-test.gts index 70f8786825..aa37533d63 100644 --- a/packages/host/tests/integration/commands/read-source-test.gts +++ b/packages/host/tests/integration/commands/read-source-test.gts @@ -29,7 +29,6 @@ class StubRealmService extends RealmService { module('Integration | commands | read-source', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks); let snapshot = setupSnapshotRealm(hooks, { diff --git a/packages/host/tests/integration/commands/read-text-file-test.gts b/packages/host/tests/integration/commands/read-text-file-test.gts index 10dcc49d4d..11073ecb7e 100644 --- a/packages/host/tests/integration/commands/read-text-file-test.gts +++ b/packages/host/tests/integration/commands/read-text-file-test.gts @@ -29,7 +29,6 @@ class StubRealmService extends RealmService { module('Integration | commands | read-text-file', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks); let snapshot = setupSnapshotRealm(hooks, { diff --git a/packages/host/tests/integration/commands/search-command-test.gts b/packages/host/tests/integration/commands/search-command-test.gts index b631d3cabc..66f1e2b460 100644 --- a/packages/host/tests/integration/commands/search-command-test.gts +++ b/packages/host/tests/integration/commands/search-command-test.gts @@ -39,7 +39,6 @@ module('Integration | commands | search', function (hooks) { const realmName = 'Operator Mode Workspace'; let loader: Loader; - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/commands/search-google-images-test.gts b/packages/host/tests/integration/commands/search-google-images-test.gts index b9a810349b..b2f04b527e 100644 --- a/packages/host/tests/integration/commands/search-google-images-test.gts +++ b/packages/host/tests/integration/commands/search-google-images-test.gts @@ -15,7 +15,6 @@ import { setupRenderingTest } from '../../helpers/setup'; module('Integration | commands | search-google-images', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/send-ai-assistant-message-test.gts b/packages/host/tests/integration/commands/send-ai-assistant-message-test.gts index 2bc0ce1af0..9bd2c1513e 100644 --- a/packages/host/tests/integration/commands/send-ai-assistant-message-test.gts +++ b/packages/host/tests/integration/commands/send-ai-assistant-message-test.gts @@ -32,7 +32,6 @@ class StubRealmService extends RealmService { module('Integration | commands | send-ai-assistant-message', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/send-request-via-proxy-test.gts b/packages/host/tests/integration/commands/send-request-via-proxy-test.gts index 4d360a3aa0..6a380c6e07 100644 --- a/packages/host/tests/integration/commands/send-request-via-proxy-test.gts +++ b/packages/host/tests/integration/commands/send-request-via-proxy-test.gts @@ -29,7 +29,6 @@ class StubRealmService extends RealmService { module('Integration | commands | send-request-via-proxy', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/set-user-system-card-test.gts b/packages/host/tests/integration/commands/set-user-system-card-test.gts index c55f2cb326..d63de76237 100644 --- a/packages/host/tests/integration/commands/set-user-system-card-test.gts +++ b/packages/host/tests/integration/commands/set-user-system-card-test.gts @@ -29,7 +29,6 @@ class StubRealmService extends RealmService { module('Integration | commands | set-user-system-card', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/show-card-test.gts b/packages/host/tests/integration/commands/show-card-test.gts index 056c16f636..ab6712ba30 100644 --- a/packages/host/tests/integration/commands/show-card-test.gts +++ b/packages/host/tests/integration/commands/show-card-test.gts @@ -120,6 +120,15 @@ module('Integration | Command | show-card', function (hooks) { setupRenderingTest(hooks); setupWindowMock(hooks); + setupOnSave(hooks); + setupCardLogs( + hooks, + async () => + await getService('loader-service').loader.import( + `${baseRealm.url}card-api`, + ), + ); + const realmName = 'Show Card Test Realm'; let loader: Loader; let mockMatrixUtils = setupMockMatrix(hooks, { @@ -130,8 +139,6 @@ module('Integration | Command | show-card', function (hooks) { let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; await setupIntegrationTestRealm({ mockMatrixUtils, contents: { @@ -220,23 +227,13 @@ module('Integration | Command | show-card', function (hooks) { hooks.beforeEach(function (this: RenderingTestContext) { getOwner(this)!.register('service:realm', StubRealmService); - ({ loader } = snapshot.get()); }); - setupLocalIndexing(hooks); - setupOnSave(hooks); - setupCardLogs( - hooks, - async () => await loader.import(`${baseRealm.url}card-api`), - ); - let command: ShowCardCommand; let mockOperatorModeStateService: MockOperatorModeStateService; let mockPlaygroundPanelService: MockPlaygroundPanelService; hooks.beforeEach(function (this: RenderingTestContext) { - snapshot.get(); - mockOperatorModeStateService = new MockOperatorModeStateService(); mockPlaygroundPanelService = new MockPlaygroundPanelService(); diff --git a/packages/host/tests/integration/commands/summarize-session-test.gts b/packages/host/tests/integration/commands/summarize-session-test.gts index db46c5bb72..326c4cc0cb 100644 --- a/packages/host/tests/integration/commands/summarize-session-test.gts +++ b/packages/host/tests/integration/commands/summarize-session-test.gts @@ -29,7 +29,6 @@ class StubRealmService extends RealmService { module('Integration | commands | summarize-session', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/switch-submode-test.gts b/packages/host/tests/integration/commands/switch-submode-test.gts index 46b1d33489..8249c46725 100644 --- a/packages/host/tests/integration/commands/switch-submode-test.gts +++ b/packages/host/tests/integration/commands/switch-submode-test.gts @@ -36,7 +36,6 @@ class StubRealmService extends RealmService { module('Integration | commands | switch-submode', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/transform-cards-test.gts b/packages/host/tests/integration/commands/transform-cards-test.gts index eb8163c307..c58498a4c0 100644 --- a/packages/host/tests/integration/commands/transform-cards-test.gts +++ b/packages/host/tests/integration/commands/transform-cards-test.gts @@ -52,9 +52,9 @@ module('Integration | commands | transform-cards', function (hooks) { loaderService.loader = loader; let cardApi: typeof import('https://cardstack.com/base/card-api'); let string: typeof import('https://cardstack.com/base/string'); - let CommandModule = await loader.import( - `${baseRealm.url}command`, - ); + let CommandModule = await loader.import< + typeof import('https://cardstack.com/base/command') + >(`${baseRealm.url}command`); cardApi = await loader.import(`${baseRealm.url}card-api`); string = await loader.import(`${baseRealm.url}string`); @@ -85,7 +85,10 @@ module('Integration | commands | transform-cards', function (hooks) { }); } - class PrefixNameCommand extends Command { + class PrefixNameCommand extends Command< + typeof JsonCard, + typeof JsonCard + > { async getInputType() { return JsonCard; } @@ -235,12 +238,7 @@ module('Integration | commands | transform-cards', function (hooks) { ({ loader } = snapshot.get()); }); - setupLocalIndexing(hooks); setupOnSave(hooks); - setupCardLogs( - hooks, - async () => await loader.import(`${baseRealm.url}card-api`), - ); hooks.beforeEach(function () { snapshot.get(); diff --git a/packages/host/tests/integration/commands/update-room-skills-test.gts b/packages/host/tests/integration/commands/update-room-skills-test.gts index dd800ecfef..6889223d16 100644 --- a/packages/host/tests/integration/commands/update-room-skills-test.gts +++ b/packages/host/tests/integration/commands/update-room-skills-test.gts @@ -146,8 +146,6 @@ module('Integration | Command | update-room-skills', function (hooks) { matrixService.reset(); }); - setupLocalIndexing(hooks); - setupOnSave(hooks); setupCardLogs( hooks, async () => await loader.import(`${baseRealm.url}card-api`), diff --git a/packages/host/tests/integration/commands/upload-image-test.gts b/packages/host/tests/integration/commands/upload-image-test.gts index 9993f3dff9..184ad0867e 100644 --- a/packages/host/tests/integration/commands/upload-image-test.gts +++ b/packages/host/tests/integration/commands/upload-image-test.gts @@ -32,7 +32,6 @@ class StubRealmService extends RealmService { module('Integration | commands | upload-image', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/use-ai-assistant-test.gts b/packages/host/tests/integration/commands/use-ai-assistant-test.gts index 3256f13861..99b1455a19 100644 --- a/packages/host/tests/integration/commands/use-ai-assistant-test.gts +++ b/packages/host/tests/integration/commands/use-ai-assistant-test.gts @@ -45,7 +45,6 @@ class StubRealmService extends RealmService { module('Integration | commands | ai-assistant', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/commands/write-text-file-test.gts b/packages/host/tests/integration/commands/write-text-file-test.gts index d90603ae24..9f6e21fdc9 100644 --- a/packages/host/tests/integration/commands/write-text-file-test.gts +++ b/packages/host/tests/integration/commands/write-text-file-test.gts @@ -40,7 +40,6 @@ class StubRealmService extends RealmService { module('Integration | commands | write-text-file', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks); let snapshot = setupSnapshotRealm(hooks, { diff --git a/packages/host/tests/integration/components/ai-assistant-panel/codeblocks-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/codeblocks-test.gts index a85940f4c7..c53b20cb6d 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/codeblocks-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/codeblocks-test.gts @@ -79,8 +79,6 @@ module('Integration | ai-assistant-panel | codeblocks', function (hooks) { }, }); - setupLocalIndexing(hooks); - setupOnSave(hooks); setupCardLogs( hooks, async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), diff --git a/packages/host/tests/integration/components/ai-assistant-panel/commands-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/commands-test.gts index d0a61a8ade..4e1442a0d0 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/commands-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/commands-test.gts @@ -79,7 +79,6 @@ module('Integration | ai-assistant-panel | commands', function (hooks) { }, }); - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/components/ai-assistant-panel/debug-message-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/debug-message-test.gts index 10fd996988..bb154b192d 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/debug-message-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/debug-message-test.gts @@ -65,7 +65,6 @@ module('Integration | ai-assistant-panel | debug-message', function (hooks) { }, }); - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/components/ai-assistant-panel/general-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/general-test.gts index ff00edbadd..6f7ac1b8ea 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/general-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/general-test.gts @@ -69,7 +69,6 @@ module('Integration | ai-assistant-panel | general', function (hooks) { setupRenderingTest(hooks); setupOperatorModeStateCleanup(hooks); - setupLocalIndexing(hooks); setupOnSave(hooks); hooks.beforeEach(async function () { await setupRendering(false); diff --git a/packages/host/tests/integration/components/ai-assistant-panel/past-sessions-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/past-sessions-test.gts index 2bfca5b51e..e90d9946e6 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/past-sessions-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/past-sessions-test.gts @@ -68,7 +68,6 @@ module('Integration | ai-assistant-panel | past sessions', function (hooks) { }, }); - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/components/ai-assistant-panel/reasoning-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/reasoning-test.gts index 31d4b96a41..7c13ae1bcc 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/reasoning-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/reasoning-test.gts @@ -66,7 +66,6 @@ module('Integration | ai-assistant-panel | reasoning', function (hooks) { }, }); - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/components/ai-assistant-panel/scrolling-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/scrolling-test.gts index fa06ce1bbd..6ebf9f6d27 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/scrolling-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/scrolling-test.gts @@ -68,7 +68,6 @@ module('Integration | ai-assistant-panel | scrolling', function (hooks) { }, }); - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/components/ai-assistant-panel/sending-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/sending-test.gts index 110bd877c2..190c094588 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/sending-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/sending-test.gts @@ -72,7 +72,6 @@ module('Integration | ai-assistant-panel | sending', function (hooks) { }, }); - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/components/ai-assistant-panel/skills-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/skills-test.gts index 5d888b590d..096d89c29b 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/skills-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/skills-test.gts @@ -83,7 +83,6 @@ module('Integration | ai-assistant-panel | skills', function (hooks) { }, }); - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/components/ai-module-creation-test.gts b/packages/host/tests/integration/components/ai-module-creation-test.gts index 263ffb345b..b86efa8908 100644 --- a/packages/host/tests/integration/components/ai-module-creation-test.gts +++ b/packages/host/tests/integration/components/ai-module-creation-test.gts @@ -71,7 +71,6 @@ module('Integration | create app module via ai-assistant', function (hooks) { this.owner.register('service:router', MockRouterService); }); - setupLocalIndexing(hooks); setupCardLogs( hooks, async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), diff --git a/packages/host/tests/integration/components/ask-ai-test.gts b/packages/host/tests/integration/components/ask-ai-test.gts index cab1939ccd..9ccc3d21a1 100644 --- a/packages/host/tests/integration/components/ask-ai-test.gts +++ b/packages/host/tests/integration/components/ask-ai-test.gts @@ -33,7 +33,6 @@ module('Integration | ask-ai', function (hooks) { setupRenderingTest(hooks); setupOperatorModeStateCleanup(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/components/card-api-test.gts b/packages/host/tests/integration/components/card-api-test.gts index 10a31a786c..e7969f59aa 100644 --- a/packages/host/tests/integration/components/card-api-test.gts +++ b/packages/host/tests/integration/components/card-api-test.gts @@ -70,7 +70,6 @@ class CardContextConsumer extends GlimmerComponent module('Integration | card api (Usage of publicAPI actions)', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks); diff --git a/packages/host/tests/integration/components/card-catalog-test.gts b/packages/host/tests/integration/components/card-catalog-test.gts index 64575a8067..930dbeb9fb 100644 --- a/packages/host/tests/integration/components/card-catalog-test.gts +++ b/packages/host/tests/integration/components/card-catalog-test.gts @@ -31,7 +31,6 @@ const realmName = 'Local Workspace'; module('Integration | card-catalog', function (hooks) { setupRenderingTest(hooks); setupOperatorModeStateCleanup(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/components/card-copy-test.gts b/packages/host/tests/integration/components/card-copy-test.gts index 0f77e0db5b..c5c1bc985e 100644 --- a/packages/host/tests/integration/components/card-copy-test.gts +++ b/packages/host/tests/integration/components/card-copy-test.gts @@ -60,7 +60,6 @@ module('Integration | card-copy', function (hooks) { setupRenderingTest(hooks); setupOperatorModeStateCleanup(hooks); - setupLocalIndexing(hooks); let loggedInAs = '@testuser:localhost'; diff --git a/packages/host/tests/integration/components/card-def-field-def-relationships-test.gts b/packages/host/tests/integration/components/card-def-field-def-relationships-test.gts index 597e615230..bab9f4c187 100644 --- a/packages/host/tests/integration/components/card-def-field-def-relationships-test.gts +++ b/packages/host/tests/integration/components/card-def-field-def-relationships-test.gts @@ -53,7 +53,6 @@ module('Integration | CardDef-FieldDef relationships test', function (hooks) { setupRenderingTest(hooks); setupOperatorModeStateCleanup(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/components/card-delete-test.gts b/packages/host/tests/integration/components/card-delete-test.gts index 78d245d335..993613b3b0 100644 --- a/packages/host/tests/integration/components/card-delete-test.gts +++ b/packages/host/tests/integration/components/card-delete-test.gts @@ -78,7 +78,7 @@ module('Integration | card-delete', function (hooks) { return card; } setupRenderingTest(hooks); - setupLocalIndexing(hooks); + setupOperatorModeStateCleanup(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/integration/components/computed-test.gts b/packages/host/tests/integration/components/computed-test.gts index c4eac16980..c441a8dafd 100644 --- a/packages/host/tests/integration/components/computed-test.gts +++ b/packages/host/tests/integration/components/computed-test.gts @@ -59,7 +59,6 @@ module('Integration | computeds', function (hooks) { ({ loader } = snapshot.get()); }); - setupLocalIndexing(hooks); setupCardLogs( hooks, diff --git a/packages/host/tests/integration/components/loading-test.gts b/packages/host/tests/integration/components/loading-test.gts index f42cb20414..4c9b7f9273 100644 --- a/packages/host/tests/integration/components/loading-test.gts +++ b/packages/host/tests/integration/components/loading-test.gts @@ -25,7 +25,6 @@ module('Integration | loading', function (hooks) { let loader: Loader; let cardApi: typeof import('https://cardstack.com/base/card-api'); - setupLocalIndexing(hooks); setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/integration/components/operator-mode-test.gts b/packages/host/tests/integration/components/operator-mode-test.gts index 44296c5730..74c5a7c576 100644 --- a/packages/host/tests/integration/components/operator-mode-test.gts +++ b/packages/host/tests/integration/components/operator-mode-test.gts @@ -73,8 +73,6 @@ module('Integration | operator-mode', function (hooks) { let testRealmAdapter: TestRealmAdapter; let operatorModeStateService: OperatorModeStateService; - setupLocalIndexing(hooks); - setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', activeRealms: [testRealmURL], diff --git a/packages/host/tests/integration/components/prerendered-card-search-test.gts b/packages/host/tests/integration/components/prerendered-card-search-test.gts index cfe8228d23..ea786dcbe4 100644 --- a/packages/host/tests/integration/components/prerendered-card-search-test.gts +++ b/packages/host/tests/integration/components/prerendered-card-search-test.gts @@ -70,7 +70,6 @@ module(`Integration | prerendered-card-search`, function (hooks) { let testRealm: Realm; setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/components/serialization-test.gts b/packages/host/tests/integration/components/serialization-test.gts index cd1ea522f9..d666d6ed1a 100644 --- a/packages/host/tests/integration/components/serialization-test.gts +++ b/packages/host/tests/integration/components/serialization-test.gts @@ -88,8 +88,6 @@ module('Integration | serialization', function (hooks) { ({ loader } = snapshot.get()); }); - setupLocalIndexing(hooks); - setupCardLogs( hooks, async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), diff --git a/packages/host/tests/integration/components/text-input-validator-test.gts b/packages/host/tests/integration/components/text-input-validator-test.gts index 6c52d3fdbf..ac79dad170 100644 --- a/packages/host/tests/integration/components/text-input-validator-test.gts +++ b/packages/host/tests/integration/components/text-input-validator-test.gts @@ -34,7 +34,7 @@ module('Integration | text-input-validator', function (hooks) { let realm: Realm; setupRenderingTest(hooks); setupOperatorModeStateCleanup(hooks); - setupLocalIndexing(hooks); + setupOnSave(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { diff --git a/packages/host/tests/integration/components/text-suggestion-test.gts b/packages/host/tests/integration/components/text-suggestion-test.gts index 51559d7a10..fa064fe8d3 100644 --- a/packages/host/tests/integration/components/text-suggestion-test.gts +++ b/packages/host/tests/integration/components/text-suggestion-test.gts @@ -23,7 +23,6 @@ let loader: Loader; module('Integration | text-suggestion | card-chooser-title', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks); diff --git a/packages/host/tests/integration/field-configuration-test.gts b/packages/host/tests/integration/field-configuration-test.gts index af0ea7ac8b..a702a26ff2 100644 --- a/packages/host/tests/integration/field-configuration-test.gts +++ b/packages/host/tests/integration/field-configuration-test.gts @@ -134,7 +134,6 @@ function buildThemeDocument(palette: string): SingleCardDocument { module('Integration | field configuration', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks); let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { diff --git a/packages/host/tests/integration/message-service-subscription-test.gts b/packages/host/tests/integration/message-service-subscription-test.gts index 2038cad086..ed4e1f17ce 100644 --- a/packages/host/tests/integration/message-service-subscription-test.gts +++ b/packages/host/tests/integration/message-service-subscription-test.gts @@ -34,7 +34,6 @@ let loader: Loader; module('Integration | message service subscription', function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', activeRealms: [testRealmURL], diff --git a/packages/host/tests/integration/realm-indexing-test.gts b/packages/host/tests/integration/realm-indexing-test.gts index 982a9ad3b2..8bca830f21 100644 --- a/packages/host/tests/integration/realm-indexing-test.gts +++ b/packages/host/tests/integration/realm-indexing-test.gts @@ -105,8 +105,6 @@ module(`Integration | realm indexing`, function (hooks) { window.removeEventListener('boxel-render-error', onError); }); - setupLocalIndexing(hooks); - setupCardLogs( hooks, async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), diff --git a/packages/host/tests/integration/realm-querying-test.gts b/packages/host/tests/integration/realm-querying-test.gts index 9519b98233..8159c2409b 100644 --- a/packages/host/tests/integration/realm-querying-test.gts +++ b/packages/host/tests/integration/realm-querying-test.gts @@ -24,7 +24,6 @@ const paths = new RealmPaths(new URL(testRealmURL)); module(`Integration | realm querying`, function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks); const sampleCards: CardDocFiles = { diff --git a/packages/host/tests/integration/realm-test.gts b/packages/host/tests/integration/realm-test.gts index 5bb142ac47..595da09ac1 100644 --- a/packages/host/tests/integration/realm-test.gts +++ b/packages/host/tests/integration/realm-test.gts @@ -60,7 +60,6 @@ module('Integration | realm', function (hooks) { }, }); - setupLocalIndexing(hooks); setupCardLogs( hooks, async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), diff --git a/packages/host/tests/integration/resources/search-test.ts b/packages/host/tests/integration/resources/search-test.ts index 88c70782e4..92e013b494 100644 --- a/packages/host/tests/integration/resources/search-test.ts +++ b/packages/host/tests/integration/resources/search-test.ts @@ -50,7 +50,6 @@ function getSearchResourceForTest( module(`Integration | search resource`, function (hooks) { setupRenderingTest(hooks); - setupLocalIndexing(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { loggedInAs: '@testuser:localhost', diff --git a/packages/host/tests/integration/store-test.gts b/packages/host/tests/integration/store-test.gts index 52f7ea4754..9457201da2 100644 --- a/packages/host/tests/integration/store-test.gts +++ b/packages/host/tests/integration/store-test.gts @@ -1,9 +1,4 @@ -import { - waitUntil, - waitFor, - click, - typeIn, -} from '@ember/test-helpers'; +import { waitUntil, waitFor, click, typeIn } from '@ember/test-helpers'; import GlimmerComponent from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; @@ -70,7 +65,6 @@ module('Integration | Store', function (hooks) { let BoomPersonDef: typeof CardDefType; let realmService: RealmService; - setupLocalIndexing(hooks); setupOnSave(hooks); setupCardLogs( hooks, From adfe09a5da4f52e5fbbe6245ae371ee575ff0460 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Mon, 15 Dec 2025 11:25:07 +0000 Subject: [PATCH 08/17] Include db snapshot deletion --- packages/host/app/lib/sqlite-adapter.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/host/app/lib/sqlite-adapter.ts b/packages/host/app/lib/sqlite-adapter.ts index e9bcfa1573..b85c82a474 100644 --- a/packages/host/app/lib/sqlite-adapter.ts +++ b/packages/host/app/lib/sqlite-adapter.ts @@ -200,6 +200,20 @@ export default class SQLiteAdapter implements DBAdapter { return alias; } + async deleteSnapshot(snapshotName: string) { + this.assertNotClosed(); + await this.started; + let snapshotInfo = this.snapshotInfos.get(snapshotName); + if (!snapshotInfo) { + throw new Error(`Unknown snapshot database '${snapshotName}'`); + } + await this.sqlite('exec', { + dbId: this.dbId, + sql: `DETACH DATABASE ${snapshotName};`, + }); + this.snapshotInfos.delete(snapshotName); + } + async importSnapshot(snapshotName: string) { this.assertNotClosed(); await this.started; From 14a2a7d4cc004dc9975634253d42851056500811 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Mon, 15 Dec 2025 12:09:59 +0000 Subject: [PATCH 09/17] Flush the logs in the teardown rather than more setup hooks --- packages/host/tests/helpers/base-realm.ts | 2 +- packages/host/tests/helpers/index.gts | 21 +++++++-------- packages/host/tests/helpers/snapshot-realm.ts | 26 +++++++------------ 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/packages/host/tests/helpers/base-realm.ts b/packages/host/tests/helpers/base-realm.ts index e084a79ba1..ea28bf0202 100644 --- a/packages/host/tests/helpers/base-realm.ts +++ b/packages/host/tests/helpers/base-realm.ts @@ -106,7 +106,7 @@ let enumOptions: (typeof EnumModule)['enumOptions']; let enumValues: (typeof EnumModule)['enumValues']; let enumConfig: (typeof EnumModule)['enumConfig']; -async function initialize() { +export async function initialize() { let loader = getService('loader-service').loader; StringField = ( diff --git a/packages/host/tests/helpers/index.gts b/packages/host/tests/helpers/index.gts index 5eec5a9914..55197d4a64 100644 --- a/packages/host/tests/helpers/index.gts +++ b/packages/host/tests/helpers/index.gts @@ -84,6 +84,8 @@ export { setupSnapshotRealm } from './snapshot-realm'; export * from '@cardstack/runtime-common/helpers'; export * from './indexer'; +import { flushLogs } from './base-realm'; + export const testModuleRealm = 'http://localhost:4202/test/'; const { sqlSchema } = ENV; @@ -121,9 +123,6 @@ export function createTimingLogger( return { step(label: string) { let current = timingNow(); - if (skip) { - return; - } console.log( `[${scope}] ${label} took ${(current - last).toFixed(2)}ms (total ${( current - start @@ -132,9 +131,6 @@ export function createTimingLogger( last = current; }, finish(label = 'total') { - if (skip) { - return; - } let current = timingNow(); console.log(`[${scope}] ${label} took ${(current - start).toFixed(2)}ms`); }, @@ -525,16 +521,20 @@ export function setupLocalIndexing(hooks: NestedHooks) { // "Cannot call .factoryFor('template:index-card_error') after the owner has been destroyed" await settled(); let store = getService('store'); + let loaderService = getService('loader-service'); + let renderStore = getService('render-store'); + + await flushLogs(); + await store.flushSaves(); await store.loaded(); + let context = this as RenderingContextWithPrerender; context.__cardPrerenderElement?.remove(); context.__cardPrerenderElement = undefined; // reference counts should balance out automatically as components are destroyed store.resetCache({ preserveReferences: true }); - let renderStore = getService('render-store'); renderStore.resetCache({ preserveReferences: true }); - let loaderService = getService('loader-service'); loaderService.resetLoader({ clearFetchCache: true, reason: 'test teardown', @@ -1058,10 +1058,7 @@ export function setupCardLogs( hooks: NestedHooks, apiThunk: () => Promise, ) { - hooks.afterEach(async function () { - let api = await apiThunk(); - await api.flushLogs(); - }); + // nop } export function createJWT( diff --git a/packages/host/tests/helpers/snapshot-realm.ts b/packages/host/tests/helpers/snapshot-realm.ts index 1c0b0fb694..a4ca5f7b42 100644 --- a/packages/host/tests/helpers/snapshot-realm.ts +++ b/packages/host/tests/helpers/snapshot-realm.ts @@ -11,16 +11,15 @@ import { setupUserSubscription, setupAuthEndpoints, setupLocalIndexing, - setupCardLogs, type NestedHooks, captureDbSnapshot, restoreDbSnapshot, deleteSnapshot, setupRendering, + createTimingLogger, } from '.'; -import { setupBaseRealm } from './base-realm'; -import { setup } from 'qunit-dom'; +import { initialize } from './base-realm'; export interface SnapshotBuildContext { isInitialBuild: boolean; @@ -42,7 +41,7 @@ export interface SnapshotRealmHandle { interface SetupSnapshotRealmOptions { build: (context: SnapshotBuildContext) => Promise; mockMatrixUtils: MockUtils; - setupBaseRealm?: boolean; // TODO: default to false, allow opt-in + reInitialiseBaseRealm?: boolean; // TODO: default to true realmPermissions?: Record; acceptanceTest?: boolean; } @@ -54,28 +53,21 @@ export function setupSnapshotRealm( let cache: SnapshotCache | undefined; let latestState: T | undefined; - setupCardLogs( - hooks, - async () => - await getService('loader-service').loader.import( - `${baseRealm.url}card-api`, - ), - ); - hooks.beforeEach(async function () { - setupRendering(options.acceptanceTest!!); - }); hooks.beforeEach(async function () { let loaderService = getService('loader-service'); if (cache) { + console.log('Restoring loader from snapshot'); loaderService.loader = Loader.cloneLoader(cache.loaderSnapshot, { includeEvaluatedModules: true, }); } }); + hooks.beforeEach(async function () { + setupRendering(options.acceptanceTest!!); + }); + setupLocalIndexing(hooks); - if (options.setupBaseRealm !== false) { - setupBaseRealm(hooks); - } + hooks.beforeEach(initialize); hooks.beforeEach(async function () { setupUserSubscription(); From 9ae2c550048243b42b69fd4722753162907fa8d8 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Mon, 15 Dec 2025 12:10:23 +0000 Subject: [PATCH 10/17] remove logs --- packages/host/tests/helpers/snapshot-realm.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/host/tests/helpers/snapshot-realm.ts b/packages/host/tests/helpers/snapshot-realm.ts index a4ca5f7b42..3326d83a1f 100644 --- a/packages/host/tests/helpers/snapshot-realm.ts +++ b/packages/host/tests/helpers/snapshot-realm.ts @@ -56,7 +56,6 @@ export function setupSnapshotRealm( hooks.beforeEach(async function () { let loaderService = getService('loader-service'); if (cache) { - console.log('Restoring loader from snapshot'); loaderService.loader = Loader.cloneLoader(cache.loaderSnapshot, { includeEvaluatedModules: true, }); From 17ebe4497104da4b06a618314187fdaa7a140f13 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Mon, 15 Dec 2025 13:31:53 +0000 Subject: [PATCH 11/17] Issue with mounting and unmounting with the virtual network --- .../commands/upload-image-test.gts | 104 +++++++----------- 1 file changed, 38 insertions(+), 66 deletions(-) diff --git a/packages/host/tests/integration/commands/upload-image-test.gts b/packages/host/tests/integration/commands/upload-image-test.gts index 184ad0867e..dcd0c83777 100644 --- a/packages/host/tests/integration/commands/upload-image-test.gts +++ b/packages/host/tests/integration/commands/upload-image-test.gts @@ -31,6 +31,29 @@ class StubRealmService extends RealmService { } module('Integration | commands | upload-image', function (hooks) { + let lastForwardPayload: any; + let forwardPayloads: any[] = []; + let lastDirectUploadRequest: + | { + url: string; + formData: FormData; + } + | undefined; + let networkService: NetworkService; + let directUploadFetchHandler: + | ((request: Request) => Promise) + | undefined; + let handlerMounted = false; + + const directUploadResponse = { + success: true, + errors: [], + result: { + id: 'direct-upload-id', + uploadURL: 'https://upload.imagedelivery.net/direct-upload-url', + }, + }; + setupRenderingTest(hooks); let mockMatrixUtils = setupMockMatrix(hooks, { @@ -49,33 +72,17 @@ module('Integration | commands | upload-image', function (hooks) { ...SYSTEM_CARD_FIXTURE_CONTENTS, }, loader, + realmPermissions: { + [testRealmURL]: { + read: true, + write: true, + }, + }, }); return {}; }, }); - let lastForwardPayload: any; - let forwardPayloads: any[] = []; - let lastDirectUploadRequest: - | { - url: string; - formData: FormData; - } - | undefined; - let networkService: NetworkService; - let directUploadFetchHandler: - | ((request: Request) => Promise) - | undefined; - - const directUploadResponse = { - success: true, - errors: [], - result: { - id: 'direct-upload-id', - uploadURL: 'https://upload.imagedelivery.net/direct-upload-url', - }, - }; - setupRealmServerEndpoints(hooks, [ { route: '_request-forward', @@ -109,8 +116,8 @@ module('Integration | commands | upload-image', function (hooks) { ]); hooks.beforeEach(async function (this: RenderingTestContext) { - snapshot.get(); getOwner(this)!.register('service:realm', StubRealmService); + networkService = getService('network'); lastForwardPayload = undefined; forwardPayloads = []; lastDirectUploadRequest = undefined; @@ -139,23 +146,17 @@ module('Integration | commands | upload-image', function (hooks) { } return null; }; - networkService = getService('network'); - networkService.virtualNetwork.mount(directUploadFetchHandler, { - prepend: true, - }); - - await setupIntegrationTestRealm({ - mockMatrixUtils, - contents: { - ...SYSTEM_CARD_FIXTURE_CONTENTS, - }, - }); + if (!handlerMounted) { + networkService.virtualNetwork.mount(directUploadFetchHandler, { + prepend: true, + }); + } }); - hooks.afterEach(function () { - if (directUploadFetchHandler) { + hooks.after(function () { + if (handlerMounted) { networkService.virtualNetwork.unmount(directUploadFetchHandler); - directUploadFetchHandler = undefined; + handlerMounted = false; } }); @@ -224,34 +225,6 @@ module('Integration | commands | upload-image', function (hooks) { }); const objectUrl = URL.createObjectURL(file); - const originalFetch = globalThis.fetch; - globalThis.fetch = async ( - input: RequestInfo | URL, - init?: RequestInit, - ): Promise => { - let url: string; - if (typeof input === 'string') { - url = input; - } else if (input instanceof URL) { - url = input.href; - } else if (input instanceof Request) { - url = input.url; - } else { - url = String(input); - } - - if (url.startsWith('blob:')) { - return new Response(file, { - status: 200, - headers: { - 'Content-Type': file.type, - }, - }); - } - - return originalFetch(input as RequestInfo, init); - }; - try { const result = await command.execute({ sourceImageUrl: objectUrl, @@ -312,7 +285,6 @@ module('Integration | commands | upload-image', function (hooks) { 'saved card uses id returned by direct upload', ); } finally { - globalThis.fetch = originalFetch; URL.revokeObjectURL(objectUrl); } }); From 5adfe30f2a8d354acb75efe3caa6e14c5e87a123 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Mon, 15 Dec 2025 13:36:35 +0000 Subject: [PATCH 12/17] Make sure matrix is started --- .../tests/integration/commands/write-text-file-test.gts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/host/tests/integration/commands/write-text-file-test.gts b/packages/host/tests/integration/commands/write-text-file-test.gts index 9f6e21fdc9..b9cd3230c4 100644 --- a/packages/host/tests/integration/commands/write-text-file-test.gts +++ b/packages/host/tests/integration/commands/write-text-file-test.gts @@ -41,7 +41,11 @@ class StubRealmService extends RealmService { module('Integration | commands | write-text-file', function (hooks) { setupRenderingTest(hooks); - let mockMatrixUtils = setupMockMatrix(hooks); + let mockMatrixUtils = setupMockMatrix(hooks, { + loggedInAs: '@testuser:localhost', + activeRealms: [testRealmURL], + autostart: true, + }); let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { @@ -49,6 +53,7 @@ module('Integration | commands | write-text-file', function (hooks) { loaderService.loader = loader; await setupIntegrationTestRealm({ mockMatrixUtils, + realmURL: testRealmURL, contents: {}, loader, }); From ac0d72fc414bbb1729753657416ddd0e8e6ea9bb Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Mon, 15 Dec 2025 13:39:47 +0000 Subject: [PATCH 13/17] Required matrix for the first test --- .../host/tests/integration/commands/write-text-file-test.gts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/host/tests/integration/commands/write-text-file-test.gts b/packages/host/tests/integration/commands/write-text-file-test.gts index b9cd3230c4..ee28ec423b 100644 --- a/packages/host/tests/integration/commands/write-text-file-test.gts +++ b/packages/host/tests/integration/commands/write-text-file-test.gts @@ -18,6 +18,7 @@ import { } from '../../helpers'; import { setupMockMatrix } from '../../helpers/mock-matrix'; import { setupRenderingTest } from '../../helpers/setup'; +import { baseRealm } from '@cardstack/runtime-common'; let fetch: NetworkService['fetch']; @@ -51,6 +52,7 @@ module('Integration | commands | write-text-file', function (hooks) { async build({ loader }) { let loaderService = getService('loader-service'); loaderService.loader = loader; + await loader.import(`${baseRealm.url}command`); await setupIntegrationTestRealm({ mockMatrixUtils, realmURL: testRealmURL, From 7ae726a19b6c25d4c293e2ade1bb1bc8697d3062 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Mon, 15 Dec 2025 14:32:37 +0000 Subject: [PATCH 14/17] Specs needed for operatormode tests --- packages/host/tests/helpers/base-realm.ts | 9 ++++++++- .../tests/integration/components/operator-mode-test.gts | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/host/tests/helpers/base-realm.ts b/packages/host/tests/helpers/base-realm.ts index ea28bf0202..c55f917861 100644 --- a/packages/host/tests/helpers/base-realm.ts +++ b/packages/host/tests/helpers/base-realm.ts @@ -19,6 +19,7 @@ import type * as PhoneNumberFieldModule from 'https://cardstack.com/base/phone-n import type * as RealmFieldModule from 'https://cardstack.com/base/realm'; import type * as SkillModule from 'https://cardstack.com/base/skill'; import type * as StringFieldModule from 'https://cardstack.com/base/string'; +import type * as SpecModule from 'https://cardstack.com/base/spec'; import type * as SystemCardModule from 'https://cardstack.com/base/system-card'; import type * as TextAreaFieldModule from 'https://cardstack.com/base/text-area'; @@ -70,6 +71,9 @@ let CardsGrid: CardsGrid; type Skill = (typeof SkillModule)['Skill']; let Skill: Skill; +type Spec = (typeof SpecModule)['Spec']; +let Spec: Spec; + type ModelConfiguration = (typeof SystemCardModule)['ModelConfiguration']; let ModelConfiguration: ModelConfiguration; @@ -178,6 +182,8 @@ export async function initialize() { Skill = (await loader.import(`${baseRealm.url}skill`)) .Skill; + Spec = (await loader.import(`${baseRealm.url}spec`)).Spec; + ModelConfiguration = ( await loader.import(`${baseRealm.url}system-card`) ).ModelConfiguration; @@ -248,6 +254,8 @@ export { RealmField, PhoneNumberField, CardsGrid, + Skill, + Spec, SystemCard, ModelConfiguration, field, @@ -273,7 +281,6 @@ export { getFields, getFieldDescription, ReadOnlyField, - Skill, instanceOf, CardInfoField, enumField, diff --git a/packages/host/tests/integration/components/operator-mode-test.gts b/packages/host/tests/integration/components/operator-mode-test.gts index 74c5a7c576..eacd6bd93d 100644 --- a/packages/host/tests/integration/components/operator-mode-test.gts +++ b/packages/host/tests/integration/components/operator-mode-test.gts @@ -79,6 +79,8 @@ module('Integration | operator-mode', function (hooks) { autostart: true, }); + setupOnSave(hooks); + let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { mockMatrixUtils, async build({ loader }) { From ff86c80b10a9b5b01f55908cec1a93f2aa0f760b Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Mon, 15 Dec 2025 21:07:52 +0000 Subject: [PATCH 15/17] Improve loading speed --- packages/host/app/lib/browser-queue.ts | 10 +++++++--- packages/host/app/services/loader-service.ts | 12 +++++++++++- packages/host/tests/helpers/snapshot-realm.ts | 4 ++-- packages/runtime-common/loader.ts | 7 +++++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/host/app/lib/browser-queue.ts b/packages/host/app/lib/browser-queue.ts index 7256de6c74..3f23c3a750 100644 --- a/packages/host/app/lib/browser-queue.ts +++ b/packages/host/app/lib/browser-queue.ts @@ -77,9 +77,13 @@ export class BrowserQueue implements QueuePublisher, QueueRunner { return job; } - private debouncedDrainJobs = debounce(() => { - this.drainJobs(); - }, 250); + private debouncedDrainJobs = debounce( + () => { + this.drainJobs(); + }, + 1, + { leading: true }, + ); private async drainJobs() { await this.flush(); diff --git a/packages/host/app/services/loader-service.ts b/packages/host/app/services/loader-service.ts index 93ebaa8327..2fb3030e4e 100644 --- a/packages/host/app/services/loader-service.ts +++ b/packages/host/app/services/loader-service.ts @@ -5,6 +5,7 @@ import Service, { service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; import type { FetcherMiddlewareHandler } from '@cardstack/runtime-common'; +import { baseRealm } from '@cardstack/runtime-common'; import { fetcher, maybeHandleScopedCSSRequest, @@ -22,6 +23,7 @@ import type NetworkService from './network'; import type RealmService from './realm'; import type RealmInfoService from './realm-info-service'; import type ResetService from './reset'; +import { isTesting } from '@embroider/macros'; const log = logger('loader-service'); @@ -68,7 +70,15 @@ export default class LoaderService extends Service { // by default we keep the fetch cache so we can take advantage of HTTP // caching when rebuilding the loader state if (this.loader) { - this.loader = Loader.cloneLoader(this.loader); + // If we're testing, we can keep the base realm modules cached to speed + // up tests + if (isTesting()) { + this.loader = Loader.cloneLoader(this.loader, { + includeEvaluatedModules: `${baseRealm.url}.*`, + }); + } else { + this.loader = Loader.cloneLoader(this.loader); + } } else { this.loader = this.makeInstance(); } diff --git a/packages/host/tests/helpers/snapshot-realm.ts b/packages/host/tests/helpers/snapshot-realm.ts index 3326d83a1f..39467d1caf 100644 --- a/packages/host/tests/helpers/snapshot-realm.ts +++ b/packages/host/tests/helpers/snapshot-realm.ts @@ -57,7 +57,7 @@ export function setupSnapshotRealm( let loaderService = getService('loader-service'); if (cache) { loaderService.loader = Loader.cloneLoader(cache.loaderSnapshot, { - includeEvaluatedModules: true, + includeEvaluatedModules: '.*', }); } }); @@ -88,7 +88,7 @@ export function setupSnapshotRealm( if (!cache) { let clonedLoader = Loader.cloneLoader(loaderService.loader, { - includeEvaluatedModules: true, + includeEvaluatedModules: '.*', }); cache = { loaderSnapshot: clonedLoader, diff --git a/packages/runtime-common/loader.ts b/packages/runtime-common/loader.ts index f5edb61c16..ca779ae5e9 100644 --- a/packages/runtime-common/loader.ts +++ b/packages/runtime-common/loader.ts @@ -119,7 +119,7 @@ export class Loader { static cloneLoader( loader: Loader, - options?: { includeEvaluatedModules?: boolean }, + options?: { includeEvaluatedModules?: string }, ): Loader { let clone = new Loader(loader.fetchImplementation, loader.resolveImport); for (let [moduleIdentifier, module] of loader.moduleShims) { @@ -130,7 +130,10 @@ export class Loader { if (loader.moduleShims.has(moduleIdentifier)) { continue; } - if (module.state === 'evaluated') { + if ( + module.state === 'evaluated' && + moduleIdentifier.match(options.includeEvaluatedModules) + ) { clone.shimModule( moduleIdentifier, module.moduleInstance as Record, From 63f500288dd9642ea6ee2c0b45f57faa12f1227d Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Tue, 16 Dec 2025 09:53:21 +0000 Subject: [PATCH 16/17] More migrations for the testing update --- .../ai-assistant-panel/codeblocks-test.gts | 174 ++++++------ .../ai-assistant-panel/commands-test.gts | 260 +++++++++--------- .../ai-assistant-panel/debug-message-test.gts | 30 +- .../ai-assistant-panel/general-test.gts | 202 +++++++------- .../ai-assistant-panel/past-sessions-test.gts | 192 ++++++------- .../ai-assistant-panel/reasoning-test.gts | 88 +++--- .../ai-assistant-panel/scrolling-test.gts | 88 +++--- .../ai-assistant-panel/sending-test.gts | 88 +++--- .../ai-assistant-panel/skills-test.gts | 127 ++++++++- 9 files changed, 634 insertions(+), 615 deletions(-) diff --git a/packages/host/tests/integration/components/ai-assistant-panel/codeblocks-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/codeblocks-test.gts index c53b20cb6d..bc2780d789 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/codeblocks-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/codeblocks-test.gts @@ -17,9 +17,7 @@ import { REPLACE_MARKER, SEARCH_MARKER, SEPARATOR_MARKER, - baseRealm, } from '@cardstack/runtime-common'; -import { Loader } from '@cardstack/runtime-common/loader'; import OperatorMode from '@cardstack/host/components/operator-mode/container'; @@ -28,7 +26,6 @@ import type OperatorModeStateService from '@cardstack/host/services/operator-mod import { percySnapshot, testRealmURL, - setupCardLogs, setupIntegrationTestRealm, setupLocalIndexing, setupOnSave, @@ -50,7 +47,6 @@ import { setupRenderingTest } from '../../../helpers/setup'; module('Integration | ai-assistant-panel | codeblocks', function (hooks) { const realmName = 'Operator Mode Workspace'; - let loader: Loader; let operatorModeStateService: OperatorModeStateService; setupRenderingTest(hooks); @@ -70,33 +66,16 @@ module('Integration | ai-assistant-panel | codeblocks', function (hooks) { let { simulateRemoteMessage, createAndJoinRoom } = mockMatrixUtils; - let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { + let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - return { loader }; - }, - }); - - setupCardLogs( - hooks, - async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), - ); - - let noop = () => {}; - - hooks.beforeEach(async function () { - ({ loader } = snapshot.get()); - operatorModeStateService = getService('operator-mode-state-service'); - - // Add cardService mock for example.com/component.gts - let cardService = getService('card-service'); - cardService.getSource = async (url: URL) => { - if (url.toString() === 'https://example.com/component.gts') { - return { - status: 200, - content: `import Component from '@glimmer/component'; + // Add cardService mock for example.com/component.gts + let cardService = getService('card-service'); + cardService.getSource = async (url: URL) => { + if (url.toString() === 'https://example.com/component.gts') { + return { + status: 200, + content: `import Component from '@glimmer/component'; export default class MyComponent extends Component { a = 1; @@ -109,79 +88,88 @@ export default class MyComponent extends Component { }`, + }; + } + return { + status: 404, + content: '', }; - } - return { - status: 404, - content: '', }; - }; - class Address extends FieldDef { - static displayName = 'Address'; - @field city = contains(StringField); - @field country = contains(StringField); - static embedded = class Embedded extends Component { - - }; - } + class Address extends FieldDef { + static displayName = 'Address'; + @field city = contains(StringField); + @field country = contains(StringField); + static embedded = class Embedded extends Component { + + }; + } + + class Person extends CardDef { + static displayName = 'Person'; + @field firstName = contains(StringField); + @field firstLetterOfTheName = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName[0]; + }, + }); + @field title = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName; + }, + }); + @field address = contains(Address); + static isolated = class Isolated extends Component { + + }; + } - class Person extends CardDef { - static displayName = 'Person'; - @field firstName = contains(StringField); - @field firstLetterOfTheName = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName[0]; + await setupIntegrationTestRealm({ + mockMatrixUtils, + contents: { + 'address.gts': { Address }, + 'person.gts': { Person }, + 'Person/fadhlan.json': new Person({ + firstName: 'Fadhlan', + address: new Address({ + city: 'Bandung', + country: 'Indonesia', + }), + }), + '.realm.json': `{ "name": "${realmName}" }`, }, }); - @field title = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName; - }, + + createAndJoinRoom({ + sender: '@testuser:localhost', + name: 'room-test', }); - @field address = contains(Address); - static isolated = class Isolated extends Component { - - }; - } - await setupIntegrationTestRealm({ - mockMatrixUtils, - contents: { - 'address.gts': { Address }, - 'person.gts': { Person }, - 'Person/fadhlan.json': new Person({ - firstName: 'Fadhlan', - address: new Address({ - city: 'Bandung', - country: 'Indonesia', - }), - }), - '.realm.json': `{ "name": "${realmName}" }`, - }, - }); + return {}; + }, + }); - createAndJoinRoom({ - sender: '@testuser:localhost', - name: 'room-test', - }); + let noop = () => {}; + + hooks.beforeEach(async function () { + operatorModeStateService = getService('operator-mode-state-service'); }); function setCardInOperatorModeState( diff --git a/packages/host/tests/integration/components/ai-assistant-panel/commands-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/commands-test.gts index 4e1442a0d0..1d1d9c6e98 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/commands-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/commands-test.gts @@ -6,9 +6,6 @@ import { getService } from '@universal-ember/test-support'; import { module, test } from 'qunit'; -import { baseRealm } from '@cardstack/runtime-common'; -import { Loader } from '@cardstack/runtime-common/loader'; - import { APP_BOXEL_COMMAND_REQUESTS_KEY, APP_BOXEL_COMMAND_RESULT_EVENT_TYPE, @@ -25,7 +22,6 @@ import type OperatorModeStateService from '@cardstack/host/services/operator-mod import { percySnapshot, testRealmURL, - setupCardLogs, setupIntegrationTestRealm, setupLocalIndexing, setupOnSave, @@ -49,7 +45,6 @@ import { setupRenderingTest } from '../../../helpers/setup'; module('Integration | ai-assistant-panel | commands', function (hooks) { const realmName = 'Operator Mode Workspace'; - let loader: Loader; let operatorModeStateService: OperatorModeStateService; setupRenderingTest(hooks); @@ -70,138 +65,150 @@ module('Integration | ai-assistant-panel | commands', function (hooks) { let { createAndJoinRoom, simulateRemoteMessage, getRoomEvents } = mockMatrixUtils; - let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { + let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - return { loader }; + class Pet extends CardDef { + static displayName = 'Pet'; + @field name = contains(StringField); + @field title = contains(StringField, { + computeVia: function (this: Pet) { + return this.name; + }, + }); + static fitted = class Fitted extends Component { + + }; + } + + class Address extends FieldDef { + static displayName = 'Address'; + @field city = contains(StringField); + @field country = contains(StringField); + static embedded = class Embedded extends Component { + + }; + } + + class Person extends CardDef { + static displayName = 'Person'; + @field firstName = contains(StringField); + @field pet = linksTo(Pet); + @field friends = linksToMany(Pet); + @field firstLetterOfTheName = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName[0]; + }, + }); + @field title = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName; + }, + }); + @field address = contains(Address); + static isolated = class Isolated extends Component { + + }; + static fitted = class Fitted extends Component { + + }; + } + + await setupIntegrationTestRealm({ + mockMatrixUtils, + contents: { + 'pet.gts': { Pet }, + 'address.gts': { Address }, + 'person.gts': { Person }, + 'Person/fadhlan.json': new Person({ + firstName: 'Fadhlan', + address: new Address({ + city: 'Bandung', + country: 'Indonesia', + }), + }), + 'Person/burcu.json': new Person({ + firstName: 'Burcu', + address: new Address({ + city: 'Istanbul', + country: 'Turkey', + }), + pet: new Pet({ + name: 'Lion', + }), + friends: [new Pet({ name: 'Tiger' }), new Pet({ name: 'Bear' })], + }), + 'Person/mickey.json': new Person({ + firstName: 'Mickey', + address: new Address({ + city: 'Paris', + country: 'France', + }), + friends: [new Pet({ name: 'Donald' })], + }), + 'Person/justin.json': new Person({ firstName: 'Justin' }), + 'Person/ian.json': new Person({ firstName: 'Ian' }), + 'Person/matic.json': new Person({ firstName: 'Matic' }), + 'Person/buck.json': new Person({ firstName: 'Buck' }), + 'Person/hassan.json': new Person({ firstName: 'Hassan' }), + '.realm.json': `{ "name": "${realmName}" }`, + }, + }); + + createAndJoinRoom({ + sender: '@testuser:localhost', + name: 'room-test', + }); + + return {}; }, }); setupOnSave(hooks); - setupCardLogs( - hooks, - async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), - ); let noop = () => {}; hooks.beforeEach(async function () { - ({ loader } = snapshot.get()); operatorModeStateService = getService('operator-mode-state-service'); - - class Pet extends CardDef { - static displayName = 'Pet'; - @field name = contains(StringField); - @field title = contains(StringField, { - computeVia: function (this: Pet) { - return this.name; - }, - }); - static fitted = class Fitted extends Component { - - }; - } - - class Address extends FieldDef { - static displayName = 'Address'; - @field city = contains(StringField); - @field country = contains(StringField); - static embedded = class Embedded extends Component { - - }; - } - - class Person extends CardDef { - static displayName = 'Person'; - @field firstName = contains(StringField); - @field pet = linksTo(Pet); - @field friends = linksToMany(Pet); - @field firstLetterOfTheName = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName[0]; - }, - }); - @field title = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName; - }, - }); - @field address = contains(Address); - static isolated = class Isolated extends Component { - - }; - } - - let petMango = new Pet({ name: 'Mango' }); - let petJackie = new Pet({ name: 'Jackie' }); - - await setupIntegrationTestRealm({ - mockMatrixUtils, - contents: { - 'address.gts': { Address }, - 'hello.txt': 'Hello, world!', - 'person.gts': { Person }, - 'pet.gts': { Pet }, - 'Pet/mango.json': petMango, - 'Pet/jackie.json': petJackie, - 'Person/fadhlan.json': new Person({ - firstName: 'Fadhlan', - address: new Address({ - city: 'Bandung', - country: 'Indonesia', - }), - pet: petMango, - }), - 'Person/burcu.json': new Person({ - firstName: 'Burcu', - friends: [petJackie, petMango], - }), - 'Person/mickey.json': new Person({ - firstName: 'Mickey', - }), - 'Person/justin.json': new Person({ firstName: 'Justin' }), - 'Person/ian.json': new Person({ firstName: 'Ian' }), - 'Person/matic.json': new Person({ firstName: 'Matic' }), - 'Person/buck.json': new Person({ firstName: 'Buck' }), - 'Person/hassan.json': new Person({ firstName: 'Hassan' }), - '.realm.json': `{ "name": "${realmName}" }`, - }, - }); }); function setCardInOperatorModeState( @@ -706,7 +713,6 @@ module('Integration | ai-assistant-panel | commands', function (hooks) { assert .dom('[data-test-message-idx="0"] [data-test-boxel-card-header-title]') .containsText('Search Results'); - assert.dom('.result-list li').exists({ count: 2 }); assert.dom('.result-list li:nth-child(1)').containsText('Jackie'); diff --git a/packages/host/tests/integration/components/ai-assistant-panel/debug-message-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/debug-message-test.gts index bb154b192d..b712e857ec 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/debug-message-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/debug-message-test.gts @@ -6,10 +6,6 @@ import { getService } from '@universal-ember/test-support'; import { module, test } from 'qunit'; -import { baseRealm } from '@cardstack/runtime-common'; - -import { Loader } from '@cardstack/runtime-common/loader'; - import { APP_BOXEL_DEBUG_MESSAGE_EVENT_TYPE, APP_BOXEL_MESSAGE_MSGTYPE, @@ -25,7 +21,6 @@ import type { CardMessageContent } from 'https://cardstack.com/base/matrix-event import { testRealmURL, - setupCardLogs, setupIntegrationTestRealm, setupLocalIndexing, setupOnSave, @@ -38,7 +33,6 @@ import { setupRenderingTest } from '../../../helpers/setup'; module('Integration | ai-assistant-panel | debug-message', function (hooks) { const realmName = 'Debug Message Test Realm'; - let loader: Loader; let operatorModeStateService: OperatorModeStateService; setupRenderingTest(hooks); @@ -56,33 +50,25 @@ module('Integration | ai-assistant-panel | debug-message', function (hooks) { let { simulateRemoteMessage } = mockMatrixUtils; - let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { + let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - return { loader }; + await setupIntegrationTestRealm({ + mockMatrixUtils, + contents: { + '.realm.json': `{ "name": "${realmName}" }`, + }, + }); + return {}; }, }); setupOnSave(hooks); - setupCardLogs( - hooks, - async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), - ); hooks.beforeEach(async function () { - ({ loader } = snapshot.get()); operatorModeStateService = this.owner.lookup( 'service:operator-mode-state-service', ) as OperatorModeStateService; - - await setupIntegrationTestRealm({ - mockMatrixUtils, - contents: { - '.realm.json': `{ "name": "${realmName}" }`, - }, - }); }); function setCardInOperatorModeState( diff --git a/packages/host/tests/integration/components/ai-assistant-panel/general-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/general-test.gts index 6f7ac1b8ea..246d3739ea 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/general-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/general-test.gts @@ -15,9 +15,6 @@ import { format, subMinutes } from 'date-fns'; import { module, test } from 'qunit'; -import { baseRealm } from '@cardstack/runtime-common'; -import { Loader } from '@cardstack/runtime-common/loader'; - import { APP_BOXEL_COMMAND_REQUESTS_KEY, APP_BOXEL_CONTINUATION_OF_CONTENT_KEY, @@ -35,7 +32,6 @@ import type OperatorModeStateService from '@cardstack/host/services/operator-mod import { percySnapshot, testRealmURL, - setupCardLogs, setupIntegrationTestRealm, setupLocalIndexing, setupOnSave, @@ -62,7 +58,6 @@ import { setupRenderingTest } from '../../../helpers/setup'; module('Integration | ai-assistant-panel | general', function (hooks) { const realmName = 'Operator Mode Workspace'; - let loader: Loader; let operatorModeStateService: OperatorModeStateService; let localPersistenceService: LocalPersistenceService; @@ -93,22 +88,103 @@ module('Integration | ai-assistant-panel | general', function (hooks) { getRoomEvents, } = mockMatrixUtils; - let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { + let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - return { loader }; - }, - }); + class Pet extends CardDef { + static displayName = 'Pet'; + @field name = contains(StringField); + @field title = contains(StringField, { + computeVia: function (this: Pet) { + return this.name; + }, + }); + static fitted = class Fitted extends Component { + + }; + } - setupCardLogs( - hooks, - async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), - ); + class Address extends FieldDef { + static displayName = 'Address'; + @field city = contains(StringField); + @field country = contains(StringField); + static embedded = class Embedded extends Component { + + }; + } - hooks.beforeEach(function () { - ({ loader } = snapshot.get()); + class Person extends CardDef { + static displayName = 'Person'; + @field firstName = contains(StringField); + @field pet = linksTo(Pet); + @field friends = linksToMany(Pet); + @field firstLetterOfTheName = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName[0]; + }, + }); + @field title = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName; + }, + }); + @field address = contains(Address); + static isolated = class Isolated extends Component { + + }; + } + + let petMango = new Pet({ name: 'Mango' }); + + await setupIntegrationTestRealm({ + mockMatrixUtils, + contents: { + 'pet.gts': { Pet }, + 'address.gts': { Address }, + 'person.gts': { Person }, + 'Pet/mango.json': petMango, + 'Person/fadhlan.json': new Person({ + firstName: 'Fadhlan', + address: new Address({ + city: 'Bandung', + country: 'Indonesia', + }), + pet: petMango, + }), + 'example-file.gts': ` + @field name = contains(StringField); + `, + '.realm.json': `{ "name": "${realmName}" }`, + }, + }); + + return {}; + }, }); // Setup realm server endpoints for summarization tests @@ -194,98 +270,6 @@ module('Integration | ai-assistant-panel | general', function (hooks) { hooks.beforeEach(async function () { operatorModeStateService = getService('operator-mode-state-service'); localPersistenceService = getService('local-persistence-service'); - - class Pet extends CardDef { - static displayName = 'Pet'; - @field name = contains(StringField); - @field title = contains(StringField, { - computeVia: function (this: Pet) { - return this.name; - }, - }); - static fitted = class Fitted extends Component { - - }; - } - - class Address extends FieldDef { - static displayName = 'Address'; - @field city = contains(StringField); - @field country = contains(StringField); - static embedded = class Embedded extends Component { - - }; - } - - class Person extends CardDef { - static displayName = 'Person'; - @field firstName = contains(StringField); - @field pet = linksTo(Pet); - @field friends = linksToMany(Pet); - @field firstLetterOfTheName = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName[0]; - }, - }); - @field title = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName; - }, - }); - @field address = contains(Address); - static isolated = class Isolated extends Component { - - }; - } - - let petMango = new Pet({ name: 'Mango' }); - - await setupIntegrationTestRealm({ - mockMatrixUtils, - contents: { - 'pet.gts': { Pet }, - 'address.gts': { Address }, - 'person.gts': { Person }, - 'Pet/mango.json': petMango, - 'Person/fadhlan.json': new Person({ - firstName: 'Fadhlan', - address: new Address({ - city: 'Bandung', - country: 'Indonesia', - }), - pet: petMango, - }), - 'example-file.gts': ` - @field name = contains(StringField); - `, - '.realm.json': `{ "name": "${realmName}" }`, - }, - }); }); function setCardInOperatorModeState( diff --git a/packages/host/tests/integration/components/ai-assistant-panel/past-sessions-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/past-sessions-test.gts index e90d9946e6..5751a5589e 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/past-sessions-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/past-sessions-test.gts @@ -5,9 +5,6 @@ import { getService } from '@universal-ember/test-support'; import { module, test } from 'qunit'; -import { baseRealm } from '@cardstack/runtime-common'; -import { Loader } from '@cardstack/runtime-common/loader'; - import { APP_BOXEL_MESSAGE_MSGTYPE } from '@cardstack/runtime-common/matrix-constants'; import OperatorMode from '@cardstack/host/components/operator-mode/container'; @@ -16,7 +13,6 @@ import type OperatorModeStateService from '@cardstack/host/services/operator-mod import { testRealmURL, - setupCardLogs, setupIntegrationTestRealm, setupLocalIndexing, setupOnSave, @@ -39,7 +35,6 @@ import { setupRenderingTest } from '../../../helpers/setup'; module('Integration | ai-assistant-panel | past sessions', function (hooks) { const realmName = 'Operator Mode Workspace'; - let loader: Loader; let operatorModeStateService: OperatorModeStateService; setupRenderingTest(hooks); @@ -59,114 +54,107 @@ module('Integration | ai-assistant-panel | past sessions', function (hooks) { let { createAndJoinRoom, simulateRemoteMessage } = mockMatrixUtils; - let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { + let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - return { loader }; + class Pet extends CardDef { + static displayName = 'Pet'; + @field name = contains(StringField); + @field title = contains(StringField, { + computeVia: function (this: Pet) { + return this.name; + }, + }); + static fitted = class Fitted extends Component { + + }; + } + + class Address extends FieldDef { + static displayName = 'Address'; + @field city = contains(StringField); + @field country = contains(StringField); + static embedded = class Embedded extends Component { + + }; + } + class Person extends CardDef { + static displayName = 'Person'; + @field firstName = contains(StringField); + @field pet = linksTo(Pet); + @field friends = linksToMany(Pet); + @field firstLetterOfTheName = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName[0]; + }, + }); + @field title = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName; + }, + }); + @field address = contains(Address); + static isolated = class Isolated extends Component { + + }; + } + + let petMango = new Pet({ name: 'Mango' }); + + await setupIntegrationTestRealm({ + mockMatrixUtils, + contents: { + 'pet.gts': { Pet }, + 'address.gts': { Address }, + 'person.gts': { Person }, + 'Pet/mango.json': petMango, + 'Person/fadhlan.json': new Person({ + firstName: 'Fadhlan', + address: new Address({ + city: 'Bandung', + country: 'Indonesia', + }), + pet: petMango, + }), + '.realm.json': `{ "name": "${realmName}" }`, + }, + }); + + return {}; }, }); setupOnSave(hooks); - setupCardLogs( - hooks, - async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), - ); let noop = () => {}; hooks.beforeEach(async function () { - ({ loader } = snapshot.get()); operatorModeStateService = getService('operator-mode-state-service'); - - class Pet extends CardDef { - static displayName = 'Pet'; - @field name = contains(StringField); - @field title = contains(StringField, { - computeVia: function (this: Pet) { - return this.name; - }, - }); - static fitted = class Fitted extends Component { - - }; - } - - class Address extends FieldDef { - static displayName = 'Address'; - @field city = contains(StringField); - @field country = contains(StringField); - static embedded = class Embedded extends Component { - - }; - } - class Person extends CardDef { - static displayName = 'Person'; - @field firstName = contains(StringField); - @field pet = linksTo(Pet); - @field friends = linksToMany(Pet); - @field firstLetterOfTheName = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName[0]; - }, - }); - @field title = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName; - }, - }); - @field address = contains(Address); - static isolated = class Isolated extends Component { - - }; - } - - let petMango = new Pet({ name: 'Mango' }); - - await setupIntegrationTestRealm({ - mockMatrixUtils, - contents: { - 'pet.gts': { Pet }, - 'address.gts': { Address }, - 'person.gts': { Person }, - 'Pet/mango.json': petMango, - 'Person/fadhlan.json': new Person({ - firstName: 'Fadhlan', - address: new Address({ - city: 'Bandung', - country: 'Indonesia', - }), - pet: petMango, - }), - '.realm.json': `{ "name": "${realmName}" }`, - }, - }); }); function setCardInOperatorModeState( diff --git a/packages/host/tests/integration/components/ai-assistant-panel/reasoning-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/reasoning-test.gts index 7c13ae1bcc..10e72bfa37 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/reasoning-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/reasoning-test.gts @@ -6,9 +6,6 @@ import { getService } from '@universal-ember/test-support'; import { module, test } from 'qunit'; -import { baseRealm } from '@cardstack/runtime-common'; -import { Loader } from '@cardstack/runtime-common/loader'; - import { APP_BOXEL_REASONING_CONTENT_KEY } from '@cardstack/runtime-common/matrix-constants'; import OperatorMode from '@cardstack/host/components/operator-mode/container'; @@ -17,7 +14,6 @@ import type OperatorModeStateService from '@cardstack/host/services/operator-mod import { testRealmURL, - setupCardLogs, setupIntegrationTestRealm, setupLocalIndexing, setupOnSave, @@ -37,7 +33,6 @@ import { setupRenderingTest } from '../../../helpers/setup'; module('Integration | ai-assistant-panel | reasoning', function (hooks) { const realmName = 'Operator Mode Workspace'; - let loader: Loader; let operatorModeStateService: OperatorModeStateService; setupRenderingTest(hooks); @@ -57,62 +52,55 @@ module('Integration | ai-assistant-panel | reasoning', function (hooks) { let { simulateRemoteMessage } = mockMatrixUtils; - let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { + let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - return { loader }; + class Person extends CardDef { + static displayName = 'Person'; + @field firstName = contains(StringField); + @field firstLetterOfTheName = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName[0]; + }, + }); + @field title = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName; + }, + }); + static isolated = class Isolated extends Component { + + }; + } + + await setupIntegrationTestRealm({ + mockMatrixUtils, + contents: { + 'person.gts': { Person }, + 'Person/fadhlan.json': new Person({ + firstName: 'Fadhlan', + }), + '.realm.json': `{ "name": "${realmName}" }`, + }, + }); + + return {}; }, }); setupOnSave(hooks); - setupCardLogs( - hooks, - async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), - ); let noop = () => {}; hooks.beforeEach(async function () { - ({ loader } = snapshot.get()); operatorModeStateService = getService('operator-mode-state-service'); - - class Person extends CardDef { - static displayName = 'Person'; - @field firstName = contains(StringField); - @field firstLetterOfTheName = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName[0]; - }, - }); - @field title = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName; - }, - }); - static isolated = class Isolated extends Component { - - }; - } - - await setupIntegrationTestRealm({ - mockMatrixUtils, - contents: { - 'person.gts': { Person }, - 'Person/fadhlan.json': new Person({ - firstName: 'Fadhlan', - }), - '.realm.json': `{ "name": "${realmName}" }`, - }, - }); }); function setCardInOperatorModeState( diff --git a/packages/host/tests/integration/components/ai-assistant-panel/scrolling-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/scrolling-test.gts index 6ebf9f6d27..0a3b8608f3 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/scrolling-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/scrolling-test.gts @@ -6,9 +6,6 @@ import { getService } from '@universal-ember/test-support'; import { module, test } from 'qunit'; -import { baseRealm } from '@cardstack/runtime-common'; -import { Loader } from '@cardstack/runtime-common/loader'; - import { APP_BOXEL_MESSAGE_MSGTYPE } from '@cardstack/runtime-common/matrix-constants'; import { BOTTOM_THRESHOLD } from '@cardstack/host/components/ai-assistant/message'; @@ -18,7 +15,6 @@ import type OperatorModeStateService from '@cardstack/host/services/operator-mod import { testRealmURL, - setupCardLogs, setupIntegrationTestRealm, setupLocalIndexing, setupOnSave, @@ -38,7 +34,6 @@ import { setupRenderingTest } from '../../../helpers/setup'; module('Integration | ai-assistant-panel | scrolling', function (hooks) { const realmName = 'Operator Mode Workspace'; - let loader: Loader; let operatorModeStateService: OperatorModeStateService; setupRenderingTest(hooks); @@ -59,62 +54,55 @@ module('Integration | ai-assistant-panel | scrolling', function (hooks) { let { createAndJoinRoom, simulateRemoteMessage, setReadReceipt } = mockMatrixUtils; - let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { + let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - return { loader }; + class Person extends CardDef { + static displayName = 'Person'; + @field firstName = contains(StringField); + @field firstLetterOfTheName = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName[0]; + }, + }); + @field title = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName; + }, + }); + static isolated = class Isolated extends Component { + + }; + } + + await setupIntegrationTestRealm({ + mockMatrixUtils, + contents: { + 'person.gts': { Person }, + 'Person/fadhlan.json': new Person({ + firstName: 'Fadhlan', + }), + '.realm.json': `{ "name": "${realmName}" }`, + }, + }); + + return {}; }, }); setupOnSave(hooks); - setupCardLogs( - hooks, - async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), - ); let noop = () => {}; hooks.beforeEach(async function () { - ({ loader } = snapshot.get()); operatorModeStateService = getService('operator-mode-state-service'); - - class Person extends CardDef { - static displayName = 'Person'; - @field firstName = contains(StringField); - @field firstLetterOfTheName = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName[0]; - }, - }); - @field title = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName; - }, - }); - static isolated = class Isolated extends Component { - - }; - } - - await setupIntegrationTestRealm({ - mockMatrixUtils, - contents: { - 'person.gts': { Person }, - 'Person/fadhlan.json': new Person({ - firstName: 'Fadhlan', - }), - '.realm.json': `{ "name": "${realmName}" }`, - }, - }); }); function setCardInOperatorModeState( diff --git a/packages/host/tests/integration/components/ai-assistant-panel/sending-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/sending-test.gts index 190c094588..fe61f7d255 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/sending-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/sending-test.gts @@ -13,9 +13,6 @@ import { getService } from '@universal-ember/test-support'; import window from 'ember-window-mock'; import { module, test } from 'qunit'; -import { baseRealm } from '@cardstack/runtime-common'; -import { Loader } from '@cardstack/runtime-common/loader'; - import OperatorMode from '@cardstack/host/components/operator-mode/container'; import { Submodes } from '@cardstack/host/components/submode-switcher'; @@ -45,7 +42,6 @@ import { setupRenderingTest } from '../../../helpers/setup'; module('Integration | ai-assistant-panel | sending', function (hooks) { const realmName = 'Operator Mode Workspace'; - let loader: Loader; let operatorModeStateService: OperatorModeStateService; setupRenderingTest(hooks); @@ -63,62 +59,54 @@ module('Integration | ai-assistant-panel | sending', function (hooks) { })(), }); - let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { + let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - return { loader }; + class Person extends CardDef { + static displayName = 'Person'; + @field firstName = contains(StringField); + @field firstLetterOfTheName = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName[0]; + }, + }); + @field title = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName; + }, + }); + static isolated = class Isolated extends Component { + + }; + } + + await setupIntegrationTestRealm({ + mockMatrixUtils, + contents: { + 'person.gts': { Person }, + 'Person/fadhlan.json': new Person({ + firstName: 'Fadhlan', + }), + '.realm.json': `{ "name": "${realmName}" }`, + }, + }); + + return {}; }, }); setupOnSave(hooks); - setupCardLogs( - hooks, - async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), - ); - let noop = () => {}; hooks.beforeEach(async function () { - ({ loader } = snapshot.get()); operatorModeStateService = getService('operator-mode-state-service'); - - class Person extends CardDef { - static displayName = 'Person'; - @field firstName = contains(StringField); - @field firstLetterOfTheName = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName[0]; - }, - }); - @field title = contains(StringField, { - computeVia: function (this: Person) { - return this.firstName; - }, - }); - static isolated = class Isolated extends Component { - - }; - } - - await setupIntegrationTestRealm({ - mockMatrixUtils, - contents: { - 'person.gts': { Person }, - 'Person/fadhlan.json': new Person({ - firstName: 'Fadhlan', - }), - '.realm.json': `{ "name": "${realmName}" }`, - }, - }); }); function setCardInOperatorModeState( diff --git a/packages/host/tests/integration/components/ai-assistant-panel/skills-test.gts b/packages/host/tests/integration/components/ai-assistant-panel/skills-test.gts index 096d89c29b..4711a9edc0 100644 --- a/packages/host/tests/integration/components/ai-assistant-panel/skills-test.gts +++ b/packages/host/tests/integration/components/ai-assistant-panel/skills-test.gts @@ -10,10 +10,8 @@ import { REPLACE_MARKER, SEARCH_MARKER, SEPARATOR_MARKER, - baseRealm, skillCardRef, } from '@cardstack/runtime-common'; -import { Loader } from '@cardstack/runtime-common/loader'; import { APP_BOXEL_COMMAND_REQUESTS_KEY, @@ -29,7 +27,6 @@ import { FileDef } from 'https://cardstack.com/base/file-api'; import { testRealmURL, - setupCardLogs, setupIntegrationTestRealm, setupLocalIndexing, setupOnSave, @@ -54,7 +51,6 @@ import { setupRenderingTest } from '../../../helpers/setup'; module('Integration | ai-assistant-panel | skills', function (hooks) { const realmName = 'Operator Mode Workspace'; - let loader: Loader; let operatorModeStateService: OperatorModeStateService; setupRenderingTest(hooks); @@ -74,20 +70,127 @@ module('Integration | ai-assistant-panel | skills', function (hooks) { let { getRoomState, getRoomEvents, simulateRemoteMessage } = mockMatrixUtils; - let snapshot = setupSnapshotRealm<{ loader: Loader }>(hooks, { + let snapshot = setupSnapshotRealm(hooks, { mockMatrixUtils, async build({ loader }) { - let loaderService = getService('loader-service'); - loaderService.loader = loader; - return { loader }; + class Pet extends CardDef { + static displayName = 'Pet'; + @field name = contains(StringField); + @field title = contains(StringField, { + computeVia: function (this: Pet) { + return this.name; + }, + }); + static fitted = class Fitted extends Component { + + }; + } + + class Address extends FieldDef { + static displayName = 'Address'; + @field city = contains(StringField); + @field country = contains(StringField); + static embedded = class Embedded extends Component { + + }; + } + + class Person extends CardDef { + static displayName = 'Person'; + @field firstName = contains(StringField); + @field pet = linksTo(Pet); + @field friends = linksToMany(Pet); + @field firstLetterOfTheName = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName[0]; + }, + }); + @field title = contains(StringField, { + computeVia: function (this: Person) { + return this.firstName; + }, + }); + @field address = contains(Address); + static isolated = class Isolated extends Component { + + }; + } + + await setupIntegrationTestRealm({ + mockMatrixUtils, + contents: { + 'pet.gts': { Pet }, + 'address.gts': { Address }, + 'person.gts': { Person }, + 'Person/fadhlan.json': new Person({ + firstName: 'Fadhlan', + address: new Address({ + city: 'Bandung', + country: 'Indonesia', + }), + pet: new Pet({ + name: 'Lion', + }), + friends: [new Pet({ name: 'Tiger' }), new Pet({ name: 'Bear' })], + }), + 'Person/burcu.json': new Person({ + firstName: 'Burcu', + address: new Address({ + city: 'Istanbul', + country: 'Turkey', + }), + pet: new Pet({ + name: 'Lion', + }), + friends: [new Pet({ name: 'Tiger' }), new Pet({ name: 'Bear' })], + }), + 'Person/mickey.json': new Person({ + firstName: 'Mickey', + address: new Address({ + city: 'Paris', + country: 'France', + }), + friends: [new Pet({ name: 'Donald' })], + }), + 'Person/justin.json': new Person({ firstName: 'Justin' }), + 'Person/ian.json': new Person({ firstName: 'Ian' }), + 'Person/matic.json': new Person({ firstName: 'Matic' }), + 'Person/buck.json': new Person({ firstName: 'Buck' }), + 'Person/hassan.json': new Person({ firstName: 'Hassan' }), + '.realm.json': `{ "name": "${realmName}" }`, + }, + }); + + return {}; }, }); setupOnSave(hooks); - setupCardLogs( - hooks, - async () => await snapshot.get().loader.import(`${baseRealm.url}card-api`), - ); let noop = () => {}; From c9707bf5db2a1b2c43b80e6eb78f71626d8a6744 Mon Sep 17 00:00:00 2001 From: Ian Calvert Date: Tue, 16 Dec 2025 11:39:40 +0000 Subject: [PATCH 17/17] Cut shards down in half now its faster --- .github/workflows/ci-host.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-host.yaml b/.github/workflows/ci-host.yaml index 7252b23aeb..b6bd6f9ade 100644 --- a/.github/workflows/ci-host.yaml +++ b/.github/workflows/ci-host.yaml @@ -31,8 +31,8 @@ jobs: strategy: fail-fast: false matrix: - shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] - shardTotal: [16] + shardIndex: [1, 2, 3, 4, 5, 6, 7, 8] + shardTotal: [8] concurrency: group: boxel-host-test${{ github.head_ref || github.run_id }}-shard${{ matrix.shardIndex }} cancel-in-progress: true