* refactor(test): colocate pure-domain tests and reduce test debt Move focused immutable domain/contracts/adapter tests from tests/composition/** beside their production owners under src/** as colocated *.test.ts/*.fixture.ts, and relocate persistence-shaped composition tests under tests/boundary/filesystem/**. Update import paths, the Vitest project topology (shared worker context for pure domain/contracts and recording-port service projects), the test migration ledger, testing docs, and AGENTS.md to match. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: remove test migration ledger The cutover is complete and the ledger is no longer referenced anywhere in source, scripts, or the docs gate. Drop the standalone artifact. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: clean up stale migration artifacts Remove empty directories left by the test migration and replace the "final cutover" language in docs/testing.md with standing PR guidance that no longer references the completed migration. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: repair CI failures from schema, knip, and stale generated artifacts Three root causes fixed: 1. catalog-schemas.mjs: valuesAt only traversed anyOf from Zod's toJSONSchema, not oneOf. The webScreenshotDiffSchema change to a discriminated union produces oneOf, so the product catalog generator could not derive the web_screenshot_diff schema version. Add oneOf traversal. 2. conformancePackage.ts: the test rewrite removed the only imports of ScenarioManifest, ReplayPlan, ShimPlan, and ExpectedEvidence, making them unused exports that knip flags. Remove the dead type aliases. 3. Regenerate stale artifacts (product catalog, MCP tool catalog, skill metadata, conformance manifest) that drifted from the source changes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
160 lines
4.8 KiB
TypeScript
160 lines
4.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
createJavaScriptApplicationEdge,
|
|
createJavaScriptApplicationGraph,
|
|
createJavaScriptApplicationNode,
|
|
type ApplicationNode,
|
|
type JavaScriptApplicationGraph,
|
|
} from "./javascriptApplicationGraph.js";
|
|
import {
|
|
APPLICATION_GRAPH_DIGESTS,
|
|
artifactEvidence,
|
|
buildSyntheticJavaScriptApplicationGraph,
|
|
inferredArtifactEvidence,
|
|
} from "./javascriptApplicationGraph.fixture.js";
|
|
|
|
const completeCoverage = {
|
|
status: "complete" as const,
|
|
truncated: false,
|
|
omitted_count: 0,
|
|
limits: [],
|
|
};
|
|
|
|
const nodeByLabel = (
|
|
graph: JavaScriptApplicationGraph,
|
|
label: string,
|
|
): ApplicationNode => {
|
|
const node = graph.nodes.find(({ observations }) =>
|
|
observations.some((observation) => observation.label === label),
|
|
);
|
|
if (node === undefined) throw new TypeError(`Missing fixture node: ${label}`);
|
|
return node;
|
|
};
|
|
|
|
const firstOf = <Value>(values: readonly Value[], label: string): Value => {
|
|
const value = values[0];
|
|
if (value === undefined) throw new TypeError(`Missing fixture ${label}`);
|
|
return value;
|
|
};
|
|
|
|
describe("JavaScript Application Graph", () => {
|
|
it("rejects duplicate nodes, missing roots, dangling edges, and self edges", () => {
|
|
const graph = buildSyntheticJavaScriptApplicationGraph();
|
|
const { graph_id: _graphId, ...semantic } = graph;
|
|
const source = firstOf(semantic.nodes, "node");
|
|
expect(() =>
|
|
createJavaScriptApplicationGraph({
|
|
...semantic,
|
|
nodes: [...semantic.nodes, source],
|
|
}),
|
|
).toThrow(/Nodes must be sorted and unique/u);
|
|
expect(() =>
|
|
createJavaScriptApplicationGraph({
|
|
...semantic,
|
|
root_node_ids: [`jag_node_${"9".repeat(64)}`],
|
|
}),
|
|
).toThrow(/Root identifier/u);
|
|
|
|
const missingId = `jag_node_${"9".repeat(64)}`;
|
|
const dangling = createJavaScriptApplicationEdge({
|
|
source_node_id: source.node_id,
|
|
target_node_id: missingId,
|
|
relation: "loads",
|
|
properties: {},
|
|
evidence: inferredArtifactEvidence(
|
|
APPLICATION_GRAPH_DIGESTS.asar,
|
|
"dist/main.js",
|
|
),
|
|
});
|
|
expect(() =>
|
|
createJavaScriptApplicationGraph({
|
|
...semantic,
|
|
edges: [...semantic.edges, dangling],
|
|
}),
|
|
).toThrow(/endpoints must name graph nodes/u);
|
|
|
|
const selfEdge = createJavaScriptApplicationEdge({
|
|
source_node_id: source.node_id,
|
|
target_node_id: source.node_id,
|
|
relation: "imports",
|
|
properties: {},
|
|
evidence: inferredArtifactEvidence(
|
|
APPLICATION_GRAPH_DIGESTS.asar,
|
|
"dist/main.js",
|
|
),
|
|
});
|
|
expect(() =>
|
|
createJavaScriptApplicationGraph({
|
|
...semantic,
|
|
edges: [...semantic.edges, selfEdge],
|
|
}),
|
|
).toThrow(/self-referential/u);
|
|
});
|
|
|
|
it("allows changed_from only between entities of the same kind", () => {
|
|
const graph = buildSyntheticJavaScriptApplicationGraph();
|
|
const preload = nodeByLabel(graph, "desktop preload");
|
|
const runtime = nodeByLabel(graph, "preload runtime script");
|
|
const earlierPreload = createJavaScriptApplicationNode({
|
|
kind: "electron-preload",
|
|
identity: {
|
|
strategy: "canonical-path",
|
|
stability: "artifact-version",
|
|
artifact_sha256: "7".repeat(64),
|
|
path: "dist/preload.js",
|
|
},
|
|
observations: [
|
|
{
|
|
label: "earlier preload",
|
|
properties: {},
|
|
evidence: artifactEvidence("7".repeat(64), "dist/preload.js"),
|
|
},
|
|
],
|
|
});
|
|
const changedFrom = createJavaScriptApplicationEdge({
|
|
source_node_id: preload.node_id,
|
|
target_node_id: earlierPreload.node_id,
|
|
relation: "changed_from",
|
|
properties: {},
|
|
evidence: inferredArtifactEvidence(
|
|
APPLICATION_GRAPH_DIGESTS.asar,
|
|
"dist/preload.js",
|
|
),
|
|
});
|
|
expect(
|
|
createJavaScriptApplicationGraph({
|
|
schema: "JavaScriptApplicationGraph",
|
|
schema_version: 1,
|
|
root_node_ids: [preload.node_id],
|
|
nodes: [preload, earlierPreload],
|
|
edges: [changedFrom],
|
|
coverage: completeCoverage,
|
|
limitations: [],
|
|
}).edges,
|
|
).toEqual([changedFrom]);
|
|
|
|
const invalid = createJavaScriptApplicationEdge({
|
|
source_node_id: preload.node_id,
|
|
target_node_id: runtime.node_id,
|
|
relation: "changed_from",
|
|
properties: {},
|
|
evidence: inferredArtifactEvidence(
|
|
APPLICATION_GRAPH_DIGESTS.asar,
|
|
"dist/preload.js",
|
|
),
|
|
});
|
|
expect(() =>
|
|
createJavaScriptApplicationGraph({
|
|
schema: "JavaScriptApplicationGraph",
|
|
schema_version: 1,
|
|
root_node_ids: [preload.node_id],
|
|
nodes: [preload, runtime],
|
|
edges: [invalid],
|
|
coverage: completeCoverage,
|
|
limitations: [],
|
|
}),
|
|
).toThrow(/changed_from endpoints must have the same node kind/u);
|
|
});
|
|
});
|