Manage distribution board components
This commit is contained in:
@@ -7,6 +7,13 @@ import {
|
||||
distributionBoardComponentRoles,
|
||||
} from "../src/shared/constants/distribution-board-component.js";
|
||||
import { circuitGroupCategories } from "../src/shared/constants/circuit-group.js";
|
||||
import {
|
||||
buildDistributionBoardComponentSnapshot,
|
||||
getNextComponentSortOrder,
|
||||
getSuggestedGroupComponentIdentifier,
|
||||
toDistributionBoardComponentSnapshot,
|
||||
updateDistributionBoardComponentSnapshot,
|
||||
} from "../src/frontend/utils/distribution-board-component-editing.js";
|
||||
import "./distribution-board-component-structure-project-command.repository.test.js";
|
||||
|
||||
describe("distribution board component catalog", () => {
|
||||
@@ -47,4 +54,92 @@ describe("distribution board component catalog", () => {
|
||||
placement: "header",
|
||||
});
|
||||
});
|
||||
|
||||
it("builds exact editable component snapshots for persistent commands", () => {
|
||||
const groupRcd = buildDistributionBoardComponentSnapshot({
|
||||
id: "component-1",
|
||||
circuitListId: "list-1",
|
||||
role: "group_residual_current_protection",
|
||||
sectionId: "section-1",
|
||||
sortOrder: 20,
|
||||
values: {
|
||||
equipmentIdentifier: " -1Q1.0 ",
|
||||
name: " Gruppen-FI ",
|
||||
protectionDevice: {
|
||||
type: "FI",
|
||||
ratedCurrentA: 40,
|
||||
rcdType: "A",
|
||||
ratedResidualCurrentMa: 30,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepEqual(groupRcd, {
|
||||
component: {
|
||||
id: "component-1",
|
||||
circuitListId: "list-1",
|
||||
sectionId: "section-1",
|
||||
equipmentIdentifier: "-1Q1.0",
|
||||
name: "Gruppen-FI",
|
||||
role: "group_residual_current_protection",
|
||||
placement: "group",
|
||||
sortOrder: 20,
|
||||
},
|
||||
protectionDevice: {
|
||||
componentId: "component-1",
|
||||
type: "FI",
|
||||
ratedCurrentA: 40,
|
||||
fuseUtilizationCategory: null,
|
||||
tripCharacteristic: null,
|
||||
rcdType: "A",
|
||||
ratedResidualCurrentMa: 30,
|
||||
},
|
||||
});
|
||||
assert.deepEqual(
|
||||
updateDistributionBoardComponentSnapshot(groupRcd, {
|
||||
equipmentIdentifier: "-1Q1.0",
|
||||
name: "FI Beleuchtung",
|
||||
protectionDevice: {
|
||||
type: "FI",
|
||||
ratedCurrentA: 63,
|
||||
rcdType: "B+",
|
||||
ratedResidualCurrentMa: 300,
|
||||
},
|
||||
}).component,
|
||||
{ ...groupRcd.component, name: "FI Beleuchtung" }
|
||||
);
|
||||
});
|
||||
|
||||
it("maps tree DTOs and derives stable group suggestions and sort positions", () => {
|
||||
const snapshot = toDistributionBoardComponentSnapshot({
|
||||
id: "actor-1",
|
||||
circuitListId: "list-1",
|
||||
equipmentIdentifier: "-K1",
|
||||
name: "KNX Aktor",
|
||||
role: "auxiliary",
|
||||
placement: "footer",
|
||||
sortOrder: 10,
|
||||
});
|
||||
assert.equal(snapshot.component.sectionId, null);
|
||||
assert.equal(snapshot.protectionDevice, null);
|
||||
assert.equal(getNextComponentSortOrder([{ sortOrder: 10 }, { sortOrder: 40 }]), 50);
|
||||
assert.equal(
|
||||
getSuggestedGroupComponentIdentifier(
|
||||
{
|
||||
id: "section-1",
|
||||
key: "lighting",
|
||||
displayName: "Beleuchtung 2",
|
||||
prefix: "-1F2",
|
||||
sortOrder: 10,
|
||||
category: "lighting",
|
||||
groupNumber: 2,
|
||||
sectionTotalPower: 0,
|
||||
components: [],
|
||||
circuits: [],
|
||||
},
|
||||
"group_upstream_protection"
|
||||
),
|
||||
"-1F2.0"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user