All checks were successful
synthetic / suite (push) Successful in 1m2s
The connector maps native Q-ids to aliases under urn:ce ids, publishes only through the existing rights and reference gate, and leaves the real-user pilot open. Assistant: grok Assistant-Session: 01a15378-f601-7fe2-a143-8e1500a1d59c
37 lines
1.8 KiB
TypeScript
37 lines
1.8 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { entitySlug, findDataspace, findEntity, findKind } from "./catalog";
|
|
|
|
const directory = join(process.cwd(), "../examples/dataspaces/computing-basics");
|
|
|
|
describe("computing-basics catalog", () => {
|
|
it("reads kind labels and an entity title from the published dataspace", () => {
|
|
const snapshot = JSON.parse(readFileSync(join(directory, "snapshot.json"), "utf8")) as {
|
|
dataspace: { id: string; title: string };
|
|
kinds: { id: string; label: string }[];
|
|
entities: { id: string; kindId: string; title: string }[];
|
|
sources: { id: string; title: string; license: string }[];
|
|
};
|
|
const manifest = JSON.parse(readFileSync(join(directory, "manifest.json"), "utf8")) as {
|
|
kindViews: Record<string, { columns: string[] }>;
|
|
home: { featuredKinds: string[] };
|
|
};
|
|
const kindId = manifest.home.featuredKinds[0];
|
|
const declared = snapshot.kinds.find((kind) => kind.id === kindId);
|
|
const kind = findKind(snapshot.dataspace.id, kindId);
|
|
expect(declared).toBeTruthy();
|
|
expect(kind?.label).toBe(declared?.label);
|
|
expect(kind?.columns.map((column) => column.key)).toEqual(manifest.kindViews[kindId].columns);
|
|
|
|
const entity = snapshot.entities.find((item) => item.kindId === kindId);
|
|
expect(entity).toBeTruthy();
|
|
const view = findEntity(snapshot.dataspace.id, kindId, entitySlug(entity!.id, kindId));
|
|
const source = snapshot.sources[0];
|
|
expect(view?.title).toBe(entity?.title);
|
|
expect(
|
|
view?.sources.some((item) => item.title === source.title || item.license === source.license),
|
|
).toBe(true);
|
|
expect(findDataspace(snapshot.dataspace.id)?.title).toBe(snapshot.dataspace.title);
|
|
});
|
|
});
|