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
91 lines
2.3 KiB
TypeScript
91 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { snapShapeFootprintToVisibleGrid } from "@/lib/gridSnap";
|
|
import { DEFAULT_WORKPLANE_WORKSPACE } from "@/lib/workplaneSettings";
|
|
import type { WorkplaneShape } from "@/types/sketchforge";
|
|
|
|
function groupedShape(): WorkplaneShape {
|
|
return {
|
|
id: "group",
|
|
name: "Group",
|
|
kind: "mesh",
|
|
color: "#d41721",
|
|
x: 3.2,
|
|
z: -1.7,
|
|
elevation: 2.4,
|
|
size: 43.5,
|
|
width: 43.5,
|
|
depth: 19.8,
|
|
height: 31.25,
|
|
rotation: 0,
|
|
groupedBaseWidth: 43.5,
|
|
groupedBaseDepth: 19.8,
|
|
groupedBaseHeight: 31.25,
|
|
groupedShapes: [
|
|
{
|
|
id: "child-a",
|
|
name: "Child A",
|
|
kind: "box",
|
|
color: "#d41721",
|
|
x: -10.75,
|
|
z: 1.2,
|
|
elevation: 0,
|
|
size: 20,
|
|
width: 20,
|
|
depth: 12,
|
|
height: 20,
|
|
rotation: 0,
|
|
},
|
|
{
|
|
id: "child-b",
|
|
name: "Child B",
|
|
kind: "box",
|
|
color: "#0098c7",
|
|
x: 14.5,
|
|
z: -2.8,
|
|
elevation: 0,
|
|
size: 10,
|
|
width: 8,
|
|
depth: 10,
|
|
height: 31.25,
|
|
rotation: 0,
|
|
},
|
|
],
|
|
};
|
|
}
|
|
|
|
describe("Snap to Grid", () => {
|
|
it("translates a group footprint to the visible grid without resizing it or changing child offsets", () => {
|
|
const group = groupedShape();
|
|
const snapped = snapShapeFootprintToVisibleGrid(
|
|
group,
|
|
{ minX: -17.3, minZ: -11.4 },
|
|
{ ...DEFAULT_WORKPLANE_WORKSPACE, gridBlockSize: 5 },
|
|
);
|
|
|
|
expect(snapped.x).toBe(5.5);
|
|
expect(snapped.z).toBe(-0.3);
|
|
expect(-17.3 + snapped.x - group.x).toBeCloseTo(-15, 6);
|
|
expect(-11.4 + snapped.z - group.z).toBeCloseTo(-10, 6);
|
|
expect(snapped).toMatchObject({
|
|
elevation: 2.4,
|
|
width: 43.5,
|
|
depth: 19.8,
|
|
height: 31.25,
|
|
size: 43.5,
|
|
});
|
|
expect(snapped.groupedShapes).toBe(group.groupedShapes);
|
|
});
|
|
|
|
it("uses the rendered grid origin for custom workplane dimensions", () => {
|
|
const group = groupedShape();
|
|
const snapped = snapShapeFootprintToVisibleGrid(
|
|
group,
|
|
{ minX: -18, minZ: -13 },
|
|
{ ...DEFAULT_WORKPLANE_WORKSPACE, width: 203, depth: 187, gridBlockSize: 10 },
|
|
);
|
|
|
|
expect(-18 + snapped.x - group.x).toBeCloseTo(-21.5, 6);
|
|
expect(-13 + snapped.z - group.z).toBeCloseTo(-13.5, 6);
|
|
});
|
|
});
|