#!/usr/bin/env node import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { audit64Satisfied } from "./audit64.mjs"; const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const docs = path.join(root, "docs"); const dir = path.join(docs, "current", "business-evidence", "desktop-test-cam-testpathtoolshapedoc-20261030"); const desktop = JSON.parse(fs.readFileSync(path.join(docs, "p6", "cam-shape-doc-chrome.json"), "utf8")); const mobile = JSON.parse(fs.readFileSync(path.join(docs, "p6", "cam-shape-doc-chrome-mobile.json"), "utf8")); const caseId = "desktop-test.Mod.CAM.CAMTests.TestPathToolBit"; const EXPECTED = 9; const contract = { schema: "freecad-web-official-case-acceptance-contract/v1", caseId, source: "freecad-source/src/Mod/CAM/CAMTests/TestPathToolBit.py", enabledOfficialMethods: EXPECTED, prerequisites: [ "absolute TestPathToolBit.py and Path/Tool/assets/__init__.py paths", "abstract Asset base and AssetUri resolve in WASM", "official TestAsset subclass overrides dependencies/from_bytes/to_bytes/get_id", "headless worker isolation with no document requirement", ], passConditions: [ "all 9 official methods pass", "testGetToolBit yields ToolBitEndmill with id 5mm_Endmill and testGetLibrary yields Default", "toolshapedocshape://bullnose loads with Diameter 5.0 mm and CornerRadius 1.5 mm", "the bullnose bit pickles and unpickles preserving type and id", "document count returns 0 to 0", "desktop and mobile have no page errors, overflow or external requests", "64-record workbench audit passes on each host", ], failureClassification: { prerequisite: "source paths or the builtin asset path probe fail before methods", product: "official tool bit, library, bullnose or pickle assertion fails", presentation: "viewport, network or console failure", audit: "workbench audit failure", }, persistence: { applicable: false, reason: "tool bits are built from builtin shape assets into an in-memory store", database: "not used; SQLite WASM/OPFS is the project persistence standard when needed", }, }; function complete(report) { const result = report.cases.centroid.state.response?.result; const pre = result?.preflight; const probe = pre?.probe; return ( report.result === "pass" && result?.schema === "freecad-web-cam/test-path-tool-shape-doc/v1" && result.tests?.length === EXPECTED && result.tests.every((t) => t.passed === true) && result.guiUp?.[0] === "bool" && result.guiUp?.[1] === false && pre?.passed === true && probe?.bodyPriority === true && probe?.partFallback === true && probe?.noneWhenEmpty === true && Array.isArray(probe?.props?.Diameter) && probe.props.Diameter.join("|") === "10 mm|App::PropertyString" && Array.isArray(probe?.props?.Length) && probe.props.Length.join("|") === "50 mm|App::PropertyString" && probe?.hasContext === true && result.documentCountBefore === 0 && result.documentCountAfter === 0 && report.cases.layout.state.crossOriginIsolated === true && report.cases.layout.state.bodyOverflow === false && report.cases.layout.state.propertiesInViewport === true && report.network.externalRequestCount === 0 && report.network.httpFailures.length === 0 && report.exceptions.length === 0 && report.audit64.status === "passed" && audit64Satisfied(report.audit64) && report.audit64.failures === 0 ); } const passed = complete(desktop) && complete(mobile); const profile = { schema: "freecad-web-official-case-profile/v1", caseId, status: passed ? "passed" : "incomplete", sourceMapped: true, implementationStatus: "native_web_owner_ready", integrationStatus: passed ? "passed" : "integration_pending", acceptancePassed: passed, preflight: desktop.cases.centroid.state.response.result.preflight, officialMethods: { expected: EXPECTED, desktop: desktop.cases.centroid.state.response.result.tests, mobile: mobile.cases.centroid.state.response.result.tests, }, viewports: { desktop: { viewport: desktop.viewport, layout: desktop.cases.layout.state, pageErrors: desktop.exceptions, overflow: desktop.cases.layout.state.bodyOverflow }, mobile: { viewport: mobile.viewport, layout: mobile.cases.layout.state, pageErrors: mobile.exceptions, overflow: mobile.cases.layout.state.bodyOverflow }, }, audit64: { desktop: desktop.audit64, mobile: mobile.audit64 }, persistence: contract.persistence, evidence: [ "acceptance-contract.json", "cam-shape-doc-native-desktop.json", "cam-shape-doc-native-mobile.json", "cam-shape-doc-browser-desktop.json", "cam-shape-doc-browser-mobile.json", "workbench-surface-audit-desktop.json", "workbench-surface-audit-mobile.json", "cam-shape-doc-desktop.png", "cam-shape-doc-mobile.png", ].map((file) => `docs/current/business-evidence/desktop-test-cam-testpathtoolshapedoc-20261030/${file}`), }; fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(path.join(dir, "acceptance-contract.json"), `${JSON.stringify(contract, null, 2)}\n`); fs.writeFileSync(path.join(dir, "desktop-test-cam-shape-doc-profile.json"), `${JSON.stringify(profile, null, 2)}\n`); console.log(JSON.stringify({ status: profile.status, methods: EXPECTED, bodyPriority: profile.preflight.probe.bodyPriority, partFallback: profile.preflight.probe.partFallback, noneWhenEmpty: profile.preflight.probe.noneWhenEmpty, failedMethods: profile.officialMethods.desktop.filter((t) => !t.passed).map((t) => t.name), audits: [profile.audit64.desktop.records, profile.audit64.mobile.records], })); process.exitCode = passed ? 0 : 1;