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
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ı
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import {
|
||||
MAX_DWG_BYTES,
|
||||
convertDwgBytesToDxf,
|
||||
importedShapeFromDwg,
|
||||
loadLibreDwgKernel,
|
||||
readDwgVersion,
|
||||
} from "@/lib/dwgKernel";
|
||||
|
||||
function asciiBytes(text: string) {
|
||||
return new Uint8Array(Array.from(text, (char) => char.charCodeAt(0)));
|
||||
}
|
||||
|
||||
describe("LibreDWG WebAssembly Kernel", () => {
|
||||
it("initializes LibreDWG WebAssembly module with virtual filesystem and cwrap", async () => {
|
||||
const wasm = await loadLibreDwgKernel();
|
||||
expect(wasm).toBeDefined();
|
||||
expect(wasm.FS).toBeDefined();
|
||||
expect(typeof wasm.FS.writeFile).toBe("function");
|
||||
expect(typeof wasm.FS.readFile).toBe("function");
|
||||
expect(typeof wasm.cwrap).toBe("function");
|
||||
});
|
||||
|
||||
it("reads the DWG version signature", () => {
|
||||
expect(readDwgVersion(asciiBytes("AC1032"))).toBe("AC1032");
|
||||
expect(readDwgVersion(asciiBytes("AC1015xxxxxxxx"))).toBe("AC1015");
|
||||
expect(readDwgVersion(asciiBytes("DXF"))).toBeNull();
|
||||
expect(readDwgVersion(asciiBytes("hello world"))).toBeNull();
|
||||
expect(readDwgVersion(new Uint8Array([]))).toBeNull();
|
||||
});
|
||||
|
||||
it("rejects files without a DWG signature with a clear Turkish message", async () => {
|
||||
const notADwg = asciiBytes("Bu bir metin dosyasi, DWG degil. ".repeat(4));
|
||||
await expect(convertDwgBytesToDxf(notADwg)).rejects.toThrow(
|
||||
/geçerli bir AutoCAD DWG çizimi değil/,
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects unsupported DWG versions with the supported range", async () => {
|
||||
const futureDwg = asciiBytes(`AC1035${"x".repeat(120)}`);
|
||||
await expect(convertDwgBytesToDxf(futureDwg)).rejects.toThrow(
|
||||
/Bu DWG sürümü \(AC1035\) desteklenmiyor/,
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects oversized DWG files before loading the kernel", async () => {
|
||||
const tooLarge = new Uint8Array(MAX_DWG_BYTES + 1);
|
||||
tooLarge.set(asciiBytes("AC1032"), 0);
|
||||
await expect(convertDwgBytesToDxf(tooLarge)).rejects.toThrow(/DWG dosyası çok büyük/);
|
||||
});
|
||||
|
||||
it("handles corrupted/truncated DWG files with clear descriptive error", async () => {
|
||||
// Valid version signature but no readable DWG sections at all.
|
||||
const fakeDwgBytes = asciiBytes("AC1015\u0000\u0000\u0000\u0000");
|
||||
await expect(convertDwgBytesToDxf(fakeDwgBytes)).rejects.toThrow(
|
||||
/DWG çizimi DXF'e dönüştürülemedi \(dosya sürümü: AC1015/,
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects empty bytes immediately", async () => {
|
||||
await expect(convertDwgBytesToDxf(new Uint8Array([]))).rejects.toThrow(
|
||||
/Geçersiz veya boş DWG dosyası/,
|
||||
);
|
||||
});
|
||||
|
||||
it("converts a real AutoCAD DWG file to DXF and constructs a 3D solid shape", async () => {
|
||||
const dwgPath = path.resolve(process.cwd(), "test_circle_2010.dwg");
|
||||
if (fs.existsSync(dwgPath)) {
|
||||
const bytes = fs.readFileSync(dwgPath);
|
||||
const shape = await importedShapeFromDwg("test_circle_2010.dwg", bytes);
|
||||
expect(shape.kind).toBe("mesh");
|
||||
expect(shape.importedMesh).toBeDefined();
|
||||
expect(shape.importedMesh?.triangleCount).toBeGreaterThan(0);
|
||||
expect(shape.importedMesh?.baseWidth).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user