34 lines
4.9 KiB
JavaScript
34 lines
4.9 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-success.json'), 'utf8'))
|
|
const fail = (message) => { throw new Error(`FreeCAD PropertyLinkSubListGlobal success check failed: ${message}`) }
|
|
if (report.schemaVersion !== 1 || report.status !== 'pass' || report.baselineId !== 'freecad-1.1.1-property-linksublistglobal-success' || report.freecadVersion !== '1.1.1' || report.gitCommit !== '0108fd4b4850cc46e625b60e53cea7a7bbe69f8d' || report.propertyType !== 'App::PropertyLinkSubListGlobal' || report.caseCount !== 1 || report.bindingBoundary?.oracleDefault?.length !== 0 || report.bindingBoundary.safeFirstRead !== 'assign-empty-list-before-read' || report.bindingBoundary.emptyListMeans !== 'no-references' || report.bindingBoundary.shapeBinderUsesFirstPartFeature !== true || report.bindingBoundary.multipleObjectReferencesPreserved !== true) fail('baseline or binding boundary is invalid')
|
|
const entry = report.cases?.[0]
|
|
if (!entry || entry.objectTypeId !== 'PartDesign::ShapeBinder' || entry.objectName !== 'ShapeBinderProbe' || entry.propertyName !== 'Support' || entry.group !== '' || entry.mode !== 'direct-native-property-setter') fail('case identity changed')
|
|
const expectedValues = {
|
|
empty: [],
|
|
wholeObject: [{ object: 'SourceBox', subElements: [] }],
|
|
sameObjectSubElements: [{ object: 'SourceBox', subElements: ['Face1', 'Face2'] }],
|
|
multipleObjects: [{ object: 'SourceBox', subElements: ['Face1', 'Face2'] }, { object: 'SecondBox', subElements: ['Face1'] }],
|
|
}
|
|
const expectedObjectSet = [{ name: 'ShapeBinderProbe', typeId: 'PartDesign::ShapeBinder' }, { name: 'SourceBox', typeId: 'Part::Feature' }, { name: 'SecondBox', typeId: 'Part::Feature' }]
|
|
const targetShapes = entry.phases?.wholeObject?.targetShapes
|
|
if (targetShapes?.SourceBox?.isNull !== false || targetShapes.SourceBox.solids !== 1 || targetShapes.SourceBox.faces !== 6 || targetShapes.SourceBox.edges !== 12 || targetShapes.SourceBox.vertices !== 8 || targetShapes?.SecondBox?.isNull !== false || targetShapes.SecondBox.solids !== 1 || targetShapes.SecondBox.faces !== 6 || targetShapes.SecondBox.edges !== 12 || targetShapes.SecondBox.vertices !== 8) fail('source topology evidence is invalid')
|
|
for (const [phase, expectedValue] of Object.entries(expectedValues)) {
|
|
const snapshot = entry.phases?.[phase]
|
|
if (!snapshot || !isDeepStrictEqual(snapshot.value, expectedValue) || snapshot.propertyTypeId !== 'App::PropertyLinkSubListGlobal' || !isDeepStrictEqual(snapshot.propertyStatus, []) || !isDeepStrictEqual(snapshot.editorMode, []) || !isDeepStrictEqual(snapshot.objectSet, expectedObjectSet) || snapshot.statusString !== 'Valid' || snapshot.recomputeResult !== true) fail(`${phase} property or document semantics changed`)
|
|
if (!isDeepStrictEqual(snapshot.targetShapes, targetShapes)) fail(`${phase} changed source topology`)
|
|
}
|
|
const empty = entry.phases.empty
|
|
if (empty.shape?.isNull !== true || !isDeepStrictEqual(empty.ownerOutList, []) || !isDeepStrictEqual(empty.targetInLists, { SourceBox: [], SecondBox: [] }) || !isDeepStrictEqual(empty.ownerState, ['Up-to-date'])) fail('empty support boundary changed')
|
|
const whole = entry.phases.wholeObject
|
|
if (whole.shape?.isNull !== false || whole.shape.solids !== 1 || whole.shape.faces !== 6 || whole.shape.edges !== 12 || whole.shape.vertices !== 8 || !isDeepStrictEqual(whole.ownerOutList, ['SourceBox']) || !isDeepStrictEqual(whole.targetInLists, { SourceBox: ['ShapeBinderProbe'], SecondBox: [] })) fail('whole-object support semantics changed')
|
|
const sub = entry.phases.sameObjectSubElements
|
|
if (sub.shape?.isNull !== false || sub.shape.solids !== 0 || sub.shape.faces !== 2 || sub.shape.edges !== 8 || sub.shape.vertices !== 8 || !isDeepStrictEqual(sub.ownerOutList, ['SourceBox', 'SourceBox']) || !isDeepStrictEqual(sub.targetInLists, { SourceBox: ['ShapeBinderProbe', 'ShapeBinderProbe'], SecondBox: [] })) fail('sub-element support semantics changed')
|
|
const multiple = entry.phases.multipleObjects
|
|
if (multiple.shape?.isNull !== false || multiple.shape.solids !== 0 || multiple.shape.faces !== 2 || multiple.shape.edges !== 8 || multiple.shape.vertices !== 8 || !isDeepStrictEqual(multiple.ownerOutList, ['SourceBox', 'SourceBox', 'SecondBox']) || !isDeepStrictEqual(multiple.targetInLists, { SourceBox: ['ShapeBinderProbe', 'ShapeBinderProbe'], SecondBox: ['ShapeBinderProbe'] })) fail('multiple-object support/backlink semantics changed')
|
|
console.log(JSON.stringify({ status: 'freecad-property-linksublistglobal-success-pass', propertyType: report.propertyType, cases: report.caseCount, phases: Object.keys(expectedValues), wholeObjectShape: { solids: whole.shape.solids, faces: whole.shape.faces }, subElementShape: { solids: sub.shape.solids, faces: sub.shape.faces }, globalBacklinks: multiple.ownerOutList }, null, 2))
|