70 lines
2.5 KiB
TypeScript
70 lines
2.5 KiB
TypeScript
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");
|
|
});
|
|
});
|