Add reusable system preset library

This commit is contained in:
2026-11-05 22:16:27 +00:00
parent a28cb2e7b9
commit a734a0282f
5 changed files with 71 additions and 17 deletions
+9 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { demoLandscape, validateLandscape } from './model'
import { demoLandscape, getPreset, systemFromPreset, validateLandscape } from './model'
describe('landscape model', () => {
it('provides the editable demo landscape', () => {
@@ -15,4 +15,12 @@ describe('landscape model', () => {
it('rejects connections that reference deleted systems', () => { const source = demoLandscape(); source.connections[0].targetId = 'deleted-system'; expect(() => validateLandscape(source)).toThrow(/missing system/) })
it('rejects scenario steps that reference deleted connections', () => { const source = demoLandscape(); source.scenarios[0].steps[0].connectionIds = ['deleted-connection']; expect(() => validateLandscape(source)).toThrow(/deleted connection/) })
it('rejects unsupported or malformed imports', () => { expect(() => validateLandscape(null)).toThrow(/JSON object/); expect(() => validateLandscape({ version: 2 })).toThrow(/Unsupported landscape format/) })
it('creates an isolated preset instance with selected capabilities', () => {
const preset = getPreset('website')!
const instance = systemFromPreset(preset, ['analytics'], [200, 300])
expect(instance.presetId).toBe('website')
expect(instance.capabilities.map((capability) => capability.id)).toEqual(['analytics'])
instance.capabilities[0].actions[0].payload = '{"changed":true}'
expect(preset.capabilities.find((capability) => capability.id === 'analytics')?.actions[0].payload).not.toBe('{"changed":true}')
})
})