32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { projectMatch } from "../src/projects/project-match.ts";
|
|
|
|
const snapshot = {
|
|
status: "partial",
|
|
rootCategory: "ROBOT",
|
|
searchLimited: true,
|
|
unmetRequirements: [{ message: "缺少负载数据" }],
|
|
missingParts: [{ category: "SENSOR" }],
|
|
requirementChecks: [],
|
|
assembly: { status: "ready", connections: [] },
|
|
components: [{ instanceId: "base-1", component: { componentCode: "CW-BASE" } }],
|
|
};
|
|
|
|
test("saved project snapshots restore a workspace match without an analysis id", () => {
|
|
const match = projectMatch({ projectCode: "RP-42", snapshot });
|
|
|
|
assert.equal(match.analysisId, "project-RP-42");
|
|
assert.equal(match.matchId, "project-RP-42");
|
|
assert.equal(match.status, "partial");
|
|
assert.equal(match.searchLimited, true);
|
|
assert.equal(match.components, snapshot.components);
|
|
assert.equal(match.assembly, snapshot.assembly);
|
|
assert.deepEqual(match.alternatives, []);
|
|
});
|
|
|
|
test("projects without a usable snapshot are not opened as empty assemblies", () => {
|
|
assert.equal(projectMatch({ projectCode: "RP-empty" }), null);
|
|
assert.equal(projectMatch({ projectCode: "RP-no-parts", snapshot: { ...snapshot, components: [] } }), null);
|
|
});
|