Connect canonical projects to persistent workspace runtimes and canvas views

This commit is contained in:
2026-11-08 00:07:27 +08:00
parent 8a76e53a9f
commit e2987de21a
27 changed files with 970 additions and 57 deletions
+13
View File
@@ -127,3 +127,16 @@ test('recovery codec restores immutable maps and rejects broken history/dependen
assert.equal(restored.document.elements.get('a').data.title, 'encoded');
await engine.close();
});
test('a fresh canonical read replaces a clean recovered base, keeps history and refuses older versions', async () => {
const storage = storageFixture(), port = persistenceFixture(), first = await open(storage, port);
first.engine.editor.dispatch({ type: 'element.data', target, patch: { title: 'local' } }); await first.engine.settle(); await first.engine.close();
const reopened = await open(storage, port), current = reopened.engine.getSnapshot();
const remote = applyChanges(current.runtime.acknowledged, [{ kind: 'field', target, field: 'geometry', before: current.document.elements.get('a').geometry, after: { ...current.document.elements.get('a').geometry, x: 400 } }]);
assert.equal(reopened.engine.refresh(remote, new Map([['canvas', 3]])).status, 'applied');
assert.equal(reopened.engine.getSnapshot().document.elements.get('a').geometry.x, 400);
assert.equal(reopened.engine.getSnapshot().history.undo.length, 1);
assert.equal(reopened.engine.refresh(original, new Map([['canvas', 1]])).code, 'stale_canonical_version');
assert.equal(reopened.engine.getSnapshot().document.elements.get('a').geometry.x, 400);
await reopened.engine.close();
});