[5] Doppelspur Door/Opening aufgeloest: Formatversion 2 migriert Legacy-Tueren zu Oeffnungen (kind door), Project.doors und Door entfernt, Legacy-Pfade in Plan/Schnitt/Ansicht/3D/Liste gestrichen; Tests angepasst

This commit is contained in:
karim committed 2026-10-27 20:00:24 +01:00
1 parent 346798eee6
commit b0270bae3e
94 files changed
+100 -367

No files matched your search

+24 -2
View File
@@ -31,11 +31,11 @@ describe("Projektdatei-Format", () => {
expect(!r.ok && r.error).toMatch(/walls/);
});
it("tolerant: fehlende Listen ergaenzt, falsche Typen geleert, unbekannte Felder gemeldet und behalten", () => {
const { doors: _d, ...rest } = sampleProject;
const { lineStyles: _l, ...rest } = sampleProject;
const r = parseProjectFile(JSON.stringify({ ...rest, hatches: "x", zukunft: 1 }));
expect(r.ok).toBe(true);
if (!r.ok) return;
expect(r.project.doors).toEqual([]);
expect(r.project.lineStyles).toEqual([]);
expect(r.project.hatches).toEqual([]);
expect((r.project as unknown as { zukunft: number }).zukunft).toBe(1);
expect(r.warnings.join(" ")).toMatch(/hatches/);
@@ -45,3 +45,25 @@ describe("Projektdatei-Format", () => {
expect(parseProjectFile(JSON.stringify({ ...sampleProject, formatVersion: "1" })).ok).toBe(false);
});
});
describe("Migration 1 → 2: Legacy-Türen werden Öffnungen", () => {
it("doors → openings (kind door), Feld doors entfällt, Kollisions-ids bleiben eindeutig", () => {
const base = JSON.parse(JSON.stringify(sampleProject)) as Record<string, unknown>;
const existing = (base.openings as Array<{ id: string }>)[0].id;
base.formatVersion = 1;
base.doors = [
{ id: "TX", type: "door", hostWallId: "W1", categoryCode: "21", position: 0.5, width: 0.9, height: 2.1, swing: "right", hinge: "end" },
{ id: existing, type: "door", hostWallId: "W1", categoryCode: "21", position: 3, width: 0.8, height: 2, swing: "left", hinge: "start" },
];
const r = parseProjectFile(JSON.stringify(base));
expect(r.ok).toBe(true);
if (!r.ok) return;
expect(r.migratedFrom).toBe(1);
expect("doors" in r.project).toBe(false);
const ids = (r.project.openings ?? []).map((o) => o.id);
expect(new Set(ids).size).toBe(ids.length);
const tx = r.project.openings!.find((o) => o.id === "TX")!;
expect(tx).toMatchObject({ kind: "door", position: 0.5, width: 0.9, height: 2.1, sillHeight: 0, swing: "right", hinge: "end", type: "opening" });
expect(r.project.openings!.some((o) => o.id === `${existing}-t` && o.kind === "door")).toBe(true);
});
});