Delete populated circuit groups safely
This commit is contained in:
@@ -19,11 +19,13 @@ import {
|
||||
buildCircuitGroupMovePlan,
|
||||
buildCircuitGroupRenumberPlan,
|
||||
buildCircuitGroupReorderAssignments,
|
||||
buildCircuitGroupSubtreeSnapshot,
|
||||
buildNewCircuitGroupSnapshot,
|
||||
canMoveCircuitToGroup,
|
||||
canRenumberCircuitGroups,
|
||||
canDeleteCircuitGroup,
|
||||
renameCircuitGroupSnapshot,
|
||||
summarizeCircuitGroupSubtree,
|
||||
} from "../src/frontend/utils/circuit-group-editing.js";
|
||||
|
||||
describe("circuit group numbering", () => {
|
||||
@@ -294,6 +296,93 @@ describe("circuit group numbering", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("captures a complete populated group for warned deletion", () => {
|
||||
const section = {
|
||||
...groupSection("lighting-1", "lighting", 1, 10),
|
||||
components: [
|
||||
{
|
||||
id: "rcd-1",
|
||||
circuitListId: "list-1",
|
||||
sectionId: "lighting-1",
|
||||
equipmentIdentifier: "-1Q1.0",
|
||||
name: "Gruppen-FI",
|
||||
role: "group_residual_current_protection" as const,
|
||||
placement: "group" as const,
|
||||
sortOrder: 10,
|
||||
protectionDevice: {
|
||||
type: "FI" as const,
|
||||
ratedCurrentA: 40,
|
||||
rcdType: "A" as const,
|
||||
ratedResidualCurrentMa: 30,
|
||||
},
|
||||
},
|
||||
],
|
||||
circuits: [
|
||||
{
|
||||
id: "circuit-1",
|
||||
circuitListId: "list-1",
|
||||
sectionId: "lighting-1",
|
||||
equipmentIdentifier: "-1F1.1",
|
||||
displayName: "Flurlicht",
|
||||
sortOrder: 10,
|
||||
voltage: 230,
|
||||
isReserve: false,
|
||||
circuitTotalPower: 0.1,
|
||||
protectionDevice: {
|
||||
type: "LS" as const,
|
||||
ratedCurrentA: 10,
|
||||
tripCharacteristic: "B" as const,
|
||||
},
|
||||
deviceRows: [
|
||||
{
|
||||
id: "row-1",
|
||||
linkedProjectDeviceId: "device-1",
|
||||
sortOrder: 10,
|
||||
name: "Leuchte",
|
||||
displayName: "Leuchte Flur",
|
||||
phaseType: "single_phase",
|
||||
quantity: 2,
|
||||
powerPerUnit: 0.05,
|
||||
simultaneityFactor: 1,
|
||||
cosPhi: 0.95,
|
||||
overriddenFields: "[\"displayName\"]",
|
||||
rowTotalPower: 0.1,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const snapshot = buildCircuitGroupSubtreeSnapshot(
|
||||
section,
|
||||
"list-1"
|
||||
);
|
||||
|
||||
assert.deepEqual(summarizeCircuitGroupSubtree(snapshot), {
|
||||
circuitCount: 1,
|
||||
deviceRowCount: 1,
|
||||
protectionComponentCount: 1,
|
||||
});
|
||||
assert.equal(
|
||||
snapshot.circuits[0].circuit.deviceRows[0]
|
||||
.linkedProjectDeviceId,
|
||||
"device-1"
|
||||
);
|
||||
assert.equal(
|
||||
snapshot.circuits[0].circuit.deviceRows[0]
|
||||
.overriddenFields,
|
||||
"[\"displayName\"]"
|
||||
);
|
||||
assert.deepEqual(snapshot.circuits[0].protectionDevice, {
|
||||
circuitId: "circuit-1",
|
||||
type: "LS",
|
||||
ratedCurrentA: 10,
|
||||
fuseUtilizationCategory: null,
|
||||
tripCharacteristic: "B",
|
||||
rcdType: null,
|
||||
ratedResidualCurrentMa: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("formats the agreed identifiers including the leading hyphen", () => {
|
||||
assert.equal(
|
||||
formatGroupUpstreamProtectionIdentifier("lighting", 1),
|
||||
|
||||
Reference in New Issue
Block a user