#!/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-testlinuxcncpost-20261029"); const desktop = JSON.parse(fs.readFileSync(path.join(docs, "p6", "cam-linux-post-chrome.json"), "utf8")); const mobile = JSON.parse(fs.readFileSync(path.join(docs, "p6", "cam-linux-post-chrome-mobile.json"), "utf8")); const caseId = "desktop-test.Mod.CAM.CAMTests.TestLinuxCNCPost"; const contract = { schema: "freecad-web-official-case-acceptance-contract/v1", caseId, source: "freecad-source/src/Mod/CAM/CAMTests/TestLinuxCNCPost.py", enabledOfficialMethods: 23, prerequisites: [ "absolute LinuxCNC source, mock, processor and post script paths", "temporary in-memory MockJob, MockOperation and Linuxcnc postprocessor", "Machine with one rotary Toolhead and shared Units.Velocity", "CAM Worker ready with headless FreeCAD.GuiUp boolean", "desktop 1440x900 and mobile 390x844 host/server with crossOriginIsolated" ], passConditions: [ "all 23 official unittest methods pass in the WASM Python runtime", "preflight MockJob/MockOperation/Linuxcnc/Machine types are recorded and document resources close 0→0", "desktop/mobile owner has no page errors, overflow, failed HTTP requests or external requests", "same-host workbench surface audit has 64 records and zero failures" ], failureClassification: { prerequisite: "source paths, mock fixture, postprocessor, machine, units or worker setup fails before tests", product: "official LinuxCNC blend/tapping/schema assertion fails after prerequisites pass", presentation: "viewport, overflow, console, page or HTTP failure", audit: "64-record workbench surface audit failure" }, persistence: { applicable: false, reason: "official LinuxCNC tests use in-memory mock job/operation data and close without saving", database: "not used; SQLite WASM with OPFS is the project standard when persistence is applicable" } }; function complete(report) { const state = report.cases.centroid.state; const response = state.response; const result = response?.result; const preflight = result?.preflight; return report.result === "pass" && response?.kind === "result" && result?.schema === "freecad-web-cam/test-linuxcnc-post/v1" && result?.module === "CAM" && result?.source === "freecad-source" && result?.guiSkipped === true && result?.webOwner === true && result?.resourcesReleased === true && Array.isArray(result?.guiUp) && result.guiUp[0] === "bool" && result.guiUp[1] === false && Array.isArray(result?.tests) && result.tests.length === 23 && result.tests.every((test) => test?.passed === true) && preflight?.passed === true && preflight.job?.type === "MockJob" && preflight.operation?.type === "MockOperation" && preflight.postProcessor?.className === "Linuxcnc" && preflight.machine?.toolheads === 1 && preflight.units?.velocityPresent === true && preflight.documentCountBefore === 0 && preflight.documentCountAfter === 0 && preflight.resourcesReleased === true && 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: 23, 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-linux-post-native-desktop.json", "cam-linux-post-native-mobile.json", "cam-linux-post-browser-desktop.json", "cam-linux-post-browser-mobile.json", "workbench-surface-audit-desktop.json", "workbench-surface-audit-mobile.json", "cam-linux-post-desktop.png", "cam-linux-post-mobile.png" ].map((file) => `docs/current/business-evidence/desktop-test-cam-testlinuxcncpost-20261029/${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-linux-post-profile.json"), `${JSON.stringify(profile, null, 2)}\n`); console.log(JSON.stringify({ status: profile.status, methods: profile.officialMethods.expected, audits: [profile.audit64.desktop.records, profile.audit64.mobile.records] })); process.exitCode = passed ? 0 : 1;