Files
snapcad-studio/tests/unit/architecturalLayers.test.ts
T
Enes Yakıştır 33b0940012
Build and Push Docker Images / build (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
feat: SnapCAD Studio'yu YakHub deposuna taşı
- DWG/DXF içe aktarma ve .skf yeniden açma düzeltmeleri

- YakNet Bulut eşitlemede boş/eski kopya koruması ve yerel-only proje bildirimi

- Panelden içe aktarma duyuruları ve erişilebilir Türkçe hata mesajları

- AGPL-3.0 lisansı, README ve YakHub bağlantıları
2026-10-25 18:20:21 +03:00

108 lines
2.6 KiB
TypeScript

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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<string, WorkplaneShape[]>();
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)");
});
});