Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
87 lines
3.4 KiB
TypeScript
87 lines
3.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
||||
|
|
import { detachComponentInstance, instantiateComponentShapes } from "@/lib/cloudComponents";
|
|||
|
|
import type { WorkplaneShape } from "@/types/sketchforge";
|
|||
|
|
|
|||
|
|
function makeSampleShape(overrides: Partial<WorkplaneShape> = {}): WorkplaneShape {
|
|||
|
|
return {
|
|||
|
|
id: "orig-1",
|
|||
|
|
name: "Ahşap Kolon",
|
|||
|
|
kind: "box",
|
|||
|
|
color: "#b45309",
|
|||
|
|
x: 50,
|
|||
|
|
z: 30,
|
|||
|
|
elevation: 10,
|
|||
|
|
width: 20,
|
|||
|
|
depth: 20,
|
|||
|
|
height: 100,
|
|||
|
|
size: 20,
|
|||
|
|
rotation: 0,
|
|||
|
|
texture: "wood",
|
|||
|
|
componentDefId: "comp-kolon",
|
|||
|
|
componentName: "Ahşap Kolon",
|
|||
|
|
...overrides,
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
describe("YakNet 3B Cloud Components — Instantiation & Make Unique", () => {
|
|||
|
|
it("instantiates multi-part components as a rigid centered unit with unique IDs", () => {
|
|||
|
|
const leg1 = makeSampleShape({ id: "leg-1", x: 40, z: 20, elevation: 0, width: 10, depth: 10, height: 40 });
|
|||
|
|
const leg2 = makeSampleShape({ id: "leg-2", x: 80, z: 20, elevation: 0, width: 10, depth: 10, height: 40 });
|
|||
|
|
const top = makeSampleShape({ id: "top-1", x: 60, z: 20, elevation: 40, width: 60, depth: 30, height: 6 });
|
|||
|
|
|
|||
|
|
let seq = 0;
|
|||
|
|
const placed = instantiateComponentShapes([leg1, leg2, top], {
|
|||
|
|
componentDefId: "yaknet-masa-01",
|
|||
|
|
componentName: "Çalışma Masası",
|
|||
|
|
targetOffset: { x: 0, z: 0, elevation: 5 },
|
|||
|
|
createId: (prefix) => `${prefix}-${++seq}`,
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
expect(placed).toHaveLength(3);
|
|||
|
|
expect(new Set(placed.map((s) => s.id)).size).toBe(3);
|
|||
|
|
|
|||
|
|
// Relative distances preserved while center aligns on (0, 0) and base on y=5
|
|||
|
|
expect(placed[0].x).toBe(-20);
|
|||
|
|
expect(placed[1].x).toBe(20);
|
|||
|
|
expect(placed[2].x).toBe(0);
|
|||
|
|
expect(placed[0].elevation).toBe(5);
|
|||
|
|
expect(placed[2].elevation).toBe(45);
|
|||
|
|
expect(placed.every((s) => s.componentDefId === "yaknet-masa-01")).toBe(true);
|
|||
|
|
expect(placed.every((s) => s.componentName === "Çalışma Masası")).toBe(true);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
it("deep-clones groupedShapes and sketchProfile so instances do not share mutable nested references", () => {
|
|||
|
|
const child = makeSampleShape({ id: "child-1" });
|
|||
|
|
const parent = makeSampleShape({
|
|||
|
|
id: "parent-1",
|
|||
|
|
groupedShapes: [child],
|
|||
|
|
sketchProfile: {
|
|||
|
|
points: [{ id: "p1", x: 0, z: 0, mode: "corner" }],
|
|||
|
|
segments: [{ id: "s1", startPointId: "p1", endPointId: "p1", kind: "line" }],
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
let seq = 0;
|
|||
|
|
const [inst] = instantiateComponentShapes([parent], {
|
|||
|
|
createId: (prefix) => `${prefix}-${++seq}`,
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
expect(inst.id).not.toBe(parent.id);
|
|||
|
|
expect(inst.groupedShapes?.[0].id).not.toBe(child.id);
|
|||
|
|
expect(inst.sketchProfile?.points[0]).not.toBe(parent.sketchProfile?.points[0]);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
it("detaches selected component instances cleanly on Make Unique", () => {
|
|||
|
|
const a = makeSampleShape({ id: "win-1", componentDefId: "comp-win", componentName: "Pencere" });
|
|||
|
|
const b = makeSampleShape({ id: "win-2", x: 90, componentDefId: "comp-win", componentName: "Pencere" });
|
|||
|
|
const plain = makeSampleShape({ id: "wall-1", componentDefId: undefined, componentName: undefined });
|
|||
|
|
|
|||
|
|
const detached = detachComponentInstance([a, b, plain], ["win-2"], () => "compdef-unique-1");
|
|||
|
|
|
|||
|
|
expect(detached[0].componentDefId).toBe("comp-win");
|
|||
|
|
expect(detached[0].componentName).toBe("Pencere");
|
|||
|
|
expect(detached[1].componentDefId).toBe("compdef-unique-1");
|
|||
|
|
expect(detached[1].componentName).toBe("Pencere (Benzersiz)");
|
|||
|
|
expect(detached[2].componentDefId).toBeUndefined();
|
|||
|
|
});
|
|||
|
|
});
|