Add circuit reorder history
This commit is contained in:
@@ -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/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user