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