Show circuit protection in saved layouts
This commit is contained in:
@@ -6,12 +6,14 @@ import {
|
||||
buildDeviceRowEditPatch,
|
||||
formatValue,
|
||||
getCircuitSectionLabel,
|
||||
getLegacyProjectColumnLayoutStorageKey,
|
||||
getProjectColumnLayoutStorageKey,
|
||||
isGridEditorControlTarget,
|
||||
getBlockSortValue,
|
||||
getCellKind,
|
||||
getCircuitValue,
|
||||
getDeviceValue,
|
||||
migrateLegacyColumnLayout,
|
||||
parseStoredColumnLayout,
|
||||
parseNumeric,
|
||||
} from "../src/frontend/utils/circuit-grid-model.js";
|
||||
@@ -79,6 +81,10 @@ describe("circuit grid model", () => {
|
||||
it("stores valid column layouts under a project-specific key", () => {
|
||||
assert.equal(
|
||||
getProjectColumnLayoutStorageKey("project-1"),
|
||||
"circuitTreeEditor.columnLayout.v3.project-1"
|
||||
);
|
||||
assert.equal(
|
||||
getLegacyProjectColumnLayoutStorageKey("project-1"),
|
||||
"circuitTreeEditor.columnLayout.v2.project-1"
|
||||
);
|
||||
const layout = parseStoredColumnLayout(
|
||||
@@ -100,6 +106,39 @@ describe("circuit grid model", () => {
|
||||
assert.equal(parseStoredColumnLayout("{invalid"), null);
|
||||
});
|
||||
|
||||
it("adds the circuit protection column to legacy project layouts", () => {
|
||||
const legacyLayout = parseStoredColumnLayout(
|
||||
JSON.stringify({
|
||||
order: [
|
||||
"equipmentIdentifier",
|
||||
"displayName",
|
||||
"rowTotalPower",
|
||||
"remark",
|
||||
],
|
||||
visible: [
|
||||
"equipmentIdentifier",
|
||||
"displayName",
|
||||
"rowTotalPower",
|
||||
"remark",
|
||||
],
|
||||
})
|
||||
);
|
||||
assert.ok(legacyLayout);
|
||||
|
||||
const migrated = migrateLegacyColumnLayout(legacyLayout);
|
||||
assert.equal(
|
||||
migrated.order.indexOf("protectionSummary"),
|
||||
migrated.order.indexOf("rowTotalPower") + 1
|
||||
);
|
||||
assert.deepEqual(migrated.visible, [
|
||||
"equipmentIdentifier",
|
||||
"displayName",
|
||||
"rowTotalPower",
|
||||
"remark",
|
||||
"protectionSummary",
|
||||
]);
|
||||
});
|
||||
|
||||
it("shows stable circuit sections with German labels", () => {
|
||||
assert.equal(
|
||||
getCircuitSectionLabel({
|
||||
|
||||
Reference in New Issue
Block a user