Files
Web_FreeCAD_Bitbybit/scripts/check-freecad-property-linksubhidden-success.mjs
wangdequan 7bd7ff5055
Some checks failed
real-verification / chrome (push) Has been cancelled
real-verification / freecad-oracle (push) Has been cancelled
real-verification / wasm (push) Has been cancelled
feat: close hidden link property evidence
2026-08-17 17:31:34 -04:00

30 lines
4.7 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-linksubhidden-success.json'), 'utf8'))
const fail = (message) => { throw new Error(`FreeCAD PropertyLinkSubHidden success check failed: ${message}`) }
if (report.schemaVersion !== 1 || report.status !== 'pass' || report.baselineId !== 'freecad-1.1.1-property-linksubhidden-success' || report.freecadVersion !== '1.1.1' || report.gitCommit !== '0108fd4b4850cc46e625b60e53cea7a7bbe69f8d' || report.propertyType !== 'App::PropertyLinkSubHidden') fail('baseline is invalid')
if (report.caseCount !== 4 || report.cases?.length !== 4 || report.bindingBoundary?.oracleDefault !== null || report.bindingBoundary.safeFirstRead !== 'assign-null-object-before-read' || report.bindingBoundary.emptySubListMeans !== 'whole-object-reference') fail('case inventory or first-read boundary changed')
const expectedHosts = new Map([['App::Link', { name: 'LinkProbe', ordinaryOutList: ['ColorSourceA'], targetInLists: { ColorSourceA: ['LinkProbe'], ColorSourceB: [] } }], ['App::LinkGroup', { name: 'LinkGroupProbe', ordinaryOutList: [], targetInLists: { ColorSourceA: [], ColorSourceB: [] } }], ['App::LinkGroupPython', { name: 'LinkGroupPythonProbe', ordinaryOutList: [], targetInLists: { ColorSourceA: [], ColorSourceB: [] } }], ['App::LinkPython', { name: 'LinkPythonProbe', ordinaryOutList: ['ColorSourceA'], targetInLists: { ColorSourceA: ['LinkPythonProbe'], ColorSourceB: [] } }]])
const expectedValues = { ordered: { object: 'ColorSourceA', subElements: ['Face1', 'Face3'] }, duplicates: { object: 'ColorSourceA', subElements: ['Face6', 'Face1', 'Face6'] }, wholeObject: { object: 'ColorSourceA', subElements: [] }, explicitNull: null }
const expectedObjects = (ownerName, ownerTypeId) => [{ name: ownerName, typeId: ownerTypeId }, { name: 'ColorSourceA', typeId: 'Part::Feature' }, { name: 'ColorSourceB', typeId: 'Part::Feature' }]
for (const entry of report.cases) {
const host = expectedHosts.get(entry.objectTypeId)
const objectName = host?.name
if (!objectName || entry.objectName !== objectName || entry.propertyName !== 'ColoredElements' || entry.group !== ' Link' || entry.mode !== 'direct-native-property-setter') fail(`${entry.objectTypeId} identity changed`)
const baselineTargets = entry.phases?.ordered?.targetShapes
if (baselineTargets?.ColorSourceA?.isNull !== false || baselineTargets.ColorSourceA.solids !== 1 || baselineTargets.ColorSourceA.faces !== 6 || baselineTargets.ColorSourceA.edges !== 12 || baselineTargets.ColorSourceA.vertices !== 8 || typeof baselineTargets.ColorSourceA.brepSha256 !== 'string') fail(`${entry.objectTypeId} box target is invalid`)
if (baselineTargets?.ColorSourceB?.isNull !== false || baselineTargets.ColorSourceB.solids !== 1 || baselineTargets.ColorSourceB.faces !== 3 || baselineTargets.ColorSourceB.edges !== 3 || baselineTargets.ColorSourceB.vertices !== 2 || typeof baselineTargets.ColorSourceB.brepSha256 !== 'string') fail(`${entry.objectTypeId} cylinder target is invalid`)
for (const [phase, expectedValue] of Object.entries(expectedValues)) {
const snapshot = entry.phases?.[phase]
if (!isDeepStrictEqual(snapshot?.value, expectedValue) || snapshot.propertyTypeId !== 'App::PropertyLinkSubHidden' || snapshot.group !== ' Link' || !isDeepStrictEqual(snapshot.propertyStatus, ['LockDynamic', '26']) || !isDeepStrictEqual(snapshot.editorMode, ['Hidden'])) fail(`${entry.objectTypeId} ${phase} property semantics changed`)
if (!isDeepStrictEqual(snapshot.ownerState, ['Up-to-date']) || snapshot.statusString !== 'Valid' || snapshot.recomputeResult !== true || snapshot.shape?.applicable !== false) fail(`${entry.objectTypeId} ${phase} host state changed`)
if (!isDeepStrictEqual(snapshot.ownerOutList, host.ordinaryOutList) || !isDeepStrictEqual(snapshot.targetInLists, host.targetInLists)) fail(`${entry.objectTypeId} ${phase} leaked a hidden dependency or backlink`)
if (!isDeepStrictEqual(snapshot.targetShapes, baselineTargets)) fail(`${entry.objectTypeId} ${phase} changed a target Shape`)
if (!isDeepStrictEqual(snapshot.objectSet, expectedObjects(objectName, entry.objectTypeId))) fail(`${entry.objectTypeId} ${phase} changed the document object set`)
}
}
console.log(JSON.stringify({ status: 'freecad-property-linksubhidden-success-pass', cases: report.caseCount, phases: Object.keys(expectedValues), orderedValue: expectedValues.ordered, duplicateValue: expectedValues.duplicates, wholeObjectValue: expectedValues.wholeObject, hiddenDependency: { ownerOutList: [], targetInLists: { ColorSourceA: [], ColorSourceB: [] } } }, null, 2))