Files
Web_FreeCAD_Bitbybit/scripts/check-freecad-property-linksublistglobal-roundtrip.mjs
wangdequan 54649da16c
Some checks are pending
real-verification / chrome (push) Waiting to run
real-verification / freecad-oracle (push) Waiting to run
real-verification / wasm (push) Waiting to run
feat: close link sub property codecs
2026-08-17 21:37:33 -04:00

20 lines
3.2 KiB
JavaScript

import { isDeepStrictEqual } from 'node:util'
import { readFile } from 'node:fs/promises'
import { resolve } from 'node:path'
const root = resolve(new URL('..', import.meta.url).pathname)
const report = JSON.parse(await readFile(resolve(root, 'config/freecad-property-linksublistglobal-roundtrip.json'), 'utf8'))
const fail = (message) => { throw new Error(`FreeCAD PropertyLinkSubListGlobal roundtrip check failed: ${message}`) }
if (report.schemaVersion !== 1 || report.status !== 'pass' || report.baselineId !== 'freecad-1.1.1-property-linksublistglobal-roundtrip' || report.freecadVersion !== '1.1.1' || report.gitCommit !== '0108fd4b4850cc46e625b60e53cea7a7bbe69f8d') fail('baseline is invalid')
const initial = { schemaVersion: 1, entries: [{ objectId: 'SourceBox', subElement: 'Face1' }, { objectId: 'SourceBox', subElement: 'Face2' }, { objectId: 'SecondBox', subElement: 'Face1' }] }
const target = { schemaVersion: 1, entries: [{ objectId: 'SecondBox', subElement: 'Face1' }, { objectId: 'SourceBox', subElement: 'Face1' }] }
if (report.native?.inspectedType !== 'App::PropertyLinkSubListGlobal' || report.native.inspectedElement !== 'LinkSubList' || report.native.decoded !== true || !isDeepStrictEqual(report.native.decodedValue, initial)) fail('native archive did not decode the Global property')
if (report.web?.beforeDecoded !== true || report.web.afterDecoded !== true || report.web.inspectedType !== 'App::PropertyLinkSubListGlobal' || report.web.inspectedElement !== 'LinkSubList' || report.web.archiveBytes <= 0 || !isDeepStrictEqual(report.web.beforeValue, initial) || !isDeepStrictEqual(report.web.afterValue, target)) fail('Web FCStd projection or rewrite changed semantics')
const reopened = report.native.reopened
const resaved = report.native.resaved
for (const [label, snapshot, expected] of [['reopened', reopened, target], ['resaved', resaved, target]]) {
if (snapshot?.object?.typeId !== 'PartDesign::ShapeBinder' || snapshot.object.propertyTypeId !== 'App::PropertyLinkSubListGlobal' || snapshot.object.group !== '' || !isDeepStrictEqual(snapshot.object.value, expected.entries.map((entry) => ({ object: entry.objectId, subElements: entry.subElement === null ? [] : [entry.subElement] }))) || snapshot.object.statusString !== 'Valid' || !isDeepStrictEqual(snapshot.object.state, ['Up-to-date']) || !isDeepStrictEqual(snapshot.object.outList, ['SecondBox', 'SourceBox']) || snapshot.object.shape?.isNull !== false || snapshot.object.shape.solids !== 0 || snapshot.object.shape.faces !== 1 || snapshot.object.shape.edges !== 4 || snapshot.object.shape.vertices !== 4 || !isDeepStrictEqual(snapshot.targets?.SourceBox?.inList, ['ShapeBinderProbe']) || !isDeepStrictEqual(snapshot.targets?.SecondBox?.inList, ['ShapeBinderProbe'])) fail(`${label} native semantics changed`)
}
if (report.classification?.zeroUnknownDrift !== true || report.classification.globalBacklinksPreserved !== true || report.classification.nativeDependenciesNormalized !== true || !isDeepStrictEqual(report.classification.requestedValue, target)) fail('roundtrip classification is incomplete')
console.log(JSON.stringify({ status: 'freecad-property-linksublistglobal-roundtrip-pass', native: report.native, web: report.web, classification: report.classification }, null, 2))