import { test } from 'node:test'
import assert from 'node:assert/strict'
import { createProductionDocument } from '../src/facade/productionDocument'

test('production document closes the four document workbench dependency graph', () => { const document = createProductionDocument(); document.add({ id: 'sheet', kind: 'Spreadsheet', dependencies: [], payload: { cells: 4 } }); document.add({ id: 'draft', kind: 'Draft', dependencies: [], payload: { objects: 2 } }); document.add({ id: 'page', kind: 'TechDraw', dependencies: ['draft'], payload: { views: 1 } }); document.add({ id: 'plot', kind: 'Plot', dependencies: ['sheet'], payload: { series: 1 } }); assert.equal(document.closure().complete, true); const saved = document.save(); const reopened = createProductionDocument(); assert.equal(reopened.load(saved).artifacts.length, 4); assert.equal(reopened.closure().complete, true) })
test('production document reports missing dependencies and cycles', () => { const document = createProductionDocument(); document.add({ id: 'sheet', kind: 'Spreadsheet', dependencies: ['missing'], payload: {} }); document.add({ id: 'plot', kind: 'Plot', dependencies: ['sheet'], payload: {} }); assert.equal(document.closure().complete, false); assert.deepEqual(document.closure().missingKinds, ['TechDraw', 'Draft']); assert.deepEqual(document.closure().missingDependencies, ['sheet->missing']) })
