release: SnapCAD Studio 1.0.11 (Mimari BIM & Metraj Studyosu, IFC4 ihraci, canli guncelleme ilerlemesi, YakNet SSO iyilestirmesi)
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s

This commit is contained in:
Enes Yakıştır
2026-11-12 11:57:21 +03:00
parent ee28672e23
commit 6769717276
28 changed files with 8103 additions and 1115 deletions
+188
View File
@@ -0,0 +1,188 @@
import { describe, expect, it } from "vitest";
import { exportShapesToIfc4, classifyShapeForIfc } from "@/lib/ifcExport";
import { importedShapeWithDetailsFromIfc } from "@/lib/ifcImport";
import {
DEFAULT_BUILDING_STOREYS,
calculateArchitecturalBoq,
exportBoqToCsv,
exportBoqToPdfBytes,
auditArchitecturalCodeCompliance,
isolateStoreyVisibility,
duplicateStoreyToLevel,
generateParametricStair,
generateParametricRoof,
generateParametricOpeningUnit,
generateStructuralFrameGrid,
generateAdvancedTerrainWithPad,
} from "@/lib/architecturalBimEngine";
import {
TURKEY_81_PROVINCES_SOLAR_LOCATIONS,
SOLAR_LOCATIONS,
DEFAULT_SOLAR_SETTINGS,
calculateDailySolarSweep,
} from "@/lib/solarSystem";
import { SNAPCAD_PREFABS } from "@/lib/snapcadPrefabs";
describe("Architectural BIM Engine, IFC4 Export, BOQ Metraj & Code Auditor", () => {
it("exports 3D architectural shapes to IFC4 and round-trips through web-ifc WASM", async () => {
const villaPrefab = SNAPCAD_PREFABS.find((p) => p.id === "modern-terrace-villa");
expect(villaPrefab).toBeDefined();
const shapes = villaPrefab!.buildShapes();
const exported = exportShapesToIfc4(shapes, {
projectName: "Modern Terasli Villa",
scaleFactorToMm: 100, // 1:100 architectural scale -> real millimeters
});
expect(exported.ifcText).toContain("FILE_SCHEMA(('IFC4'));");
expect(exported.ifcText).toContain("IFCPROJECT(");
expect(exported.ifcText).toContain("IFCBUILDINGSTOREY(");
expect(exported.ifcText).toContain("IFCELEMENTQUANTITY(");
expect(exported.productCount).toBeGreaterThanOrEqual(5);
expect(exported.storeyCount).toBeGreaterThanOrEqual(1);
// Round-trip parse with web-ifc WASM
const reimported = await importedShapeWithDetailsFromIfc("villa_bim.ifc", exported.bytes);
expect(reimported.schema).toBe("IFC4");
expect(reimported.productCount).toBeGreaterThanOrEqual(5);
expect(reimported.triangleCount).toBeGreaterThanOrEqual(24);
});
it("classifies BIM entities and calculates BOQ (Metraj & Keşif) with CSV and PDF export", () => {
const frameShapes = generateStructuralFrameGrid({
baysX: 2,
baysZ: 2,
spanX: 40,
spanZ: 40,
storeyHeight: 32,
includeFoundationSlab: true,
includeCeilingSlab: true,
});
const roofShapes = generateParametricRoof({
kind: "gable",
width: 84,
depth: 84,
ridgeHeight: 18,
baseElevation: 64,
});
const openingShapes = [
...generateParametricOpeningUnit({ kind: "double-window", width: 18, height: 15 }),
...generateParametricOpeningUnit({ kind: "steel-entrance-door", width: 12, height: 21 }),
];
const allShapes = [...frameShapes, ...roofShapes, ...openingShapes];
expect(classifyShapeForIfc(roofShapes[0])).toBe("IFCROOF");
const boq = calculateArchitecturalBoq(allShapes, {
projectName: "Test Mimari Bina",
scaleMode: "1:100",
});
expect(boq.grossFloorAreaM2).toBeGreaterThan(50);
expect(boq.totalStructuralConcreteM3).toBeGreaterThan(5);
expect(boq.totalRoofAreaM2).toBeGreaterThan(50);
expect(boq.windowCount).toBeGreaterThanOrEqual(1);
expect(boq.doorCount).toBeGreaterThanOrEqual(1);
expect(boq.totalEstimatedCostTry).toBeGreaterThan(50_000);
expect(boq.items.length).toBeGreaterThanOrEqual(4);
const csv = exportBoqToCsv(boq);
expect(csv.startsWith("\uFEFF")).toBe(true);
expect(csv).toContain("15.150.1005");
expect(csv).toContain("Test Mimari Bina");
const pdfBytes = exportBoqToPdfBytes(boq);
expect(pdfBytes.byteLength).toBeGreaterThan(500);
const pdfHeader = new TextDecoder().decode(pdfBytes.slice(0, 5));
expect(pdfHeader).toBe("%PDF-");
});
it("manages multi-storey isolation and duplicates a storey to an upper floor level", () => {
const groundStorey = DEFAULT_BUILDING_STOREYS[1]; // Zemin Kat (elevation 0)
const firstStorey = DEFAULT_BUILDING_STOREYS[2]; // 1. Normal Kat (elevation 32)
const gridShapes = generateStructuralFrameGrid({
baysX: 1,
baysZ: 1,
spanX: 40,
spanZ: 40,
baseElevation: groundStorey.elevation,
storeyTag: groundStorey.tag,
});
const duplicated = duplicateStoreyToLevel(
gridShapes,
groundStorey,
firstStorey,
DEFAULT_BUILDING_STOREYS,
);
expect(duplicated.clonedShapes.length).toBe(gridShapes.length);
expect(duplicated.nextShapes.length).toBe(gridShapes.length * 2);
expect(duplicated.clonedShapes[0].elevation).toBeCloseTo(
(gridShapes[0].elevation || 0) + (firstStorey.elevation - groundStorey.elevation),
2,
);
const isolated = isolateStoreyVisibility(
duplicated.nextShapes,
firstStorey,
DEFAULT_BUILDING_STOREYS,
);
const visibleCount = isolated.filter((s) => !s.hidden).length;
expect(visibleCount).toBe(duplicated.clonedShapes.length);
});
it("generates parametric stairs (straight, L, U, spiral) and audits Turkish building code compliance", () => {
const straightStairs = generateParametricStair({ kind: "straight", stepCount: 18, totalHeight: 31 });
const lStairs = generateParametricStair({ kind: "l-shaped", stepCount: 18, totalHeight: 31 });
const uStairs = generateParametricStair({ kind: "u-shaped", stepCount: 18, totalHeight: 31 });
const spiralStairs = generateParametricStair({ kind: "spiral", stepCount: 16, totalHeight: 32 });
expect(straightStairs.length).toBeGreaterThanOrEqual(18);
expect(lStairs.length).toBeGreaterThanOrEqual(18);
expect(uStairs.length).toBeGreaterThanOrEqual(18);
expect(spiralStairs.length).toBeGreaterThanOrEqual(16);
const audit = auditArchitecturalCodeCompliance(uStairs, "1:100");
expect(audit.score).toBeGreaterThanOrEqual(50);
expect(audit.checks.some((c) => c.id === "stair-blondel")).toBe(true);
});
it("triangulates 3D site topography using simplex-noise + delaunator and computes cut/fill earthwork", () => {
const terrain = generateAdvancedTerrainWithPad({
preset: "hills",
width: 220,
depth: 220,
maxHeight: 22,
gridResolution: 14,
includeBuildingPad: true,
});
expect(terrain.triangleCount).toBeGreaterThanOrEqual(300);
expect(terrain.terrainShape.importedMesh?.positions.length).toBe(terrain.triangleCount * 9);
expect(terrain.padShape).not.toBeNull();
expect(terrain.excavationCutVolumeM3 + terrain.embankmentFillVolumeM3).toBeGreaterThan(0);
});
it("includes all 81 Turkish provinces with TS 825 zones and computes daily facade solar sweep", () => {
expect(TURKEY_81_PROVINCES_SOLAR_LOCATIONS).toHaveLength(81);
expect(TURKEY_81_PROVINCES_SOLAR_LOCATIONS[0].plateCode).toBe("01");
expect(TURKEY_81_PROVINCES_SOLAR_LOCATIONS[80].plateCode).toBe("81");
expect(SOLAR_LOCATIONS.length).toBeGreaterThanOrEqual(88);
const sweep = calculateDailySolarSweep({
...DEFAULT_SOLAR_SETTINGS,
locationIndex: 0, // İstanbul
month: 5, // Haziran
day: 21,
});
expect(sweep.daylightDurationHours).toBeGreaterThan(12);
expect(sweep.southHours).toBeGreaterThan(4);
expect(sweep.eastHours).toBeGreaterThan(2);
expect(sweep.westHours).toBeGreaterThan(2);
expect(sweep.ts825Standard.zone).toBe(2);
expect(sweep.hourlyPoints.length).toBeGreaterThanOrEqual(15);
});
});
+57 -1
View File
@@ -4,6 +4,8 @@ import { describe, expect, it } from "vitest";
import {
exportFiltersForFilename,
formatFriendlyUpdateError,
formatUpdateBytes,
formatUpdateTransferSummary,
getDesktopBridge,
isAllowedExternalUrl,
isDesktopRuntime,
@@ -61,7 +63,9 @@ describe("desktopBridge", () => {
it("distinguishes global vs 3D-editor-only menu commands", () => {
expect(isEditorOnlyMenuAction("file:new")).toBe(false);
expect(isEditorOnlyMenuAction("file:open")).toBe(false);
expect(isEditorOnlyMenuAction("file:save-and-update")).toBe(false);
expect(isEditorOnlyMenuAction("file:dashboard")).toBe(false);
expect(parseMenuAction("file:save-and-update")).toBe("file:save-and-update");
expect(isEditorOnlyMenuAction("window:drawing")).toBe(false);
expect(isEditorOnlyMenuAction("window:classrooms")).toBe(false);
expect(isEditorOnlyMenuAction("window:shared")).toBe(false);
@@ -128,6 +132,58 @@ describe("desktopBridge", () => {
expect(formatFriendlyUpdateError("Özel sunucu mesajı")).toBe("Özel sunucu mesajı");
});
it("formats live update download byte sizes and transfer summaries", () => {
expect(formatUpdateBytes(0)).toBe("0 B");
expect(formatUpdateBytes(512 * 1024)).toBe("512 KB");
expect(formatUpdateBytes(25.4 * 1024 * 1024)).toBe("25.4 MB");
expect(formatUpdateTransferSummary(null)).toBe("");
expect(
formatUpdateTransferSummary({
transferred: 12 * 1024 * 1024,
total: 0,
bytesPerSecond: 0,
}),
).toBe("12.0 MB indirildi");
expect(
formatUpdateTransferSummary({
currentVersion: "1.0.10",
latestVersion: "1.0.11",
updateAvailable: true,
downloaded: false,
checkedAt: "2026-01-01T00:00:00.000Z",
status: "downloading",
progressPercent: 45,
transferred: 45 * 1024 * 1024,
total: 100 * 1024 * 1024,
bytesPerSecond: 5.2 * 1024 * 1024,
}),
).toBe("45.0 MB / 100.0 MB • 5.2 MB/sn");
});
it("keeps desktop update safeguard and auth sync IPC channels in parity", () => {
const repoRoot = path.resolve(__dirname, "../..");
const mainSource = fs.readFileSync(path.join(repoRoot, "apps/desktop/main.cjs"), "utf8");
const preloadSource = fs.readFileSync(path.join(repoRoot, "apps/desktop/preload.cjs"), "utf8");
const pageSource = fs.readFileSync(path.join(repoRoot, "apps/web/src/app/page.tsx"), "utf8");
const requiredChannels = [
"snapcad:get-auth-state-sync",
"snapcad:get-auth-state",
"snapcad:open-update-progress",
"snapcad:set-active-work-state",
"snapcad:prepare-before-update",
"snapcad:prepare-before-update-result",
"snapcad:confirm-update-after-save",
"snapcad:cancel-pending-update-install",
];
for (const channel of requiredChannels) {
expect(mainSource, `Missing in main.cjs: ${channel}`).toContain(channel);
expect(preloadSource, `Missing in preload.cjs: ${channel}`).toContain(channel);
}
expect(pageSource).toContain(`case "file:save-and-update":`);
});
it("allows only http and https external URLs", () => {
expect(isAllowedExternalUrl("https://snap.yakhub.com.tr")).toBe(true);
expect(isAllowedExternalUrl("http://127.0.0.1:62158")).toBe(true);
@@ -191,7 +247,7 @@ describe("desktopBridge", () => {
};
const swSource = fs.readFileSync(path.join(repoRoot, "apps/web/public/sw.js"), "utf8");
expect(pkg.version).toBe("1.0.10");
expect(pkg.version).toBe("1.0.11");
expect(lock.version).toBe(pkg.version);
expect(lock.packages[""]?.version).toBe(pkg.version);
expect(SKF_CREATED_WITH_VERSION).toBe(pkg.version);
+99 -1
View File
@@ -1,4 +1,15 @@
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import {
computeUserInitials,
resolveYakNetWidgetAttributes,
sanitizeYakNetWidgetUser,
shouldSuppressUnauthenticatedSsoMessage,
YAKNET_ACCOUNT_CDN_URL,
YAKNET_AUTH_BASE,
YAKNET_SSO_IFRAME_ID,
} from "../../apps/web/src/lib/yaknetWidgetHelpers";
describe("YakNet SSO Cross-Subdomain Real-Time Session Synchronization", () => {
it("validates incoming YAKNET_SSO_STATUS message payload structure", () => {
@@ -80,10 +91,97 @@ describe("YakNet SSO Cross-Subdomain Real-Time Session Synchronization", () => {
});
it("ensures correct auth base URL for YakNet developer console SSO frame", () => {
const YAKNET_AUTH_BASE = "https://developer-console.yakhub.com.tr";
const ssoFrameUrl = `${YAKNET_AUTH_BASE}/sdk/sso-frame`;
expect(ssoFrameUrl).toBe("https://developer-console.yakhub.com.tr/sdk/sso-frame");
expect(ssoFrameUrl.startsWith("https://developer-console.yakhub.com.tr")).toBe(true);
});
it("omits authenticated attribute until session resolves to prevent login-button flash", () => {
const unresolvedAttrs = resolveYakNetWidgetAttributes({
user: null,
sessionResolved: false,
theme: "light",
});
expect(unresolvedAttrs.authenticated).toBeNull();
expect(unresolvedAttrs["user-name"]).toBeNull();
const signedOutAttrs = resolveYakNetWidgetAttributes({
user: null,
sessionResolved: true,
});
expect(signedOutAttrs.authenticated).toBe("false");
const signedInAttrs = resolveYakNetWidgetAttributes({
user: { id: 7, name: "Yakup İpek", email: "[email protected]" },
sessionResolved: true,
});
expect(signedInAttrs.authenticated).toBe("true");
expect(signedInAttrs["user-name"]).toBe("Yakup İpek");
expect(signedInAttrs["user-email"]).toBe("[email protected]");
});
it("suppresses stale or cookie-less unauthenticated SSO frame messages safely", () => {
expect(
shouldSuppressUnauthenticatedSsoMessage({
isDesktop: true,
sessionResolved: true,
hasAuthenticatedUser: true,
ssoFrameHadAuthenticated: false,
}),
).toBe(true);
expect(
shouldSuppressUnauthenticatedSsoMessage({
isDesktop: false,
sessionResolved: false,
hasAuthenticatedUser: false,
ssoFrameHadAuthenticated: false,
}),
).toBe(true);
expect(
shouldSuppressUnauthenticatedSsoMessage({
isDesktop: false,
sessionResolved: true,
hasAuthenticatedUser: true,
ssoFrameHadAuthenticated: false,
}),
).toBe(true);
expect(
shouldSuppressUnauthenticatedSsoMessage({
isDesktop: false,
sessionResolved: true,
hasAuthenticatedUser: true,
ssoFrameHadAuthenticated: true,
}),
).toBe(false);
});
it("sanitizes YakNet widget users and computes avatar initials", () => {
expect(sanitizeYakNetWidgetUser({ id: 0, name: "Invalid" })).toBeNull();
expect(sanitizeYakNetWidgetUser({ id: 12, name: " Yakup İpek ", email: " [email protected] " })).toEqual({
id: 12,
name: "Yakup İpek",
email: "[email protected]",
avatar: null,
auth_source: undefined,
});
expect(computeUserInitials("Yakup İpek")).toBe("Yİ");
expect(computeUserInitials("Tekisim")).toBe("T");
expect(computeUserInitials("")).toBe("YN");
});
it("keeps yaknet-account widget dynamically loaded from CDN without vendoring", () => {
const repoRoot = path.resolve(__dirname, "../..");
const layoutSource = fs.readFileSync(path.join(repoRoot, "apps/web/src/app/layout.tsx"), "utf8");
const cloudBarSource = fs.readFileSync(path.join(repoRoot, "apps/web/src/components/snapcad/YakNetCloudBar.tsx"), "utf8");
expect(YAKNET_ACCOUNT_CDN_URL).toBe("https://cdnjs.yakhub.com.tr/ajax/libs/yaknet-account/latest/yaknet-account.js");
expect(layoutSource).toContain("YAKNET_ACCOUNT_CDN_URL");
expect(cloudBarSource).toContain("YAKNET_SSO_IFRAME_ID");
expect(YAKNET_SSO_IFRAME_ID).toBe("yaknet-sso-iframe-instance");
expect(fs.existsSync(path.join(repoRoot, "apps/web/public/yaknet-account.js"))).toBe(false);
});
});