Add reusable system preset library
This commit is contained in:
+9
-1
@@ -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}')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user