35 lines
1.6 KiB
TypeScript
35 lines
1.6 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { loadReaderWorkspace } from "./reader-fixture.js";
|
|
import { compileExecutionPlan } from "../src/execution-world/index.js";
|
|
test("local relationship pages may reuse exactly the confirmed source window", async () => {
|
|
const workspace = await loadReaderWorkspace((name, text) => {
|
|
if (name === "queries/replica-inputs.graphql")
|
|
return text.replace("highlights(all: 1000)", "highlights(first: 10)");
|
|
if (name === "queries/reader-screen.graphql")
|
|
return text
|
|
.replace("ReaderScreen($color: String!)", "ReaderScreen")
|
|
.replace(
|
|
"highlights(all: 1000, where: {color: {eq: $color}}, orderBy: [{range: {start: ASC}}])",
|
|
"highlights(first: 10)",
|
|
)
|
|
.replace("_camino { relations { highlights { aggregate { count } } } }", "");
|
|
return text;
|
|
});
|
|
assert.doesNotThrow(() => compileExecutionPlan(workspace));
|
|
});
|
|
|
|
test("local workspace objects reads the exact server window without adding local candidates", async () => {
|
|
const load = (first: number) =>
|
|
loadReaderWorkspace((name, text) => {
|
|
if (name === "ReaderRuntime.qx") return text.replace(/^.*query HighlightList id.*$/m, "");
|
|
if (name === "queries/highlight-list.graphql")
|
|
return text.replace("availableObjects(all: 200", `objects(first: ${first}`);
|
|
return text;
|
|
});
|
|
const workspace = await load(2);
|
|
assert.doesNotThrow(() => compileExecutionPlan(workspace));
|
|
const wrong = await load(3);
|
|
assert.throws(() => compileExecutionPlan(wrong), /REPLICA_WINDOW_MISMATCH/);
|
|
});
|