Add Revit circuit list object feed
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import { createExternalCircuitListObjects } from "../src/external-model/application/external-circuit-list-objects.js";
|
||||
import type {
|
||||
ExternalModelObjectSnapshot,
|
||||
ExternalModelStateSnapshot,
|
||||
} from "../src/external-model/domain/external-model-contracts.js";
|
||||
|
||||
function object(input: {
|
||||
id: string;
|
||||
distributionBoardId: string;
|
||||
circuitDeviceRowId: string | null;
|
||||
roomNumber: string;
|
||||
}): ExternalModelObjectSnapshot {
|
||||
return {
|
||||
id: input.id,
|
||||
projectId: "project-1",
|
||||
sourceId: "source-1",
|
||||
ifcGuid: `ifc-${input.id}`,
|
||||
lastSeenImportBatchId: "batch-1",
|
||||
lastAcceptedImportBatchId: "batch-1",
|
||||
acceptedSourceValues: {
|
||||
rowNumber: 2,
|
||||
roomNumber: input.roomNumber,
|
||||
roomName: "Büro",
|
||||
familyAndType: "Steckdose: Standard",
|
||||
selectionMarker: `S-${input.id}`,
|
||||
circuitIdentifier: "-2F1.1",
|
||||
power: "120",
|
||||
quantity: "1",
|
||||
additionalSourceValues: {},
|
||||
},
|
||||
planningValues: {
|
||||
displayName: "Steckdose",
|
||||
internalDeviceType: "socket",
|
||||
category: "single_phase",
|
||||
connectionKind: "socket",
|
||||
effectiveQuantity: 1,
|
||||
powerPerUnitW: 120,
|
||||
simultaneityFactor: 1,
|
||||
cosPhi: null,
|
||||
costGroup: null,
|
||||
remark: null,
|
||||
},
|
||||
overriddenFields: [],
|
||||
externalRoomMappingId: input.distributionBoardId === "board-1" ? "mapping-1" : null,
|
||||
distributionBoardId: input.distributionBoardId,
|
||||
linkedProjectDeviceId: null,
|
||||
circuitDeviceRowId: input.circuitDeviceRowId,
|
||||
presenceStatus: "present",
|
||||
};
|
||||
}
|
||||
|
||||
describe("external circuit-list object projection", () => {
|
||||
it("returns only the board objects with unassigned objects first", () => {
|
||||
const state: ExternalModelStateSnapshot = {
|
||||
source: {
|
||||
id: "source-1",
|
||||
projectId: "project-1",
|
||||
name: "Revit-Gesamtmodell",
|
||||
sourceType: "revit_csv",
|
||||
},
|
||||
importBatches: [],
|
||||
roomMappings: [{
|
||||
id: "mapping-1",
|
||||
projectId: "project-1",
|
||||
sourceId: "source-1",
|
||||
normalizedSourceRoomKey: "number:101",
|
||||
sourceFloorName: "EG",
|
||||
sourceRoomNumber: "101",
|
||||
sourceRoomName: "Besprechung",
|
||||
roomId: "room-1",
|
||||
defaultDistributionBoardId: "board-1",
|
||||
}],
|
||||
objects: [
|
||||
object({ id: "assigned", distributionBoardId: "board-1", circuitDeviceRowId: "row-1", roomNumber: "102" }),
|
||||
object({ id: "unassigned", distributionBoardId: "board-1", circuitDeviceRowId: null, roomNumber: "101" }),
|
||||
object({ id: "other-board", distributionBoardId: "board-2", circuitDeviceRowId: null, roomNumber: "001" }),
|
||||
],
|
||||
};
|
||||
|
||||
const result = createExternalCircuitListObjects({
|
||||
state,
|
||||
distributionBoardId: "board-1",
|
||||
});
|
||||
|
||||
assert.equal(result.sourceName, "Revit-Gesamtmodell");
|
||||
assert.equal(result.objectCount, 2);
|
||||
assert.equal(result.unassignedObjectCount, 1);
|
||||
assert.deepEqual(result.objects.map(({ id }) => id), ["unassigned", "assigned"]);
|
||||
assert.equal(result.objects[0].sourceRoomName, "Besprechung");
|
||||
assert.equal(result.objects[0].roomId, "room-1");
|
||||
assert.equal(result.objects[0].sourceCircuitIdentifier, "-2F1.1");
|
||||
});
|
||||
|
||||
it("returns an empty projection before the optional Revit import", () => {
|
||||
assert.deepEqual(
|
||||
createExternalCircuitListObjects({
|
||||
state: { source: null, importBatches: [], roomMappings: [], objects: [] },
|
||||
distributionBoardId: "board-1",
|
||||
}),
|
||||
{ sourceName: null, objectCount: 0, unassignedObjectCount: 0, objects: [] }
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,7 @@ import { RoomModal } from "../src/frontend/components/room-modal.js";
|
||||
import {
|
||||
applyExternalInitialImport,
|
||||
getExternalCsvConfiguration,
|
||||
getExternalCircuitListObjects,
|
||||
planExternalInitialImport,
|
||||
previewExternalCsv,
|
||||
updateExternalCsvConfiguration,
|
||||
@@ -39,6 +40,7 @@ describe("Revit CSV frontend API", () => {
|
||||
|
||||
try {
|
||||
await getExternalCsvConfiguration("project-1");
|
||||
await getExternalCircuitListObjects("project-1", "list-1");
|
||||
await updateExternalCsvConfiguration("project-1", 7, configuration);
|
||||
await previewExternalCsv("project-1", "revit.csv", "YWJj");
|
||||
await planExternalInitialImport("project-1", "revit.csv", "YWJj");
|
||||
@@ -62,6 +64,11 @@ describe("Revit CSV frontend API", () => {
|
||||
method: "GET",
|
||||
body: null,
|
||||
},
|
||||
{
|
||||
url: "/api/projects/project-1/circuit-lists/list-1/external-objects",
|
||||
method: "GET",
|
||||
body: null,
|
||||
},
|
||||
{
|
||||
url: "/api/projects/project-1/external-csv/configuration",
|
||||
method: "PUT",
|
||||
|
||||
Reference in New Issue
Block a user