import { describe, expect, it } from "vitest"; import type { WorkplaneShape } from "@/types/sketchforge"; describe("Wall Opening & Window Cutout Unit Tests", () => { it("calculates correct through-cutting hole dimensions and position for a wall", () => { const wall: WorkplaneShape = { id: "wall-sample", name: "Taşıyıcı Duvar", kind: "box", color: "#94a3b8", x: 0, z: 0, width: 120, depth: 20, height: 60, size: 60, elevation: 0, rotation: 0, }; const windowConfig = { width: 30, height: 30, elevation: 20, // sill height offsetX: 0, }; // Calculate hole box penetrating through the wall const holeDepth = (wall.depth ?? 20) + 6; // 26mm, ensures 3mm overhang on each side const holeShape: WorkplaneShape = { id: "hole-1", name: "Pencere Kesici", kind: "box", color: "#6b7280", x: (wall.x ?? 0) + windowConfig.offsetX, z: wall.z ?? 0, width: windowConfig.width, depth: holeDepth, height: windowConfig.height, size: windowConfig.height, elevation: (wall.elevation ?? 0) + windowConfig.elevation, rotation: wall.rotation ?? 0, hole: true, }; expect(holeShape.hole).toBe(true); expect(holeShape.depth).toBeGreaterThan(wall.depth ?? 0); expect(holeShape.elevation).toBe(20); expect(holeShape.width).toBe(30); expect(holeShape.height).toBe(30); }); it("handles door cutout at zero elevation (ground level)", () => { const wall: WorkplaneShape = { id: "wall-sample-door", name: "Giriş Duvarı", kind: "box", color: "#94a3b8", x: 50, z: -20, width: 100, depth: 20, height: 60, size: 60, elevation: 0, rotation: 0, }; const doorConfig = { width: 25, height: 50, elevation: 0, // door sill at ground offsetX: -20, }; const holeShape: WorkplaneShape = { id: "door-hole", name: "Kapı Kesici", kind: "box", color: "#6b7280", x: (wall.x ?? 0) + doorConfig.offsetX, z: wall.z ?? 0, width: doorConfig.width, depth: (wall.depth ?? 20) + 6, height: doorConfig.height, size: doorConfig.height, elevation: (wall.elevation ?? 0) + doorConfig.elevation, rotation: wall.rotation ?? 0, hole: true, }; expect(holeShape.elevation).toBe(0); expect(holeShape.x).toBe(30); // 50 - 20 expect(holeShape.height).toBe(50); }); });