Manage circuit groups
This commit is contained in:
@@ -15,8 +15,60 @@ import { createCircuitGroupMovePlan } from "../src/domain/services/circuit-group
|
||||
import "./circuit-group-move-project-command.repository.test.js";
|
||||
import "./circuit-group-subtree-snapshot.test.js";
|
||||
import "./circuit-group-subtree-project-command.repository.test.js";
|
||||
import {
|
||||
buildNewCircuitGroupSnapshot,
|
||||
canDeleteCircuitGroup,
|
||||
renameCircuitGroupSnapshot,
|
||||
} from "../src/frontend/utils/circuit-group-editing.js";
|
||||
|
||||
describe("circuit group numbering", () => {
|
||||
it("builds the next group without filling gaps or renumbering existing groups", () => {
|
||||
const sections = [
|
||||
groupSection("lighting-1", "lighting", 1, 10),
|
||||
groupSection("single-1", "single_phase", 1, 20),
|
||||
groupSection("lighting-3", "lighting", 3, 15),
|
||||
];
|
||||
const snapshot = buildNewCircuitGroupSnapshot({
|
||||
id: "lighting-4",
|
||||
circuitListId: "list-1",
|
||||
category: "lighting",
|
||||
sections,
|
||||
});
|
||||
assert.deepEqual(snapshot, {
|
||||
id: "lighting-4",
|
||||
circuitListId: "list-1",
|
||||
key: "lighting_4",
|
||||
displayName: "Beleuchtung 4",
|
||||
prefix: "-1F4.",
|
||||
sortOrder: 17.5,
|
||||
category: "lighting",
|
||||
groupNumber: 4,
|
||||
});
|
||||
assert.equal(
|
||||
renameCircuitGroupSnapshot(snapshot, " Beleuchtung Nord ").displayName,
|
||||
"Beleuchtung Nord"
|
||||
);
|
||||
assert.equal(canDeleteCircuitGroup(sections[0]), true);
|
||||
assert.equal(
|
||||
canDeleteCircuitGroup({
|
||||
...sections[0],
|
||||
components: [
|
||||
{
|
||||
id: "component-1",
|
||||
circuitListId: "list-1",
|
||||
sectionId: sections[0].id,
|
||||
equipmentIdentifier: "-1Q1.0",
|
||||
name: "Gruppen-FI",
|
||||
role: "group_residual_current_protection",
|
||||
placement: "group",
|
||||
sortOrder: 10,
|
||||
},
|
||||
],
|
||||
}),
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
it("formats the agreed identifiers including the leading hyphen", () => {
|
||||
assert.equal(
|
||||
formatGroupUpstreamProtectionIdentifier("lighting", 1),
|
||||
@@ -110,6 +162,26 @@ describe("circuit group numbering", () => {
|
||||
});
|
||||
});
|
||||
|
||||
function groupSection(
|
||||
id: string,
|
||||
category: "lighting" | "single_phase" | "three_phase",
|
||||
groupNumber: number,
|
||||
sortOrder: number
|
||||
) {
|
||||
return {
|
||||
id,
|
||||
key: id,
|
||||
displayName: id,
|
||||
prefix: `-${category === "lighting" ? 1 : category === "single_phase" ? 2 : 3}F${groupNumber}.`,
|
||||
sortOrder,
|
||||
category,
|
||||
groupNumber,
|
||||
sectionTotalPower: 0,
|
||||
components: [],
|
||||
circuits: [],
|
||||
};
|
||||
}
|
||||
|
||||
describe("circuit group renumber planning", () => {
|
||||
const groups = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user