Make local graph execution optional across composed packages
This commit is contained in:
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { compileQuery } from "../src/query/compile.js";
|
||||
import { linkQueries } from "../src/query/link.js";
|
||||
import { compileExecutionPlan } from "../src/execution-world/plan.js";
|
||||
import { loadReaderWorkspace as load, readReaderFixture as read } from "./reader-fixture.js";
|
||||
test("complete reader contracts compose factories, portable selectors, CRDT edits, and bounded query scopes", async () => {
|
||||
const workspace = await load();
|
||||
@@ -23,15 +24,19 @@ test("complete reader contracts compose factories, portable selectors, CRDT edit
|
||||
);
|
||||
});
|
||||
|
||||
test("reader composition reports the dependency that weakens a portable promise", async () => {
|
||||
await assert.rejects(
|
||||
load((name, text) =>
|
||||
name === "ReaderRuntime.qx"
|
||||
? text.replace(/(operation excerpt[\s\S]*?targets )\[browser, server\]/, "$1[server]")
|
||||
: text,
|
||||
),
|
||||
/does not provide execution target browser/,
|
||||
test("ordinary operations allow server fallback; explicitly local projections require local code", async () => {
|
||||
const serverExcerpt = await load((name, text) =>
|
||||
name === "ReaderRuntime.qx"
|
||||
? text.replace(/(operation excerpt[\s\S]*?targets )\[JavaScript, server\]/, "$1[server]")
|
||||
: text,
|
||||
);
|
||||
assert.throws(() => compileExecutionPlan(serverExcerpt), /NONPORTABLE_QUERY_FIELD/);
|
||||
for (const pkg of serverExcerpt.packageImports)
|
||||
pkg.queries = pkg.queries?.filter((q) => q.placement?.kind !== "local");
|
||||
const fallback = compileExecutionPlan(serverExcerpt).definition.operations.find(
|
||||
(op) => op.operationId === "highlight:excerpt:get",
|
||||
)!;
|
||||
assert.deepEqual(fallback.availableTargets, ["server"]);
|
||||
await assert.rejects(
|
||||
load((name, text) =>
|
||||
name === "ReaderRuntime.qx"
|
||||
@@ -56,6 +61,6 @@ test("a field can remain server-queryable while failing local query placement",
|
||||
await compileQuery(admission, workspace.interfaceImports, read);
|
||||
await assert.rejects(
|
||||
compileQuery(local, workspace.interfaceImports, read),
|
||||
/browser snapshot getter for HighlightData.color/,
|
||||
/graph snapshot getter for HighlightData.color/,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user