Add Revit initial import planning
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import {
|
||||
planExternalInitialImportSchema,
|
||||
previewExternalCsvSchema,
|
||||
updateExternalCsvConfigurationSchema,
|
||||
} from "../src/shared/validation/external-csv.schemas.js";
|
||||
@@ -23,6 +24,13 @@ describe("external CSV API contracts", () => {
|
||||
}).success,
|
||||
true
|
||||
);
|
||||
assert.equal(
|
||||
planExternalInitialImportSchema.safeParse({
|
||||
fileName: "revit.csv",
|
||||
contentBase64: "YWJj",
|
||||
}).success,
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects stale-shaped, oversized and unknown request fields", () => {
|
||||
@@ -41,6 +49,14 @@ describe("external CSV API contracts", () => {
|
||||
}).success,
|
||||
false
|
||||
);
|
||||
assert.equal(
|
||||
planExternalInitialImportSchema.safeParse({
|
||||
fileName: "revit.csv",
|
||||
contentBase64: "YWJj",
|
||||
decisions: [],
|
||||
}).success,
|
||||
false
|
||||
);
|
||||
assert.equal(
|
||||
previewExternalCsvSchema.safeParse({
|
||||
fileName: "revit.csv",
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import { createExternalInitialImportPlan } from "../src/external-model/application/external-initial-import-plan.js";
|
||||
import {
|
||||
externalCsvTestConfiguration,
|
||||
firstIfcGuid,
|
||||
quotedRevitCsv,
|
||||
utf8Bytes,
|
||||
} from "./fixtures/revit-csv-fixtures.js";
|
||||
|
||||
describe("external initial import plan", () => {
|
||||
it("groups source rooms and exposes exact room and classification suggestions", () => {
|
||||
const configuration = structuredClone(externalCsvTestConfiguration);
|
||||
configuration.familyTypeRules.push({
|
||||
exactFamilyAndType: "Steckdose: Doppelsteckdose",
|
||||
internalDeviceType: "Steckdose",
|
||||
connectionKind: "socket",
|
||||
category: "single_phase",
|
||||
quantityRule: { kind: "mapped-column" },
|
||||
displayNameSuggestion: { kind: "selection-marker" },
|
||||
});
|
||||
|
||||
const plan = createExternalInitialImportPlan({
|
||||
fileName: "revit.csv",
|
||||
bytes: utf8Bytes(quotedRevitCsv, true),
|
||||
configurationVersion: 4,
|
||||
configuration,
|
||||
floors: [{ id: "floor-1", name: "EG", sortOrder: 10 }],
|
||||
rooms: [{
|
||||
id: "room-1",
|
||||
floorId: "floor-1",
|
||||
roomNumber: "01/101",
|
||||
roomName: "Technik Bestand",
|
||||
}],
|
||||
distributionBoards: [{ id: "board-1", name: "UV 1", floorId: "floor-1" }],
|
||||
projectDevices: [{
|
||||
id: "device-1",
|
||||
name: "socket",
|
||||
displayName: "Steckdose",
|
||||
category: "single_phase",
|
||||
connectionKind: "socket",
|
||||
powerPerUnit: 0.12,
|
||||
}],
|
||||
});
|
||||
|
||||
assert.equal(plan.configurationVersion, 4);
|
||||
assert.equal(plan.objectCount, 2);
|
||||
assert.equal(plan.sourceRooms.length, 2);
|
||||
assert.deepEqual(
|
||||
plan.sourceRooms.map((room) => ({
|
||||
number: room.roomNumber,
|
||||
status: room.matchStatus,
|
||||
suggested: room.suggestedRoomId,
|
||||
})),
|
||||
[
|
||||
{ number: "01/101", status: "exact-number", suggested: "room-1" },
|
||||
{ number: "01/103", status: "new", suggested: null },
|
||||
]
|
||||
);
|
||||
assert.equal(plan.familyGroups.length, 2);
|
||||
assert.equal(plan.issueCounts.unknownFamilyAndType, 1);
|
||||
assert.equal(plan.issueCounts.invalidPower, 0);
|
||||
assert.equal(plan.issueCounts.invalidQuantity, 0);
|
||||
assert.equal(plan.objects[0].ifcGuid, firstIfcGuid);
|
||||
assert.equal(plan.objects[0].suggestedPlanningValues.effectiveQuantity, 2);
|
||||
assert.equal(plan.existing.distributionBoards[0].id, "board-1");
|
||||
assert.equal(plan.existing.projectDevices[0].id, "device-1");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user