Add distribution power summaries
This commit is contained in:
@@ -5,11 +5,14 @@ import {
|
||||
buildCircuitEditPatch,
|
||||
buildDeviceRowEditPatch,
|
||||
formatValue,
|
||||
getCircuitSectionLabel,
|
||||
getProjectColumnLayoutStorageKey,
|
||||
isGridEditorControlTarget,
|
||||
getBlockSortValue,
|
||||
getCellKind,
|
||||
getCircuitValue,
|
||||
getDeviceValue,
|
||||
parseStoredColumnLayout,
|
||||
parseNumeric,
|
||||
} from "../src/frontend/utils/circuit-grid-model.js";
|
||||
import type { CircuitTreeCircuitDto, CircuitTreeDeviceRowDto } from "../src/frontend/types.js";
|
||||
@@ -73,6 +76,47 @@ describe("circuit grid model", () => {
|
||||
assert.equal(allColumns[0].locked, true);
|
||||
});
|
||||
|
||||
it("stores valid column layouts under a project-specific key", () => {
|
||||
assert.equal(
|
||||
getProjectColumnLayoutStorageKey("project-1"),
|
||||
"circuitTreeEditor.columnLayout.v2.project-1"
|
||||
);
|
||||
const layout = parseStoredColumnLayout(
|
||||
JSON.stringify({
|
||||
order: ["displayName", "equipmentIdentifier"],
|
||||
visible: [
|
||||
"displayName",
|
||||
"equipmentIdentifier",
|
||||
"unknown",
|
||||
],
|
||||
})
|
||||
);
|
||||
assert.ok(layout);
|
||||
assert.equal(layout.order[0], "equipmentIdentifier");
|
||||
assert.deepEqual(layout.visible, [
|
||||
"displayName",
|
||||
"equipmentIdentifier",
|
||||
]);
|
||||
assert.equal(parseStoredColumnLayout("{invalid"), null);
|
||||
});
|
||||
|
||||
it("shows stable circuit sections with German labels", () => {
|
||||
assert.equal(
|
||||
getCircuitSectionLabel({
|
||||
key: "lighting",
|
||||
displayName: "Lighting",
|
||||
}),
|
||||
"Licht"
|
||||
);
|
||||
assert.equal(
|
||||
getCircuitSectionLabel({
|
||||
key: "custom",
|
||||
displayName: "Sonderbereich",
|
||||
}),
|
||||
"Sonderbereich"
|
||||
);
|
||||
});
|
||||
|
||||
it("maps shared fields to the correct level for every row shape", () => {
|
||||
assert.equal(getCellKind("circuitCompact", "displayName"), "deviceField");
|
||||
assert.equal(getCellKind("circuitCompact", "equipmentIdentifier"), "circuitField");
|
||||
|
||||
Reference in New Issue
Block a user