Add circuit group reordering

This commit is contained in:
2026-07-30 19:49:27 +02:00
parent 1250f9a6af
commit e702712bd8
11 changed files with 335 additions and 7 deletions
+21
View File
@@ -50,6 +50,7 @@ import { createCircuitSectionRenumberProjectCommand } from "../src/domain/models
import { createCircuitInsertProjectCommand } from "../src/domain/models/circuit-structure-project-command.model.js";
import {
createCircuitGroupInsertProjectCommand,
createCircuitGroupReorderProjectCommand,
createCircuitGroupUpdateProjectCommand,
} from "../src/domain/models/circuit-group-structure-project-command.model.js";
import {
@@ -1270,6 +1271,26 @@ describe("project command service", () => {
.get()?.displayName,
expected.displayName
);
const groups = context.db
.select()
.from(circuitSections)
.where(eq(circuitSections.circuitListId, circuitListId))
.all();
const reorderAssignments = groups.map((group, index) => ({
groupId: group.id,
expectedSortOrder: group.sortOrder,
targetSortOrder: (groups.length - index) * 10,
}));
const reordered = createService(context).executeUser({
projectId: "project-1",
expectedRevision: 3,
command: createCircuitGroupReorderProjectCommand(
circuitListId,
reorderAssignments
),
});
assert.equal(reordered.history.currentRevision, 4);
} finally {
context.close();
}