mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
test(runtime): consolidate Inspector and reconciliation coverage
This commit is contained in:
1 parent
025df6ec30
commit
69e263b0b1
8 files changed
+1269
-1250
No files matched your search
@@ -3,35 +3,47 @@ import { reconcileJavaScriptRuntimeEvidence } from "../../../src/application/jav
|
||||
import { javascriptRuntimeReconciliationResultSchema } from "../../../src/domain/javascript/javascriptRuntimeReconciliationSchemas.js";
|
||||
import { nodeReconciliationFixture } from "../../fixtures/nodeRuntimeReconciliation.js";
|
||||
|
||||
test.each([false, true])(
|
||||
"matches a synthetic Node entry target without inventing script presence: %s",
|
||||
(scriptObserved) => {
|
||||
const reconciled = reconcileJavaScriptRuntimeEvidence(
|
||||
nodeReconciliationFixture(scriptObserved),
|
||||
);
|
||||
if (!reconciled.ok) throw reconciled.error;
|
||||
const result = javascriptRuntimeReconciliationResultSchema.parse(
|
||||
reconciled.value.evidence.normalized_result,
|
||||
);
|
||||
const target = result.reconciliations.find(
|
||||
({ entity_kind }) => entity_kind === "target",
|
||||
);
|
||||
expect(target).toMatchObject({
|
||||
status: "matched",
|
||||
basis: "artifact-path",
|
||||
confidence: "medium",
|
||||
reason: "unique-location-match",
|
||||
candidate_static_count: 1,
|
||||
});
|
||||
expect(
|
||||
result.graph.nodes.find(
|
||||
({ node_id }) => node_id === target?.static_node_id,
|
||||
)?.kind,
|
||||
).toBe("javascript-asset");
|
||||
expect(result.summary).toMatchObject({
|
||||
runtime_scripts: scriptObserved ? 1 : 0,
|
||||
static_loaded: scriptObserved ? 1 : 0,
|
||||
static_not_observed: 0,
|
||||
});
|
||||
},
|
||||
);
|
||||
test("attributes loaded script state to the reported Node script", () => {
|
||||
const reconciled = reconcileJavaScriptRuntimeEvidence(
|
||||
nodeReconciliationFixture(true),
|
||||
);
|
||||
if (!reconciled.ok) throw reconciled.error;
|
||||
const result = javascriptRuntimeReconciliationResultSchema.parse(
|
||||
reconciled.value.evidence.normalized_result,
|
||||
);
|
||||
const asset = result.graph.nodes.find(
|
||||
({ kind, observations }) =>
|
||||
kind === "javascript-asset" &&
|
||||
observations.some(({ properties }) => properties.path === "renderer.js"),
|
||||
);
|
||||
if (asset === undefined) throw new Error("Missing fixture renderer asset");
|
||||
const target = result.reconciliations.find(
|
||||
({ entity_kind }) => entity_kind === "target",
|
||||
);
|
||||
const script = result.reconciliations.find(
|
||||
({ entity_kind }) => entity_kind === "script",
|
||||
);
|
||||
expect(target).toMatchObject({
|
||||
status: "matched",
|
||||
static_node_id: asset.node_id,
|
||||
});
|
||||
expect(script).toMatchObject({
|
||||
status: "matched",
|
||||
static_node_id: asset.node_id,
|
||||
});
|
||||
expect(script?.runtime_node_id).not.toBe(target?.runtime_node_id);
|
||||
expect(
|
||||
result.static_load_states.find(
|
||||
({ static_node_id }) => static_node_id === asset.node_id,
|
||||
),
|
||||
).toMatchObject({
|
||||
status: "loaded",
|
||||
reason: "runtime-script-correspondence",
|
||||
runtime_node_ids: [script?.runtime_node_id],
|
||||
});
|
||||
expect(result.summary).toMatchObject({
|
||||
runtime_scripts: 1,
|
||||
static_loaded: 1,
|
||||
static_not_observed: 0,
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user