Add section renumber history

This commit is contained in:
2026-07-24 08:34:31 +02:00
parent 332dfdb5d9
commit 4b4603b71b
14 changed files with 1057 additions and 14 deletions
+58
View File
@@ -33,6 +33,10 @@ import {
assertCircuitSectionReorderProjectCommand,
createCircuitSectionReorderProjectCommand,
} from "../src/domain/models/circuit-section-reorder-project-command.model.js";
import {
assertCircuitSectionRenumberProjectCommand,
createCircuitSectionRenumberProjectCommand,
} from "../src/domain/models/circuit-section-renumber-project-command.model.js";
describe("serialized project commands", () => {
it("round-trips a versioned command envelope", () => {
@@ -581,3 +585,57 @@ describe("circuit section reorder project commands", () => {
);
});
});
describe("circuit section renumber project commands", () => {
it("captures every expected and target equipment identifier", () => {
const command = createCircuitSectionRenumberProjectCommand(
"section-1",
[
{
circuitId: "circuit-1",
expectedEquipmentIdentifier: "-1F1",
targetEquipmentIdentifier: "-1F2",
},
{
circuitId: "circuit-2",
expectedEquipmentIdentifier: "-1F2",
targetEquipmentIdentifier: "-1F1",
},
]
);
assert.equal(command.payload.assignments.length, 2);
assert.doesNotThrow(() =>
assertCircuitSectionRenumberProjectCommand(command)
);
});
it("rejects duplicate and complete no-op assignments", () => {
assert.throws(
() =>
createCircuitSectionRenumberProjectCommand("section-1", [
{
circuitId: "circuit-1",
expectedEquipmentIdentifier: "-1F1",
targetEquipmentIdentifier: "-1F2",
},
{
circuitId: "circuit-2",
expectedEquipmentIdentifier: "-1F2",
targetEquipmentIdentifier: "-1F2",
},
]),
/duplicate target identifiers/
);
assert.throws(
() =>
createCircuitSectionRenumberProjectCommand("section-1", [
{
circuitId: "circuit-1",
expectedEquipmentIdentifier: "-1F1",
targetEquipmentIdentifier: "-1F1",
},
]),
/change at least one identifier/
);
});
});