feat: establish production facade composition root

This commit is contained in:
2026-08-10 16:28:12 -04:00
parent b962a5c3b5
commit 7f10bba38f
11 changed files with 285 additions and 20 deletions

View File

@@ -2,6 +2,7 @@ import { test } from 'node:test'
import assert from 'node:assert/strict'
import { strToU8, unzipSync, zipSync } from 'fflate'
import { createMockFacade } from '../src/facade/mockFacade'
import { createProductionFacade } from '../src/facade/productionFacade'
import { PROJECT_SCHEMA_MIGRATIONS, PROJECT_SCHEMA_SQL, PROJECT_SCHEMA_VERSION, runProjectSchemaMigrations } from '../src/facade/projectSchema'
import { createSqliteProjectPersistence, PersistenceWriteQueue, ProjectAutosaveScheduler } from '../src/facade/projectStore'
import { DependencyGraph } from '../src/facade/dependencyGraph'
@@ -68,6 +69,17 @@ test('facade exposes a stable initial document projection', () => {
assert.deepEqual({ shapeCount: facade.geometry.capabilities().shapeCount, kernelReferenceCount: facade.geometry.capabilities().kernelReferenceCount, releasedShapeCount: facade.geometry.capabilities().releasedShapeCount }, { shapeCount: 0, kernelReferenceCount: 0, releasedShapeCount: 0 })
})
test('production facade starts from an empty document unless an application bootstrap is supplied', () => {
const facade = createProductionFacade()
const state = facade.getState()
assert.equal(state.document.id, 'doc-untitled')
assert.equal(state.document.label, 'Untitled document')
assert.deepEqual(state.document.tree, [])
assert.deepEqual(state.document.objects, [])
assert.deepEqual(state.selectedObjectIds, [])
facade.geometry.dispose()
})
test('geometry boundary validates dimensions before invoking OCCT', () => {
assert.throws(() => validateBoxInput({ width: 0, length: 2, height: 3, documentId: 'doc', documentVersion: 1 }), /width/)
assert.throws(() => validateBoxInput({ width: 1, length: 2, height: 3, center: [0, Number.NaN, 0], documentId: 'doc', documentVersion: 1 }), /center/)