Add placeholder move history
This commit is contained in:
@@ -20,7 +20,9 @@ import {
|
||||
} from "../src/domain/models/circuit-device-row-structure-project-command.model.js";
|
||||
import {
|
||||
assertCircuitDeviceRowMoveProjectCommand,
|
||||
assertCircuitDeviceRowMoveWithNewCircuitProjectCommand,
|
||||
createCircuitDeviceRowMoveProjectCommand,
|
||||
createCircuitDeviceRowMoveWithNewCircuitProjectCommand,
|
||||
} from "../src/domain/models/circuit-device-row-move-project-command.model.js";
|
||||
import {
|
||||
assertCircuitInsertProjectCommand,
|
||||
@@ -251,6 +253,29 @@ describe("circuit device-row structure project commands", () => {
|
||||
});
|
||||
|
||||
describe("circuit device-row move project commands", () => {
|
||||
const targetCircuit = {
|
||||
id: "circuit-new",
|
||||
circuitListId: "list-1",
|
||||
sectionId: "section-1",
|
||||
equipmentIdentifier: "-1F3",
|
||||
displayName: "Neuer Stromkreis",
|
||||
sortOrder: 30,
|
||||
protectionType: null,
|
||||
protectionRatedCurrent: null,
|
||||
protectionCharacteristic: null,
|
||||
cableType: null,
|
||||
cableCrossSection: null,
|
||||
cableLength: null,
|
||||
rcdAssignment: null,
|
||||
terminalDesignation: null,
|
||||
voltage: null,
|
||||
controlRequirement: null,
|
||||
status: null,
|
||||
isReserve: true,
|
||||
remark: null,
|
||||
deviceRows: [],
|
||||
};
|
||||
|
||||
it("captures deterministic source and target positions", () => {
|
||||
const command = createCircuitDeviceRowMoveProjectCommand([
|
||||
{
|
||||
@@ -313,6 +338,87 @@ describe("circuit device-row move project commands", () => {
|
||||
/no-op/
|
||||
);
|
||||
});
|
||||
|
||||
it("captures creation and deletion of a deterministic move target", () => {
|
||||
const create =
|
||||
createCircuitDeviceRowMoveWithNewCircuitProjectCommand(
|
||||
"create",
|
||||
targetCircuit,
|
||||
[
|
||||
{
|
||||
rowId: "row-1",
|
||||
expectedCircuitId: "circuit-1",
|
||||
expectedSortOrder: 10,
|
||||
targetCircuitId: targetCircuit.id,
|
||||
targetSortOrder: 10,
|
||||
},
|
||||
]
|
||||
);
|
||||
const remove =
|
||||
createCircuitDeviceRowMoveWithNewCircuitProjectCommand(
|
||||
"delete",
|
||||
targetCircuit,
|
||||
[
|
||||
{
|
||||
rowId: "row-1",
|
||||
expectedCircuitId: targetCircuit.id,
|
||||
expectedSortOrder: 10,
|
||||
targetCircuitId: "circuit-1",
|
||||
targetSortOrder: 10,
|
||||
},
|
||||
]
|
||||
);
|
||||
assert.doesNotThrow(() =>
|
||||
assertCircuitDeviceRowMoveWithNewCircuitProjectCommand(
|
||||
create
|
||||
)
|
||||
);
|
||||
assert.equal(remove.payload.targetCircuitAction, "delete");
|
||||
});
|
||||
|
||||
it("rejects inconsistent move targets and non-empty snapshots", () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
createCircuitDeviceRowMoveWithNewCircuitProjectCommand(
|
||||
"create",
|
||||
targetCircuit,
|
||||
[
|
||||
{
|
||||
rowId: "row-1",
|
||||
expectedCircuitId: "circuit-1",
|
||||
expectedSortOrder: 10,
|
||||
targetCircuitId: "other-circuit",
|
||||
targetSortOrder: 10,
|
||||
},
|
||||
]
|
||||
),
|
||||
/move rows into the new circuit/
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
assertCircuitDeviceRowMoveWithNewCircuitProjectCommand({
|
||||
schemaVersion: 1,
|
||||
type: "circuit-device-row.move-with-new-circuit",
|
||||
payload: {
|
||||
targetCircuitAction: "create",
|
||||
targetCircuit: {
|
||||
...targetCircuit,
|
||||
isReserve: false,
|
||||
},
|
||||
moves: [
|
||||
{
|
||||
rowId: "row-1",
|
||||
expectedCircuitId: "circuit-1",
|
||||
expectedSortOrder: 10,
|
||||
targetCircuitId: targetCircuit.id,
|
||||
targetSortOrder: 10,
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
/reserve state/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("circuit structure project commands", () => {
|
||||
|
||||
Reference in New Issue
Block a user