17 lines
2.3 KiB
JavaScript
17 lines
2.3 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-font-mutation.json'), 'utf8'))
|
|
const fail = (message) => { throw new Error(`FreeCAD PropertyFont mutation check failed: ${message}`) }
|
|
if (report.schemaVersion !== 1 || report.status !== 'pass' || report.baselineId !== 'freecad-1.1.1-property-font-mutation' || report.freecadVersion !== '1.1.1' || report.gitCommit !== '0108fd4b4850cc46e625b60e53cea7a7bbe69f8d' || report.propertyType !== 'App::PropertyFont' || report.object?.name !== 'FontProbe' || report.object.typeId !== 'TechDraw::DrawViewAnnotation' || report.property?.name !== 'Font' || report.property.typeId !== 'App::PropertyFont') fail('baseline or identity is invalid')
|
|
const expected = { before: 'osifont', edited: 'Liberation Sans', restored: 'osifont' }
|
|
if (!isDeepStrictEqual(report.requested, expected) || !report.phases?.before || !report.phases.edited || !report.phases.restored) fail('mutation phases are incomplete')
|
|
for (const [id, value] of Object.entries(expected)) {
|
|
const phase = report.phases[id]
|
|
if (phase.value !== value || phase.propertyTypeId !== 'App::PropertyFont' || !isDeepStrictEqual(phase.propertyStatus, []) || !isDeepStrictEqual(phase.editorMode, []) || !Array.isArray(phase.objectState) || typeof phase.statusString !== 'string' || typeof phase.recomputeResult !== 'boolean' || phase.hasShapeProperty !== false || !Array.isArray(phase.objectSet)) fail(`${id} phase metadata is invalid`)
|
|
}
|
|
if (report.classification?.valueChanged !== true || report.classification.restoreExact !== true || report.classification.objectSetStable !== true || report.classification.geometryApplicability !== 'not-applicable-no-shape-property' || report.classification.unknownSemanticDrift !== false) fail('mutation classification is not exact')
|
|
console.log(JSON.stringify({ status: 'freecad-property-font-mutation-pass', before: report.phases.before.value, edited: report.phases.edited.value, restored: report.phases.restored.value, restoreExact: report.classification.restoreExact, unknownSemanticDrift: report.classification.unknownSemanticDrift }, null, 2))
|