2026-07-11 20:34:13 +03:00
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
import {
|
2026-07-14 09:43:37 +03:00
|
|
|
CAD_MODIFIER_MAX_SHARP_ANGLE,
|
2026-07-11 20:34:13 +03:00
|
|
|
CAD_MODIFIER_REQUEST_TIMEOUT_MS,
|
|
|
|
|
CAD_MODIFIER_RUNTIME_BASE,
|
|
|
|
|
cadModifierTimeoutMessage,
|
|
|
|
|
edgeModifierSelectionStatus,
|
2026-07-19 15:58:52 +03:00
|
|
|
isCadModifierWasmMemoryFault,
|
2026-07-11 20:34:13 +03:00
|
|
|
} from "@/lib/cadModifierRuntime";
|
|
|
|
|
|
|
|
|
|
describe("CAD modifier runtime state", () => {
|
|
|
|
|
it("uses the build-managed OCCT runtime", () => {
|
|
|
|
|
expect(CAD_MODIFIER_RUNTIME_BASE).toBe("/occt");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("does not report zero edges before preparation finishes", () => {
|
|
|
|
|
expect(edgeModifierSelectionStatus(false, 0, 0)).toBe("Preparing edges\u2026");
|
|
|
|
|
expect(edgeModifierSelectionStatus(true, 0, 0)).toBe("0 of 0 sharp edges selected");
|
|
|
|
|
expect(edgeModifierSelectionStatus(true, 2, 12)).toBe("2 of 12 sharp edges selected");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("sets a bounded preparation wait and an actionable compatibility error", () => {
|
|
|
|
|
expect(CAD_MODIFIER_REQUEST_TIMEOUT_MS).toBeGreaterThanOrEqual(20_000);
|
|
|
|
|
expect(CAD_MODIFIER_REQUEST_TIMEOUT_MS).toBeLessThanOrEqual(60_000);
|
|
|
|
|
expect(cadModifierTimeoutMessage("prepare")).toContain("Firefox 121+");
|
|
|
|
|
});
|
2026-07-14 09:43:37 +03:00
|
|
|
|
|
|
|
|
it("does not expose thresholds above the worker's folded edge-angle range", () => {
|
|
|
|
|
expect(CAD_MODIFIER_MAX_SHARP_ANGLE).toBe(90);
|
|
|
|
|
});
|
2026-07-19 15:58:52 +03:00
|
|
|
|
|
|
|
|
it("recognizes browser-specific WebAssembly memory fault messages", () => {
|
|
|
|
|
expect(isCadModifierWasmMemoryFault("toBREP: memory access out of bounds")).toBe(true);
|
|
|
|
|
expect(isCadModifierWasmMemoryFault("toBREP: Out of bounds memory access (evaluating 'func(...args)')")).toBe(true);
|
|
|
|
|
expect(isCadModifierWasmMemoryFault("Unreachable code reached", "RuntimeError")).toBe(true);
|
|
|
|
|
expect(isCadModifierWasmMemoryFault("The selected edges cannot be filleted together", "Error")).toBe(false);
|
|
|
|
|
});
|
2026-07-11 20:34:13 +03:00
|
|
|
});
|