import { test } from 'node:test'
import assert from 'node:assert/strict'
import { createEngineeringProject } from '../src/facade/engineeringProject'

test('engineering project closes mixed Assembly BIM Mesh Surface artifacts', () => { const project = createEngineeringProject(); project.add({ id: 'assembly', kind: 'Assembly', sourceRefs: [], payload: { components: 2 } }); project.add({ id: 'bim', kind: 'BIM', sourceRefs: ['assembly'], payload: { elements: 1 } }); project.add({ id: 'mesh', kind: 'Mesh', sourceRefs: ['bim'], payload: { triangles: 12 } }); project.add({ id: 'surface', kind: 'Surface', sourceRefs: ['mesh'], payload: { patches: 2 } }); project.update('mesh', { payload: { triangles: 24 } }); assert.equal(project.snapshot().artifacts.find((artifact) => artifact.id === 'mesh')?.version, 2); assert.deepEqual(project.integrity(), { complete: true, kinds: ['Assembly', 'BIM', 'Mesh', 'Surface'], missingKinds: [], missingRefs: [], artifacts: 4 }); const reopened = createEngineeringProject(); assert.equal(reopened.load(project.save()).artifacts.length, 4) })
test('engineering project reports missing source references', () => { const project = createEngineeringProject(); project.add({ id: 'mesh', kind: 'Mesh', sourceRefs: ['missing'], payload: {} }); assert.equal(project.integrity().complete, false); assert.deepEqual(project.integrity().missingKinds, ['Assembly', 'BIM', 'Surface']); assert.deepEqual(project.integrity().missingRefs, ['mesh->missing']) })
