Integrate project building structure
This commit is contained in:
commit
868f48e7ac
44 changed files with 5898 additions and 377 deletions
|
|
@ -20,6 +20,7 @@ import { circuits } from "../src/db/schema/circuits.js";
|
|||
import { distributionBoardComponentProtectionDevices } from "../src/db/schema/distribution-board-component-protection-devices.js";
|
||||
import { distributionBoardComponents } from "../src/db/schema/distribution-board-components.js";
|
||||
import { distributionBoards } from "../src/db/schema/distribution-boards.js";
|
||||
import { buildings } from "../src/db/schema/buildings.js";
|
||||
import { floors } from "../src/db/schema/floors.js";
|
||||
import { projectDevices } from "../src/db/schema/project-devices.js";
|
||||
import { projectSnapshots } from "../src/db/schema/project-snapshots.js";
|
||||
|
|
@ -59,6 +60,15 @@ function createTestDatabase(): DatabaseContext {
|
|||
.where(eq(circuitSections.circuitListId, list.id))
|
||||
.get();
|
||||
assert.ok(section);
|
||||
context.db
|
||||
.insert(buildings)
|
||||
.values({
|
||||
id: "building-1",
|
||||
projectId: "project-1",
|
||||
name: "Haus A",
|
||||
sortOrder: 0,
|
||||
})
|
||||
.run();
|
||||
context.db
|
||||
.insert(floors)
|
||||
.values({
|
||||
|
|
@ -66,6 +76,7 @@ function createTestDatabase(): DatabaseContext {
|
|||
projectId: "project-1",
|
||||
name: "EG",
|
||||
sortOrder: 10,
|
||||
buildingId: "building-1",
|
||||
})
|
||||
.run();
|
||||
context.db
|
||||
|
|
@ -248,7 +259,9 @@ describe("project snapshot repository", () => {
|
|||
"device-1"
|
||||
);
|
||||
assert.equal(state.projectDevices.length, 1);
|
||||
assert.equal(state.buildings.length, 1);
|
||||
assert.equal(state.floors.length, 1);
|
||||
assert.equal(state.floors[0].buildingId, "building-1");
|
||||
assert.equal(state.rooms.length, 1);
|
||||
assert.deepEqual(repository.listByProject("project-1"), [
|
||||
created,
|
||||
|
|
@ -400,8 +413,14 @@ describe("project snapshot repository", () => {
|
|||
schemaVersion: number;
|
||||
project: Record<string, unknown>;
|
||||
distributionBoards: Array<Record<string, unknown>>;
|
||||
buildings?: unknown;
|
||||
floors: Array<Record<string, unknown>>;
|
||||
};
|
||||
payload.schemaVersion = 5;
|
||||
delete payload.buildings;
|
||||
for (const floor of payload.floors) {
|
||||
delete floor.buildingId;
|
||||
}
|
||||
for (const field of ["siteAddress", "workStage", "projectLead", "projectEditor"]) {
|
||||
delete payload.project[field];
|
||||
}
|
||||
|
|
@ -434,6 +453,9 @@ describe("project snapshot repository", () => {
|
|||
(board) => board.boardNumber === null && board.fedFrom === null
|
||||
)
|
||||
);
|
||||
// Version 5 predates buildings: the upgraded state has none.
|
||||
assert.deepEqual(targetState.buildings, []);
|
||||
assert.ok(targetState.floors.every((floor) => floor.buildingId === null));
|
||||
} finally {
|
||||
context.close();
|
||||
}
|
||||
|
|
@ -506,6 +528,11 @@ describe("portable project transfer", () => {
|
|||
copied.state.distributionBoards[0].floorId,
|
||||
copied.state.floors[0].id
|
||||
);
|
||||
assert.notEqual(copied.state.buildings[0].id, "building-1");
|
||||
assert.equal(
|
||||
copied.state.floors[0].buildingId,
|
||||
copied.state.buildings[0].id
|
||||
);
|
||||
assert.equal(
|
||||
copied.state.distributionBoards[0].supplyType,
|
||||
"SV"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue