Align project devices with circuit model

This commit is contained in:
2026-07-22 19:31:08 +02:00
parent 689cfd3c65
commit 9d07ed9856
16 changed files with 301 additions and 106 deletions
+36
View File
@@ -0,0 +1,36 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { createProjectDeviceSchema } from "../src/shared/validation/project-device.schemas.js";
describe("project device circuit-first schema", () => {
it("accepts circuit device fields", () => {
const result = createProjectDeviceSchema.safeParse({
name: "E-Line Pro",
displayName: "Office lighting",
phaseType: "single_phase",
connectionKind: "fixed",
costGroup: "440",
category: "Lighting",
quantity: 6,
powerPerUnit: 0.04,
simultaneityFactor: 0.8,
cosPhi: 0.95,
remark: "DALI",
});
assert.equal(result.success, true);
});
it("requires the circuit-first power and phase fields", () => {
const result = createProjectDeviceSchema.safeParse({
name: "Legacy device",
displayName: "Legacy device",
quantity: 1,
installedPowerPerUnitKw: 0.1,
demandFactor: 1,
phaseCount: 1,
});
assert.equal(result.success, false);
});
});