Protect referenced feeder structures from deletion
This commit is contained in:
parent
b893c72534
commit
855a04e655
13 changed files with 369 additions and 0 deletions
|
|
@ -219,6 +219,54 @@ describe("distribution-board structure project command", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("blocks undo from removing an empty board used as a feeder", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
const repository =
|
||||
new DistributionBoardStructureProjectCommandRepository(context.db);
|
||||
const upstream = createDistributionBoardStructureSnapshot(
|
||||
"project-1",
|
||||
"NSHV"
|
||||
);
|
||||
const inserted = repository.execute({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 0,
|
||||
source: "user",
|
||||
command: createDistributionBoardInsertProjectCommand(upstream),
|
||||
});
|
||||
const downstream = createDistributionBoardStructureSnapshot(
|
||||
"project-1",
|
||||
"UV-01"
|
||||
);
|
||||
context.db.insert(distributionBoards).values({
|
||||
...downstream.distributionBoard,
|
||||
boardNumber: "UV-01",
|
||||
feedingDistributionBoardId: upstream.distributionBoard.id,
|
||||
}).run();
|
||||
context.db.insert(circuitLists).values(downstream.circuitList).run();
|
||||
context.db.insert(circuitSections).values(downstream.sections).run();
|
||||
context.db.insert(distributionBoardComponents)
|
||||
.values(downstream.components).run();
|
||||
|
||||
assert.throws(
|
||||
() => repository.execute({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 1,
|
||||
source: "undo",
|
||||
historyTargetChangeSetId: inserted.revision.changeSetId,
|
||||
command: inserted.inverse,
|
||||
}),
|
||||
/Speist UV-01 – erst Einspeisung ändern\./
|
||||
);
|
||||
assert.ok(
|
||||
context.db.select().from(distributionBoards)
|
||||
.where(eq(distributionBoards.id, upstream.distributionBoard.id)).get()
|
||||
);
|
||||
} finally {
|
||||
context.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("allows only supply types enabled in the project", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue