24 lines
4.4 KiB
JavaScript
24 lines
4.4 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-mutation.json'), 'utf8'))
|
|
const fail = (message) => { throw new Error(`FreeCAD PropertyLinkSubListGlobal mutation check failed: ${message}`) }
|
|
if (report.schemaVersion !== 1 || report.status !== 'pass' || report.baselineId !== 'freecad-1.1.1-property-linksublistglobal-mutation' || report.freecadVersion !== '1.1.1' || report.gitCommit !== '0108fd4b4850cc46e625b60e53cea7a7bbe69f8d' || report.propertyType !== 'App::PropertyLinkSubListGlobal' || report.caseCount !== 1) fail('baseline is invalid')
|
|
const entry = report.case
|
|
const baselineValue = [{ object: 'SourceBox', subElements: ['Face1', 'Face2'] }, { object: 'SecondBox', subElements: ['Face1'] }]
|
|
const editedValue = [{ object: 'SecondBox', subElements: [] }]
|
|
if (entry?.objectTypeId !== 'PartDesign::ShapeBinder' || entry.objectName !== 'ShapeBinderProbe' || entry.propertyName !== 'Support' || entry.editRecomputeResult !== true || entry.restoreRecomputeResult !== true || entry.valueRestored !== true || entry.semanticStateRestored !== true) fail('mutation identity or restoration changed')
|
|
if (!isDeepStrictEqual(entry.before?.value, baselineValue) || !isDeepStrictEqual(entry.touchedAfterEdit?.value, editedValue) || !isDeepStrictEqual(entry.edited?.value, editedValue) || !isDeepStrictEqual(entry.touchedAfterRestore?.value, baselineValue) || !isDeepStrictEqual(entry.restored?.value, baselineValue)) fail('mutation values changed')
|
|
if (!isDeepStrictEqual(entry.before.ownerState, ['Up-to-date']) || entry.before.statusString !== 'Valid' || !isDeepStrictEqual(entry.touchedAfterEdit.ownerState, ['Touched']) || entry.touchedAfterEdit.statusString !== 'Touched' || !isDeepStrictEqual(entry.edited.ownerState, ['Up-to-date']) || entry.edited.statusString !== 'Valid' || !isDeepStrictEqual(entry.touchedAfterRestore.ownerState, ['Touched']) || entry.touchedAfterRestore.statusString !== 'Touched' || !isDeepStrictEqual(entry.restored.ownerState, ['Up-to-date']) || entry.restored.statusString !== 'Valid') fail('state transitions changed')
|
|
const objectSet = [{ name: 'ShapeBinderProbe', typeId: 'PartDesign::ShapeBinder' }, { name: 'SourceBox', typeId: 'Part::Feature' }, { name: 'SecondBox', typeId: 'Part::Feature' }]
|
|
for (const [phase, snapshot] of Object.entries({ before: entry.before, touchedAfterEdit: entry.touchedAfterEdit, edited: entry.edited, touchedAfterRestore: entry.touchedAfterRestore, restored: entry.restored })) {
|
|
if (snapshot.propertyTypeId !== report.propertyType || snapshot.group !== '' || !isDeepStrictEqual(snapshot.propertyStatus, []) || !isDeepStrictEqual(snapshot.editorMode, []) || !isDeepStrictEqual(snapshot.objectSet, objectSet) || !isDeepStrictEqual(snapshot.targetShapes, entry.before.targetShapes)) fail(`${phase} metadata, object set, or source Shapes changed`)
|
|
}
|
|
if (entry.before.shape?.isNull !== false || entry.before.shape.solids !== 0 || entry.before.shape.faces !== 2 || entry.before.shape.edges !== 8 || !isDeepStrictEqual(entry.before.ownerOutList, ['SourceBox', 'SourceBox', 'SecondBox']) || !isDeepStrictEqual(entry.before.targetInLists, { SourceBox: ['ShapeBinderProbe', 'ShapeBinderProbe'], SecondBox: ['ShapeBinderProbe'] })) fail('baseline Shape or backlinks changed')
|
|
if (entry.touchedAfterEdit.shape?.brepSha256 !== entry.before.shape.brepSha256 || !isDeepStrictEqual(entry.touchedAfterEdit.ownerOutList, ['SecondBox']) || !isDeepStrictEqual(entry.touchedAfterEdit.targetInLists, { SourceBox: [], SecondBox: ['ShapeBinderProbe'] })) fail('touched edit state changed')
|
|
if (entry.edited.shape?.isNull !== false || entry.edited.shape.solids !== 1 || entry.edited.shape.faces !== 6 || entry.edited.shape.edges !== 12 || entry.edited.shape.brepSha256 !== entry.before.targetShapes.SecondBox.brepSha256) fail('edited whole-object Shape changed')
|
|
if (!isDeepStrictEqual(entry.restored, entry.before)) fail('restored semantic state differs from baseline')
|
|
console.log(JSON.stringify({ status: 'freecad-property-linksublistglobal-mutation-pass', before: entry.before.value, edited: entry.edited.value, restored: entry.restored.value, baselineShape: entry.before.shape, editedShape: entry.edited.shape, semanticStateRestored: entry.semanticStateRestored }, null, 2))
|