- Doppelklick auf Raumstempel öffnet das Fenster Objekteinstellungen mit fokussiertem Abschnitt „Raumstempel“ (RoomStampSection, openObjectSettings(deps, "roomStamp")); Overlay-Dialog RoomStampEditor(Host) und TextEditorDialog entfernt. - Modell RoomStampFont (Familie, Grösse, fett, kursiv, Farbe) am Stempel und je Zeile; Kern löst Zeile > Stempel > Vorgabe auf, Zusatzzeilen tragen StampLine.marks; stamp_block*, Anzeige-Szene (gemessene Grundlinien), SVG, Druck-SVG, DXF und HTML-Block lesen sie. Eigene Grössen gehen vor Überdeckung (fit_room_stamp_with). - Mehrfachauswahl: „gemischt“, ein Undo-Schritt für alle gewählten Räume (state/roomStampEdit.ts). - Bezugspunkt und Masse nur im Objekt-Info-Panel, nicht im Fenster (ObjectInfoPanel showPlacement=false). - Tests: Rust (Schrift/Fallback/Überdeckung/Szene), vitest (Abschnitt, gemischt, Undo, Fenster ohne Platzierung, Doppelklick-Ziel), e2e roomStamp218.
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { defaultRoomStamp, roomDisplayName, setStampFontAttr } from "./roomStamp";
|
|
import type { Room } from "./types";
|
|
|
|
function makeRoom(over: Partial<Room> = {}): Room {
|
|
return {
|
|
id: "r1",
|
|
type: "room",
|
|
floorId: "f1",
|
|
categoryCode: "45",
|
|
siaCategory: "HNF",
|
|
name: "Wohnen",
|
|
boundary: [
|
|
{ x: 0, y: 0 },
|
|
{ x: 4, y: 0 },
|
|
{ x: 4, y: 3 },
|
|
{ x: 0, y: 3 },
|
|
],
|
|
color: "#123456",
|
|
...over,
|
|
};
|
|
}
|
|
|
|
describe("defaultRoomStamp", () => {
|
|
it("leitet Name/Flags aus dem Raum ab", () => {
|
|
const stamp = defaultRoomStamp(makeRoom());
|
|
expect(stamp.name).toBe("Wohnen");
|
|
expect(stamp.showFloorArea).toBeUndefined();
|
|
expect(stamp.showUsage).toBeUndefined();
|
|
expect(stamp.number).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("roomDisplayName", () => {
|
|
it("faellt auf room.name zurück ohne Stempel", () => {
|
|
expect(roomDisplayName(makeRoom())).toBe("Wohnen");
|
|
});
|
|
|
|
it("zieht name + nameLine2 zusammen", () => {
|
|
const room = makeRoom({
|
|
stamp: { name: "Bad", nameLine2: "WC", showFloorArea: true, showUsage: true },
|
|
});
|
|
expect(roomDisplayName(room)).toBe("Bad WC");
|
|
});
|
|
|
|
it("nutzt nur name ohne nameLine2", () => {
|
|
const room = makeRoom({
|
|
stamp: { name: "Küche", showFloorArea: true, showUsage: true },
|
|
});
|
|
expect(roomDisplayName(room)).toBe("Küche");
|
|
});
|
|
});
|
|
|
|
describe("setStampFontAttr [218]", () => {
|
|
const base = { name: "Wohnen" };
|
|
it("setzt und entfernt Eigenschaften je Zeile, eine leere Schrift entfällt", () => {
|
|
const a = setStampFontAttr(base, "nameFont", "sizePt", 18);
|
|
expect(a.nameFont).toEqual({ sizePt: 18 });
|
|
const b = setStampFontAttr(a, "nameFont", "family", "Jost");
|
|
expect(b.nameFont).toEqual({ sizePt: 18, family: "Jost" });
|
|
const c = setStampFontAttr(setStampFontAttr(b, "nameFont", "sizePt", undefined), "nameFont", "family", "");
|
|
expect("nameFont" in c).toBe(false);
|
|
expect(a).toEqual({ name: "Wohnen", nameFont: { sizePt: 18 } }); // unverändert (rein)
|
|
});
|
|
it("Unsinn (Grösse <= 0) setzt nichts", () => {
|
|
expect("font" in setStampFontAttr(base, "font", "sizePt", 0)).toBe(false);
|
|
expect(setStampFontAttr(base, "areaFont", "bold", true).areaFont).toEqual({ bold: true });
|
|
});
|
|
});
|