import { describe, expect, it } from "vitest"; import type { WorkplaneShape } from "@/types/sketchforge"; describe("Architectural Layers & Tags System", () => { const sampleShapes: WorkplaneShape[] = [ { id: "wall-1", name: "Dış Duvar", kind: "box", color: "#f8fafc", x: 0, z: 0, width: 50, depth: 40, height: 30, size: 50, rotation: 0, tag: "Duvarlar", hidden: false, }, { id: "roof-1", name: "Kırma Çatı", kind: "pyramid", color: "#ef4444", x: 0, z: 0, elevation: 30, width: 54, depth: 44, height: 20, size: 54, rotation: 0, tag: "Çatı", hidden: false, }, { id: "door-1", name: "Giriş Kapısı Boşluğu", kind: "box", hole: true, color: "#000000", x: 0, z: 20, width: 10, depth: 12, height: 20, size: 20, rotation: 0, tag: "Kapı & Boşluklar", hidden: false, }, ]; it("correctly groups shapes into distinct architectural tags", () => { const tagMap = new Map(); sampleShapes.forEach((s) => { const tag = s.tag || "Katman 0 (Genel)"; const list = tagMap.get(tag) || []; list.push(s); tagMap.set(tag, list); }); expect(tagMap.has("Duvarlar")).toBe(true); expect(tagMap.has("Çatı")).toBe(true); expect(tagMap.has("Kapı & Boşluklar")).toBe(true); expect(tagMap.get("Çatı")?.length).toBe(1); expect(tagMap.get("Çatı")?.[0].id).toBe("roof-1"); }); it("toggling tag visibility hides only shapes in the target tag", () => { const targetTag = "Çatı"; const updated = sampleShapes.map((s) => { if (s.tag === targetTag) { return { ...s, hidden: true }; } return s; }); const roof = updated.find((s) => s.id === "roof-1"); const wall = updated.find((s) => s.id === "wall-1"); const door = updated.find((s) => s.id === "door-1"); expect(roof?.hidden).toBe(true); expect(wall?.hidden).toBe(false); expect(door?.hidden).toBe(false); }); it("defaults un-tagged shapes to 'Katman 0 (Genel)'", () => { const genericShape: WorkplaneShape = { id: "cube-new", name: "Kutu", kind: "box", color: "#cbd5e1", x: 20, z: 20, width: 20, depth: 20, height: 20, size: 20, rotation: 0, }; const assignedTag = (genericShape.tag && genericShape.tag.trim()) || "Katman 0 (Genel)"; expect(assignedTag).toBe("Katman 0 (Genel)"); }); });