Files
workinf_Blender_Wasm/tools/web/check-stl-web-roundtrip.mjs
mes123456 380cbed4ff
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions
Checkpoint web parity through Chromium input tasks
2026-08-19 10:39:03 -04:00

39 lines
2.2 KiB
JavaScript

import assert from "node:assert/strict";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-07F/manifest.json"), "utf8"));
const report = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-07F/web-roundtrip-report.json"), "utf8"));
const fileHash = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
assert.deepEqual(
{ schemaVersion: manifest.schemaVersion, task: manifest.task, parentTask: manifest.parentTask, nextTask: manifest.nextTask },
{ schemaVersion: 1, task: "M12-07F", parentTask: "M12-07E", nextTask: "M12-07G" },
);
assert.deepEqual(
{ schemaVersion: report.schemaVersion, task: report.task, operation: report.operation, nextTask: report.nextTask },
{ schemaVersion: 1, task: "M12-07F", operation: "WEB_STL_TO_DESKTOP_ROUNDTRIP", nextTask: "M12-07G" },
);
assert.equal(report.browser.imported.triangleCount, 2);
assert.equal(report.browser.outputBytes, 184);
assert.deepEqual(report.browser.lossReport, {
schemaVersion: 1,
operation: "STL_EXPORT_LOSS_REPORT",
canRoundTrip: true,
warningCount: 1,
warnings: [{ code: "STL_MATERIAL_UNSUPPORTED", severity: "warning", message: "STL has no material slots; 2 source material assignments are omitted" }],
});
assert.equal(report.desktop.operation, "DESKTOP_IMPORT_WEB_STL");
assert.equal(report.desktop.triangleCount, 2);
assert.equal(report.desktop.polygonCount, 2);
assert.deepEqual(report.comparison, { triangleCountExact: true, normalExact: true, materialLossExplicit: true });
for (const artifact of Object.values(manifest.artifacts)) {
const file = path.join(root, artifact.path);
assert.ok(fs.existsSync(file), `missing artifact ${artifact.path}`);
assert.equal(fileHash(file), artifact.sha256, `hash mismatch ${artifact.path}`);
}
process.stdout.write(`stl-web-roundtrip-ok triangles=${report.desktop.triangleCount} normals=exact materialLoss=${report.browser.lossReport.warningCount} desktopExact=true next=${manifest.nextTask}\n`);