Implement independent presentation readiness boundaries
This commit is contained in:
@@ -62,6 +62,21 @@ test("imported fragments retain checked occurrences and require exact roots", as
|
||||
assert.equal(result.selection[0]!.selection[0]!.fragmentSpread?.digest, checked.definitionDigest);
|
||||
assert.equal(result.selection[0]!.selection[0]!.fragmentSpread?.root, item.revisionId);
|
||||
assert.ok(result.effects.some((e) => e.memberId === "title"));
|
||||
const bound = await compileQuery(
|
||||
{
|
||||
...consumer.queries![0]!,
|
||||
importedFragments: consumer.queries![0]!.importedFragments!.map((entry) => ({ ...entry, mode: "reference" })),
|
||||
},
|
||||
[item],
|
||||
async () => "query Screen {root {...Row}}",
|
||||
async () => checked,
|
||||
);
|
||||
assert.equal(bound.selection[0]!.selection.find((entry) => entry.fragmentSpread)?.fragmentSpread?.mode, "reference");
|
||||
assert(
|
||||
!bound.selection[0]!.selection.some((entry) => entry.memberId === "title"),
|
||||
"A fragment binding does not evaluate its fields in the parent",
|
||||
);
|
||||
assert(!JSON.stringify(bound.output).includes('"title"'), "Parent output excludes separately observed fields");
|
||||
const wrong = {
|
||||
...checked,
|
||||
declaration: {
|
||||
@@ -113,6 +128,39 @@ test("fragment variable mappings are explicit and checked", async () => {
|
||||
async () => checked,
|
||||
);
|
||||
assert.deepEqual(result.selection[0]!.selection[0]!.fragmentSpread?.variables, { show: "visible" });
|
||||
const referenceDeclaration = build("with {show to visible;}");
|
||||
referenceDeclaration.importedFragments = referenceDeclaration.importedFragments!.map((entry) => ({
|
||||
...entry,
|
||||
mode: "reference",
|
||||
}));
|
||||
const binding = await compileQuery(
|
||||
referenceDeclaration,
|
||||
[item],
|
||||
async () => document,
|
||||
async () => checked,
|
||||
);
|
||||
assert.deepEqual(binding.selection[0]!.selection[0]!.fragmentSpread?.variables, { show: "visible" });
|
||||
assert.notEqual(binding.definitionDigest, result.definitionDigest);
|
||||
await assert.rejects(
|
||||
compileQuery(
|
||||
referenceDeclaration,
|
||||
[item],
|
||||
async () => document.replace("$visible: Boolean!", "$visible: Boolean!, $unused: Boolean!"),
|
||||
async () => checked,
|
||||
),
|
||||
/never used/,
|
||||
);
|
||||
const changedDigest = await compileQuery(
|
||||
referenceDeclaration,
|
||||
[item],
|
||||
async () => document,
|
||||
async () => ({ ...checked, definitionDigest: "b".repeat(64) }),
|
||||
);
|
||||
assert.notEqual(
|
||||
changedDigest.definitionDigest,
|
||||
binding.definitionDigest,
|
||||
"A bound fragment's identity remains in the parent contract digest",
|
||||
);
|
||||
await assert.rejects(
|
||||
compileQuery(
|
||||
build("with {show to visible;}"),
|
||||
|
||||
Reference in New Issue
Block a user