Add explicit "no protection device" state for circuits

Circuits can now record that they deliberately have no protection device
(type NONE, shown as "–"), separate from circuits whose protection is
still open. Migration 0017 makes rated_current_a nullable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian Appel 2026-10-30 13:11:28 +01:00
parent 1f3b903809
commit 38019fe087
27 changed files with 3673 additions and 132 deletions

View file

@ -559,6 +559,44 @@ describe("project state snapshot model", () => {
() => parseProjectStateSnapshot(invalidProtection),
/protection-device configuration is invalid/
);
const protectedState = protectedSnapshot();
const noProtectionRecord = {
circuitId: protectedState.circuitProtectionDevices[0]!.circuitId,
type: "NONE",
ratedCurrentA: null,
fuseUtilizationCategory: null,
tripCharacteristic: null,
rcdType: null,
ratedResidualCurrentMa: null,
};
assert.equal(
parseProjectStateSnapshot({
...protectedState,
circuitProtectionDevices: [noProtectionRecord],
}).circuitProtectionDevices[0]?.type,
"NONE"
);
assert.throws(
() =>
parseProjectStateSnapshot({
...protectedState,
circuitProtectionDevices: [
{ ...noProtectionRecord, ratedCurrentA: 16 },
],
}),
/protection-device configuration is invalid/
);
const componentWithoutDevice = {
...protectedState,
distributionBoardComponentProtectionDevices: [
{
...protectedState.distributionBoardComponentProtectionDevices[0]!,
type: "NONE",
},
],
};
assert.throws(() => parseProjectStateSnapshot(componentWithoutDevice));
});
it("rejects duplicate ids and invalid ownership", () => {