Add configurable distribution supply types
This commit is contained in:
@@ -20,6 +20,14 @@ function minimalSnapshot() {
|
||||
description: null,
|
||||
singlePhaseVoltageV: 230,
|
||||
threePhaseVoltageV: 400,
|
||||
enabledDistributionBoardSupplyTypes: [
|
||||
"AV",
|
||||
"SV",
|
||||
"EV",
|
||||
"USV",
|
||||
"MSR",
|
||||
"SiBe",
|
||||
],
|
||||
},
|
||||
distributionBoards: [],
|
||||
circuitLists: [],
|
||||
@@ -61,9 +69,65 @@ describe("project state snapshot model", () => {
|
||||
externalProjectNumber: null,
|
||||
buildingOwner: null,
|
||||
description: null,
|
||||
enabledDistributionBoardSupplyTypes: [
|
||||
"AV",
|
||||
"SV",
|
||||
"EV",
|
||||
"USV",
|
||||
"MSR",
|
||||
"SiBe",
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("upgrades version-two distribution boards without inferred assignments", () => {
|
||||
const previous = {
|
||||
...minimalSnapshot(),
|
||||
schemaVersion: 2 as const,
|
||||
project: {
|
||||
...minimalSnapshot().project,
|
||||
enabledDistributionBoardSupplyTypes: undefined,
|
||||
},
|
||||
distributionBoards: [
|
||||
{
|
||||
id: "board-1",
|
||||
projectId: "project-1",
|
||||
name: "UV 1",
|
||||
},
|
||||
],
|
||||
};
|
||||
delete previous.project.enabledDistributionBoardSupplyTypes;
|
||||
const snapshot = parseProjectStateSnapshot(previous);
|
||||
assert.deepEqual(snapshot.distributionBoards, [
|
||||
{
|
||||
...previous.distributionBoards[0],
|
||||
floorId: null,
|
||||
supplyType: null,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("upgrades version-three snapshots with all project supply types", () => {
|
||||
const previous = {
|
||||
...minimalSnapshot(),
|
||||
schemaVersion: 3 as const,
|
||||
project: {
|
||||
...minimalSnapshot().project,
|
||||
enabledDistributionBoardSupplyTypes: undefined,
|
||||
},
|
||||
};
|
||||
delete previous.project.enabledDistributionBoardSupplyTypes;
|
||||
const snapshot = parseProjectStateSnapshot(previous);
|
||||
assert.deepEqual(snapshot.project.enabledDistributionBoardSupplyTypes, [
|
||||
"AV",
|
||||
"SV",
|
||||
"EV",
|
||||
"USV",
|
||||
"MSR",
|
||||
"SiBe",
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects duplicate ids and cross-project ownership", () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
@@ -74,11 +138,15 @@ describe("project state snapshot model", () => {
|
||||
id: "board-1",
|
||||
projectId: "project-1",
|
||||
name: "UV 1",
|
||||
floorId: null,
|
||||
supplyType: null,
|
||||
},
|
||||
{
|
||||
id: "board-1",
|
||||
projectId: "project-1",
|
||||
name: "UV 2",
|
||||
floorId: null,
|
||||
supplyType: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
@@ -102,6 +170,22 @@ describe("project state snapshot model", () => {
|
||||
});
|
||||
|
||||
it("rejects invalid references and inconsistent reserve circuits", () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
parseProjectStateSnapshot({
|
||||
...minimalSnapshot(),
|
||||
distributionBoards: [
|
||||
{
|
||||
id: "board-1",
|
||||
projectId: "project-1",
|
||||
name: "UV 1",
|
||||
floorId: "missing",
|
||||
supplyType: "AV",
|
||||
},
|
||||
],
|
||||
}),
|
||||
/distribution board floor reference is invalid/
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
parseProjectStateSnapshot({
|
||||
|
||||
Reference in New Issue
Block a user