Add circuit reorder history

This commit is contained in:
2026-07-24 08:21:32 +02:00
parent 53282e8c7c
commit 332dfdb5d9
14 changed files with 865 additions and 16 deletions
+62
View File
@@ -29,6 +29,10 @@ import {
createCircuitDeleteProjectCommand,
createCircuitInsertProjectCommand,
} from "../src/domain/models/circuit-structure-project-command.model.js";
import {
assertCircuitSectionReorderProjectCommand,
createCircuitSectionReorderProjectCommand,
} from "../src/domain/models/circuit-section-reorder-project-command.model.js";
describe("serialized project commands", () => {
it("round-trips a versioned command envelope", () => {
@@ -519,3 +523,61 @@ describe("circuit structure project commands", () => {
);
});
});
describe("circuit section reorder project commands", () => {
it("captures every expected and target sort position", () => {
const command = createCircuitSectionReorderProjectCommand(
"section-1",
[
{
circuitId: "circuit-1",
expectedSortOrder: 10,
targetSortOrder: 20,
},
{
circuitId: "circuit-2",
expectedSortOrder: 20,
targetSortOrder: 10,
},
]
);
assert.equal(command.payload.assignments.length, 2);
assert.doesNotThrow(() =>
assertCircuitSectionReorderProjectCommand(command)
);
});
it("rejects empty, duplicate and complete no-op assignments", () => {
assert.throws(
() => createCircuitSectionReorderProjectCommand("", []),
/sectionId/
);
assert.throws(
() =>
createCircuitSectionReorderProjectCommand("section-1", [
{
circuitId: "circuit-1",
expectedSortOrder: 10,
targetSortOrder: 20,
},
{
circuitId: "circuit-1",
expectedSortOrder: 20,
targetSortOrder: 10,
},
]),
/duplicate circuit ids/
);
assert.throws(
() =>
createCircuitSectionReorderProjectCommand("section-1", [
{
circuitId: "circuit-1",
expectedSortOrder: 10,
targetSortOrder: 10,
},
]),
/change at least one position/
);
});
});