18 lines
2.2 KiB
JavaScript
18 lines
2.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-font-success.json'), 'utf8'))
|
|
const fail = (message) => { throw new Error(`FreeCAD PropertyFont success check failed: ${message}`) }
|
|
if (report.schemaVersion !== 1 || report.status !== 'pass' || report.baselineId !== 'freecad-1.1.1-property-font-success' || report.freecadVersion !== '1.1.1' || report.gitCommit !== '0108fd4b4850cc46e625b60e53cea7a7bbe69f8d' || report.propertyType !== 'App::PropertyFont') fail('baseline is invalid')
|
|
if (report.object?.name !== 'FontProbe' || report.object.typeId !== 'TechDraw::DrawViewAnnotation' || report.property?.name !== 'Font' || report.property.typeId !== 'App::PropertyFont' || report.property.group !== 'Annotation') fail('native object/property identity changed')
|
|
const expected = { default: 'osifont', 'named-family': 'DejaVu Sans', 'unicode-family': 'Noto Sans CJK SC', 'empty-family': '', restored: 'osifont' }
|
|
if (report.diagnostics?.exception !== null || report.diagnostics.documentObjectCount !== 1 || !isDeepStrictEqual(Object.keys(report.phases ?? {}).sort(), Object.keys(expected).sort())) fail('native success phases are incomplete')
|
|
const objectSet = [{ name: 'FontProbe', typeId: 'TechDraw::DrawViewAnnotation' }]
|
|
for (const [id, value] of Object.entries(expected)) {
|
|
const phase = report.phases[id]
|
|
if (phase?.requested !== value || phase.value !== value || phase.propertyTypeId !== 'App::PropertyFont' || !isDeepStrictEqual(phase.propertyStatus, []) || !isDeepStrictEqual(phase.editorMode, []) || !isDeepStrictEqual(phase.objectSet, objectSet) || typeof phase.recomputeResult !== 'boolean' || phase.hasShapeProperty !== false || !Array.isArray(phase.objectState) || typeof phase.statusString !== 'string') fail(`${id} native success semantics changed`)
|
|
}
|
|
console.log(JSON.stringify({ status: 'freecad-property-font-success-pass', propertyType: report.propertyType, phases: Object.keys(report.phases), values: Object.fromEntries(Object.entries(report.phases).map(([id, phase]) => [id, phase.value])), objectSet }, null, 2))
|