section.id === cableSizingEditorCircuit.sectionId
+ )?.category
+ }
+ isSaving={isSaving}
+ projectId={projectId}
+ onClose={() => setCableSizingEditorCircuit(null)}
+ onApply={handleApplyCableSizing}
+ />
+ ) : null}
({
+ method,
+ label: LAYING_METHOD_LABELS[method],
+ dataVerified: LAYING_METHOD_VERIFIED[method],
+ }))
+ );
+}
+
+export async function listInsulationMaterialsHandler(_req: Request, res: Response) {
+ return res.json(
+ INSULATION_MATERIALS.map((insulation) => ({
+ insulation,
+ label: INSULATION_MATERIAL_LABELS[insulation],
+ }))
+ );
+}
+
+export async function markCalculationAppliedHandler(req: Request, res: Response) {
+ const { calculationId } = req.params;
+ if (typeof calculationId !== "string") {
+ return res.status(400).json({ error: "Invalid calculationId" });
+ }
+ const updated = await cableSizingCalculationRepository.markApplied(calculationId);
+ if (!updated) {
+ return res.status(404).json({ error: "Calculation not found" });
+ }
+ return res.json(updated);
+}
+
+export async function listCalculationsForCircuitHandler(req: Request, res: Response) {
+ const { circuitId } = req.params;
+ if (typeof circuitId !== "string") {
+ return res.status(400).json({ error: "Invalid circuitId" });
+ }
+ const rows = await cableSizingCalculationRepository.listByCircuit(circuitId);
+ return res.json(rows);
+}
diff --git a/src/server/index.ts b/src/server/index.ts
index 2f6ac5e..4f548c4 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -1,6 +1,7 @@
import express from "express";
import { globalDeviceRouter } from "./routes/global-device.routes.js";
import { projectDeviceRouter } from "./routes/project-device.routes.js";
+import { cableSizingRouter } from "./routes/cable-sizing.routes.js";
import { projectRouter } from "./routes/project.routes.js";
import { errorMiddleware } from "./middleware/error.middleware.js";
import { createLogger, toErrorMeta } from "../shared/logging/logger.js";
@@ -49,6 +50,7 @@ app.get("/health", (_req, res) => {
app.use("/api/projects", projectRouter);
app.use("/api/global-devices", globalDeviceRouter);
app.use("/api/project-devices", projectDeviceRouter);
+app.use("/api/cable-sizing", cableSizingRouter);
app.use(errorMiddleware);
diff --git a/src/server/routes/cable-sizing.routes.ts b/src/server/routes/cable-sizing.routes.ts
new file mode 100644
index 0000000..ca67e2e
--- /dev/null
+++ b/src/server/routes/cable-sizing.routes.ts
@@ -0,0 +1,19 @@
+import express from "express";
+import * as cableSizingController from "../controllers/cable-sizing.controller.js";
+
+export const cableSizingRouter = express.Router();
+
+cableSizingRouter.post("/calculate", cableSizingController.calculateCableSizingHandler);
+cableSizingRouter.get("/laying-methods", cableSizingController.listLayingMethodsHandler);
+cableSizingRouter.get(
+ "/insulation-materials",
+ cableSizingController.listInsulationMaterialsHandler
+);
+cableSizingRouter.post(
+ "/calculations/:calculationId/applied",
+ cableSizingController.markCalculationAppliedHandler
+);
+cableSizingRouter.get(
+ "/circuits/:circuitId/calculations",
+ cableSizingController.listCalculationsForCircuitHandler
+);
diff --git a/tests/cable-sizing-calculation.repository.test.ts b/tests/cable-sizing-calculation.repository.test.ts
new file mode 100644
index 0000000..c5a2ac1
--- /dev/null
+++ b/tests/cable-sizing-calculation.repository.test.ts
@@ -0,0 +1,152 @@
+import path from "node:path";
+import assert from "node:assert/strict";
+import { describe, it } from "node:test";
+import { eq } from "drizzle-orm";
+import { migrate } from "drizzle-orm/better-sqlite3/migrator";
+import { createDatabaseContext, type DatabaseContext } from "../src/db/database-context.js";
+import { CableSizingCalculationRepository } from "../src/db/repositories/cable-sizing-calculation.repository.js";
+import { circuitLists } from "../src/db/schema/circuit-lists.js";
+import { circuitSections } from "../src/db/schema/circuit-sections.js";
+import { circuits } from "../src/db/schema/circuits.js";
+import { projects } from "../src/db/schema/projects.js";
+import { DistributionBoardFixtureRepository } from "./support/distribution-board-fixture.js";
+
+function createRepository() {
+ const context = createDatabaseContext(":memory:");
+ migrate(context.db, { migrationsFolder: path.resolve("src", "db", "migrations") });
+ return new CableSizingCalculationRepository(context.db);
+}
+
+function createRepositoryWithCircuits(): {
+ repository: CableSizingCalculationRepository;
+ context: DatabaseContext;
+ circuitOneId: string;
+ circuitTwoId: string;
+} {
+ const context = createDatabaseContext(":memory:");
+ migrate(context.db, { migrationsFolder: path.resolve("src", "db", "migrations") });
+ context.db.insert(projects).values({ id: "project-1", name: "Test project" }).run();
+ const board = new DistributionBoardFixtureRepository(context.db).createWithCircuitListAndDefaultSections(
+ "project-1",
+ "UV-01"
+ );
+ const circuitList = context.db
+ .select()
+ .from(circuitLists)
+ .where(eq(circuitLists.distributionBoardId, board.id))
+ .get();
+ if (!circuitList) {
+ throw new Error("fixture did not create a circuit list");
+ }
+ const section = context.db
+ .select()
+ .from(circuitSections)
+ .where(eq(circuitSections.circuitListId, circuitList.id))
+ .get();
+ if (!section) {
+ throw new Error("fixture did not create a section");
+ }
+ const circuitOneId = "circuit-1";
+ const circuitTwoId = "circuit-2";
+ context.db
+ .insert(circuits)
+ .values([
+ {
+ id: circuitOneId,
+ circuitListId: section.circuitListId,
+ sectionId: section.id,
+ equipmentIdentifier: "-1F1.1",
+ },
+ {
+ id: circuitTwoId,
+ circuitListId: section.circuitListId,
+ sectionId: section.id,
+ equipmentIdentifier: "-1F1.2",
+ },
+ ])
+ .run();
+ return {
+ repository: new CableSizingCalculationRepository(context.db),
+ context,
+ circuitOneId,
+ circuitTwoId,
+ };
+}
+
+describe("CableSizingCalculationRepository", () => {
+ it("creates an entry with input/result JSON and defaults appliedToCircuit to false", () => {
+ const repository = createRepository();
+ const entry = repository.create({
+ id: "calc-1",
+ projectId: null,
+ circuitId: null,
+ equipmentIdentifier: "-1F1.1",
+ input: { layingMethod: "C" },
+ result: { recommendedCrossSectionMm2: 4 },
+ appliedToCircuit: 0,
+ });
+ assert.equal(entry.id, "calc-1");
+ assert.equal(entry.appliedToCircuit, 0);
+ assert.deepEqual(entry.input, { layingMethod: "C" });
+ assert.deepEqual(entry.result, { recommendedCrossSectionMm2: 4 });
+ });
+
+ it("lists entries by circuitId, most recent first", () => {
+ // createdAt defaults to SQLite's unixepoch() (second resolution), so two
+ // inserts in the same test can tie - pass explicit, distinct timestamps
+ // instead of racing the clock. circuitId has a real foreign key into
+ // circuits (foreign_keys = ON), so this needs actual circuit rows, not
+ // arbitrary strings.
+ const { repository, circuitOneId, circuitTwoId } = createRepositoryWithCircuits();
+ repository.create({
+ id: "calc-a",
+ projectId: null,
+ circuitId: circuitOneId,
+ equipmentIdentifier: null,
+ input: {},
+ result: {},
+ appliedToCircuit: 0,
+ createdAt: new Date(1000),
+ });
+ repository.create({
+ id: "calc-b",
+ projectId: null,
+ circuitId: circuitOneId,
+ equipmentIdentifier: null,
+ input: {},
+ result: {},
+ appliedToCircuit: 0,
+ createdAt: new Date(2000),
+ });
+ repository.create({
+ id: "calc-other-circuit",
+ projectId: null,
+ circuitId: circuitTwoId,
+ equipmentIdentifier: null,
+ input: {},
+ result: {},
+ appliedToCircuit: 0,
+ createdAt: new Date(3000),
+ });
+
+ const rows = repository.listByCircuit(circuitOneId);
+ assert.equal(rows.length, 2);
+ assert.equal(rows[0].id, "calc-b");
+ assert.equal(rows[1].id, "calc-a");
+ });
+
+ it("marks an entry as applied", () => {
+ const repository = createRepository();
+ repository.create({
+ id: "calc-1",
+ projectId: null,
+ circuitId: null,
+ equipmentIdentifier: null,
+ input: {},
+ result: {},
+ appliedToCircuit: 0,
+ });
+ const updated = repository.markApplied("calc-1");
+ assert.equal(updated?.appliedToCircuit, 1);
+ });
+});
diff --git a/tests/cable-sizing-calculation.test.ts b/tests/cable-sizing-calculation.test.ts
new file mode 100644
index 0000000..89a935d
--- /dev/null
+++ b/tests/cable-sizing-calculation.test.ts
@@ -0,0 +1,209 @@
+import assert from "node:assert/strict";
+import { describe, it } from "node:test";
+import {
+ buildCableSizingAlerts,
+ calculateCableSizing,
+ isCableSizingDataVerified,
+ type CableSizingInput,
+} from "../src/cable-sizing/domain/cable-sizing-calculation.js";
+
+const BASE_INPUT: CableSizingInput = {
+ phase: 1,
+ mode: "power",
+ powerKw: 5,
+ cosPhi: 1,
+ voltage: 230,
+ lengthM: 30,
+ layingMethod: "C",
+ conductorMaterial: "copper",
+ insulation: "pvc",
+ ambientTemperatureC: 30,
+ groupingCircuits: 1,
+ maxVoltageDropPercent: 3,
+ harmonicNeutralLoad: "none",
+};
+
+describe("calculateCableSizing", () => {
+ it("matches the verified reference case (1~, 5 kW, 230 V, 30 m, method C, copper)", () => {
+ const result = calculateCableSizing(BASE_INPUT);
+ assert.equal(result.dataVerified, true);
+ assert.ok(Math.abs(result.operatingCurrentA - 21.739) < 0.01);
+ assert.equal(result.crossSectionByCapacityMm2, 2.5);
+ assert.equal(result.crossSectionByVoltageDropMm2, 4);
+ assert.equal(result.recommendedCrossSectionMm2, 4);
+ });
+
+ it("returns dataVerified: false and no numeric result for an unverified laying method", () => {
+ const result = calculateCableSizing({ ...BASE_INPUT, layingMethod: "A2" });
+ assert.equal(result.dataVerified, false);
+ assert.equal(result.recommendedCrossSectionMm2, null);
+ assert.equal(result.rows.length, 0);
+ // The operating current itself does not depend on the capacity table
+ // and is still reported so the UI can show at least that much.
+ assert.ok(Math.abs(result.operatingCurrentA - 21.739) < 0.01);
+ });
+
+ it("returns dataVerified: false for xlpe regardless of method", () => {
+ const result = calculateCableSizing({ ...BASE_INPUT, insulation: "xlpe" });
+ assert.equal(result.dataVerified, false);
+ });
+
+ it("isCableSizingDataVerified matches the six ported, verified methods only", () => {
+ for (const method of ["A1", "B2", "C", "E", "D1", "D2"] as const) {
+ assert.equal(isCableSizingDataVerified(method, "pvc"), true, method);
+ }
+ for (const method of ["A2", "B1", "F", "G"] as const) {
+ assert.equal(isCableSizingDataVerified(method, "pvc"), false, method);
+ }
+ });
+
+ it("applies the 0.86 harmonic reduction factor only for three-phase + 15to33Percent", () => {
+ const threePhase: CableSizingInput = {
+ ...BASE_INPUT,
+ phase: 3,
+ mode: "current",
+ currentA: 10,
+ powerKw: undefined,
+ voltage: 400,
+ };
+ const base = calculateCableSizing({ ...threePhase, harmonicNeutralLoad: "none" });
+ const derated = calculateCableSizing({
+ ...threePhase,
+ harmonicNeutralLoad: "15to33Percent",
+ });
+ assert.equal(base.harmonicReductionApplied, false);
+ assert.equal(derated.harmonicReductionApplied, true);
+ assert.ok(
+ Math.abs(derated.combinedDerationFactor - base.combinedDerationFactor * 0.86) < 1e-9
+ );
+
+ const singlePhaseWithHarmonics = calculateCableSizing({
+ ...BASE_INPUT,
+ harmonicNeutralLoad: "15to33Percent",
+ });
+ assert.equal(singlePhaseWithHarmonics.harmonicReductionApplied, false);
+ });
+
+ it("uses max(operatingCurrentA, existingProtectionRatedCurrentA) as the design current for cross-section selection", () => {
+ // Load alone (21.7 A) would recommend 4 mm² (see the reference case
+ // above); a 32 A breaker on the same circuit must still be covered by
+ // the cable (In <= Iz), so the recommendation should grow accordingly.
+ const withoutBreaker = calculateCableSizing(BASE_INPUT);
+ const withBreaker = calculateCableSizing({
+ ...BASE_INPUT,
+ existingProtectionRatedCurrentA: 32,
+ });
+ assert.equal(withoutBreaker.designCurrentA, withoutBreaker.operatingCurrentA);
+ assert.equal(withBreaker.designCurrentA, 32);
+ assert.ok(
+ (withBreaker.recommendedCrossSectionMm2 ?? 0) >=
+ (withoutBreaker.recommendedCrossSectionMm2 ?? 0)
+ );
+ assert.ok(withBreaker.protectionCoordination?.coordinated);
+ });
+
+ it("reports an oversized breaker as the limiting factor when no cross-section can cover it", () => {
+ const result = calculateCableSizing({
+ ...BASE_INPUT,
+ existingProtectionRatedCurrentA: 1000,
+ });
+ assert.equal(result.designCurrentA, 1000);
+ assert.equal(result.recommendedCrossSectionMm2, null);
+ // No cross-section satisfies the design current at all, so there is no
+ // "recommended but under-protected" case to flag - protectionCoordination
+ // is only meaningful once a recommendation exists.
+ assert.equal(result.protectionCoordination, null);
+
+ const alerts = buildCableSizingAlerts(
+ { ...BASE_INPUT, existingProtectionRatedCurrentA: 1000 },
+ result
+ );
+ assert.equal(alerts.length, 1);
+ assert.equal(alerts[0].kind, "critical");
+ assert.ok(alerts[0].text.includes("Vorhandene Sicherung"));
+ });
+});
+
+describe("buildCableSizingAlerts", () => {
+ it("returns a single critical alert for an unverified combination, no numeric claims", () => {
+ const input: CableSizingInput = { ...BASE_INPUT, layingMethod: "G" };
+ const result = calculateCableSizing(input);
+ const alerts = buildCableSizingAlerts(input, result);
+ assert.equal(alerts.length, 1);
+ assert.equal(alerts[0].kind, "critical");
+ assert.ok(alerts[0].text.includes("keine geprüften"));
+ });
+
+ it("returns an ok alert plus a max-length info alert for a clean, unremarkable case", () => {
+ const input: CableSizingInput = {
+ ...BASE_INPUT,
+ mode: "current",
+ currentA: 15,
+ powerKw: undefined,
+ lengthM: 3,
+ };
+ const result = calculateCableSizing(input);
+ const alerts = buildCableSizingAlerts(input, result);
+ assert.equal(alerts.length, 2);
+ assert.equal(alerts[0].kind, "ok");
+ assert.equal(alerts[1].kind, "info");
+ assert.ok(alerts[1].text.includes("Maximale Länge"));
+ });
+});
+
+describe("maxLengthForVoltageDropM", () => {
+ it("is the inverse of the voltage-drop formula: recalculating at that length gives back the limit", () => {
+ const result = calculateCableSizing(BASE_INPUT);
+ const recommendedRow = result.rows.find((row) => row.recommended);
+ assert.ok(recommendedRow?.maxLengthForVoltageDropM != null);
+
+ const atMaxLength = calculateCableSizing({
+ ...BASE_INPUT,
+ lengthM: recommendedRow!.maxLengthForVoltageDropM!,
+ });
+ const rowAtSameCrossSection = atMaxLength.rows.find(
+ (row) => row.crossSectionMm2 === recommendedRow!.crossSectionMm2
+ );
+ assert.ok(
+ Math.abs(rowAtSameCrossSection!.voltageDropPercent! - BASE_INPUT.maxVoltageDropPercent) <
+ 0.01
+ );
+ });
+
+ it("is null when there is no current flowing (division by zero guard)", () => {
+ const result = calculateCableSizing({ ...BASE_INPUT, mode: "current", currentA: 0, powerKw: undefined });
+ assert.ok(result.rows.every((row) => row.maxLengthForVoltageDropM === null));
+ });
+});
+
+describe("practical minimum cross-section for single_phase circuits", () => {
+ it("raises a smaller calculated recommendation to 2.5 mm² for single_phase circuits", () => {
+ // 1 A load at 30 m would normally recommend 1.5 mm² by calculation alone.
+ const smallLoad: CableSizingInput = { ...BASE_INPUT, mode: "current", currentA: 1, powerKw: undefined };
+ const withoutCategory = calculateCableSizing(smallLoad);
+ const withCategory = calculateCableSizing({ ...smallLoad, circuitCategory: "single_phase" });
+
+ assert.equal(withoutCategory.recommendedCrossSectionMm2, 1.5);
+ assert.equal(withoutCategory.practicalMinimumApplied, false);
+ assert.equal(withCategory.recommendedCrossSectionMm2, 2.5);
+ assert.equal(withCategory.practicalMinimumApplied, true);
+ });
+
+ it("never lowers a recommendation that already needs more than the practical minimum", () => {
+ const result = calculateCableSizing({ ...BASE_INPUT, circuitCategory: "single_phase" });
+ assert.equal(result.recommendedCrossSectionMm2, 4);
+ assert.equal(result.practicalMinimumApplied, false);
+ });
+
+ it("does not apply to lighting or three_phase categories", () => {
+ const smallLoad: CableSizingInput = { ...BASE_INPUT, mode: "current", currentA: 1, powerKw: undefined };
+ assert.equal(
+ calculateCableSizing({ ...smallLoad, circuitCategory: "lighting" }).recommendedCrossSectionMm2,
+ 1.5
+ );
+ assert.equal(
+ calculateCableSizing({ ...smallLoad, circuitCategory: "three_phase" }).recommendedCrossSectionMm2,
+ 1.5
+ );
+ });
+});
diff --git a/tests/project-device-row-sync-project-command.repository.test.ts b/tests/project-device-row-sync-project-command.repository.test.ts
index 593a7f6..75d56a8 100644
--- a/tests/project-device-row-sync-project-command.repository.test.ts
+++ b/tests/project-device-row-sync-project-command.repository.test.ts
@@ -13,13 +13,9 @@ import { ProjectHistoryRepository } from "../src/db/repositories/project-history
import { circuitDeviceRows } from "../src/db/schema/circuit-device-rows.js";
import { circuitSections } from "../src/db/schema/circuit-sections.js";
import { circuits } from "../src/db/schema/circuits.js";
-import { externalImportBatches } from "../src/db/schema/external-import-batches.js";
-import { externalModelObjects } from "../src/db/schema/external-model-objects.js";
-import { externalModelSources } from "../src/db/schema/external-model-sources.js";
import { projectDevices } from "../src/db/schema/project-devices.js";
import { projectRevisions } from "../src/db/schema/project-revisions.js";
import { projects } from "../src/db/schema/projects.js";
-import { externalCsvTestConfiguration } from "./fixtures/revit-csv-fixtures.js";
import {
createProjectDeviceRowSyncProjectCommand,
type ProjectDeviceSyncRowSnapshot,
@@ -167,79 +163,6 @@ function getRow(context: DatabaseContext, rowId: string) {
return row;
}
-function linkExternalObject(
- context: DatabaseContext,
- rowId: string,
- effectiveQuantity: number
-) {
- context.db
- .insert(externalModelSources)
- .values({
- id: "source-1",
- projectId: "project-1",
- name: "Revit",
- sourceType: "revit_csv",
- })
- .run();
- context.db
- .insert(externalImportBatches)
- .values({
- id: "batch-1",
- projectId: "project-1",
- sourceId: "source-1",
- importKind: "initial",
- importedAtIso: "2026-08-02T16:00:00.000Z",
- fileName: "revit.csv",
- sha256: "a".repeat(64),
- appliedProjectRevision: 0,
- configurationVersion: 1,
- configurationSnapshot: externalCsvTestConfiguration,
- originalBytes: Buffer.from("test"),
- document: { delimiter: ";", encoding: "utf-8", headers: [], rows: [] },
- })
- .run();
- context.db
- .insert(externalModelObjects)
- .values({
- id: "object-1",
- projectId: "project-1",
- sourceId: "source-1",
- ifcGuid: "ifc-1",
- lastSeenImportBatchId: "batch-1",
- lastAcceptedImportBatchId: "batch-1",
- acceptedSourceValues: {
- rowNumber: 2,
- roomNumber: "101",
- roomName: "Büro",
- familyAndType: "Leuchte: Standard",
- selectionMarker: "Leuchte",
- circuitIdentifier: "-1F1",
- power: "30",
- quantity: String(effectiveQuantity),
- additionalSourceValues: {},
- },
- planningValues: {
- displayName: "Leuchte",
- internalDeviceType: "luminaire",
- category: "single_phase",
- connectionKind: "fixed",
- effectiveQuantity,
- powerPerUnitW: 30,
- simultaneityFactor: 1,
- cosPhi: null,
- costGroup: null,
- remark: null,
- },
- overriddenFields: [],
- externalRoomMappingId: null,
- distributionBoardId: null,
- linkedProjectDeviceId: null,
- circuitDeviceRowId: rowId,
- presenceStatus: "present",
- })
- .run();
-}
-
function snapshot(
context: DatabaseContext,
rowId: string
@@ -551,112 +474,6 @@ describe("project-device row sync project-command repository", () => {
}
});
- it("keeps manualQuantity from exceeding quantity when a synced quantity shrinks", () => {
- const fixture = createTestDatabase();
- try {
- fixture.context.db
- .update(circuitDeviceRows)
- .set({ quantity: 5, manualQuantity: 5 })
- .where(eq(circuitDeviceRows.id, "row-1"))
- .run();
- const store = new ProjectDeviceRowSyncProjectCommandRepository(
- fixture.context.db
- );
- const expected = snapshot(fixture.context, "row-1");
- store.execute({
- projectId: "project-1",
- expectedRevision: 0,
- source: "user",
- command: createProjectDeviceRowSyncProjectCommand(
- "project-device-1",
- "synchronize",
- [
- {
- rowId: "row-1",
- expected,
- target: { ...expected, quantity: 2 },
- },
- ]
- ),
- });
- const row = getRow(fixture.context, "row-1");
- assert.equal(row.quantity, 2);
- assert.equal(row.manualQuantity, 2);
- } finally {
- fixture.context.close();
- }
- });
-
- it("subtracts linked external objects when a synced quantity shrinks", () => {
- const fixture = createTestDatabase();
- try {
- fixture.context.db
- .update(circuitDeviceRows)
- .set({ quantity: 5, manualQuantity: 2 })
- .where(eq(circuitDeviceRows.id, "row-1"))
- .run();
- linkExternalObject(fixture.context, "row-1", 3);
- const store = new ProjectDeviceRowSyncProjectCommandRepository(
- fixture.context.db
- );
- const expected = snapshot(fixture.context, "row-1");
- store.execute({
- projectId: "project-1",
- expectedRevision: 0,
- source: "user",
- command: createProjectDeviceRowSyncProjectCommand(
- "project-device-1",
- "synchronize",
- [{ rowId: "row-1", expected, target: { ...expected, quantity: 4 } }]
- ),
- });
- const row = getRow(fixture.context, "row-1");
- assert.equal(row.quantity, 4);
- assert.equal(row.manualQuantity, 1);
- } finally {
- fixture.context.close();
- }
- });
-
- it("rejects a synced quantity below the linked external total", () => {
- const fixture = createTestDatabase();
- try {
- fixture.context.db
- .update(circuitDeviceRows)
- .set({ quantity: 5, manualQuantity: 2 })
- .where(eq(circuitDeviceRows.id, "row-1"))
- .run();
- linkExternalObject(fixture.context, "row-1", 3);
- const store = new ProjectDeviceRowSyncProjectCommandRepository(
- fixture.context.db
- );
- const expected = snapshot(fixture.context, "row-1");
- assert.throws(
- () =>
- store.execute({
- projectId: "project-1",
- expectedRevision: 0,
- source: "user",
- command: createProjectDeviceRowSyncProjectCommand(
- "project-device-1",
- "synchronize",
- [{ rowId: "row-1", expected, target: { ...expected, quantity: 2 } }]
- ),
- }),
- /below the total quantity of linked external objects/
- );
- const row = getRow(fixture.context, "row-1");
- assert.equal(row.quantity, 5);
- assert.equal(row.manualQuantity, 2);
- assert.equal(
- fixture.context.db.select().from(projectRevisions).all().length,
- 0
- );
- } finally {
- fixture.context.close();
- }
- });
-
it("rolls back synchronized rows for a stale project revision", () => {
const fixture = createTestDatabase();
try {