Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions commands/listing-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function buildInstanceOperation(
delete (doc as any).data.id;
delete (doc as any).included;
let cardResource = (doc as any).data as LooseCardResource;
cardResource.meta.adoptsFrom = copyInstanceMeta.targetCodeRef;
let href = join(realmIdentifier, copyInstanceMeta.lid) + '.json';
return { op: 'add', href, data: cardResource };
}
Expand Down
8 changes: 4 additions & 4 deletions tests/helpers/test-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,10 @@ export function makeMockCatalogContents(
self: pirateSkillId,
},
},
},
'categories.0': {
links: {
self: writingCategoryId,
'categories.0': {
links: {
self: writingCategoryId,
},
},
},
meta: {
Expand Down
28 changes: 26 additions & 2 deletions tests/live/catalog-app/listing-install.test.gts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { getService } from '@universal-ember/test-support';
import { module, test } from 'qunit';

import { identifyCard, isResolvedCodeRef } from '@cardstack/runtime-common';

import ListingInstallCommand from '../../../commands/listing-install';

import type { CardDef } from 'https://cardstack.com/base/card-api';
Expand Down Expand Up @@ -38,7 +40,7 @@ const authorListingId = `${mockCatalogURL}Listing/author`;
const blogPostListingId = `${mockCatalogURL}Listing/blog-post`;

export function runTests() {
module.skip(
module(
'Acceptance | Catalog | catalog app - listing install',
function (hooks) {
setupApplicationTest(hooks);
Expand Down Expand Up @@ -107,7 +109,7 @@ export function runTests() {
test('card listing', async function (assert) {
const listingName = 'author';

await executeCommand(
let result = await executeCommand(
ListingInstallCommand,
authorListingId,
testDestinationRealmURL,
Expand All @@ -128,6 +130,28 @@ export function runTests() {
let examplePath = `${outerFolder}${listingName}/Author/example.json`;
await openDir(assert, examplePath);
await verifyFileInFileTree(assert, examplePath);

// Author/example.json's own adoptsFrom is an absolute URL into
// the catalog realm (see makeMockCatalogContents), so this
// catches the install pipeline leaving the copied instance
// pointed at the source realm instead of rewriting it into the
// newly installed module.
let store = getService('store');
let installedCard = (await store.get(
result.exampleCardId as string,
)) as CardDef;
Comment on lines +139 to +142
let installedRef = identifyCard(installedCard.constructor);
if (!installedRef || !isResolvedCodeRef(installedRef)) {
throw new Error('expected a resolved code ref');
}
Comment on lines +143 to +146
assert.ok(
installedRef.module.startsWith(testDestinationRealmURL),
`installed card module "${installedRef.module}" resolves into the destination realm`,
);
assert.false(
installedRef.module.startsWith(mockCatalogURL),
`installed card module "${installedRef.module}" should not still point at the catalog realm`,
);
});

test('listing installs relationships of examples and its modules', async function (assert) {
Expand Down
Loading