Add restricted middleware transformation pipelines

This commit is contained in:
2026-11-05 23:07:36 +00:00
parent 163f99be54
commit f7a06f487c
5 changed files with 88 additions and 11 deletions
+13 -3
View File
@@ -1,11 +1,11 @@
import { describe, expect, it } from 'vitest'
import { definitionFromCapabilities, demoLandscape, getPreset, systemFromPreset, validateLandscape } from './model'
import { definitionFromCapabilities, demoLandscape, executePipeline, getPreset, systemFromPreset, validateLandscape } from './model'
describe('landscape model', () => {
it('provides the editable demo landscape', () => {
const landscape = demoLandscape()
expect(landscape.systems).toHaveLength(9)
expect(landscape.scenarios.map((scenario) => scenario.name)).toEqual(expect.arrayContaining(['Place order', 'Register customer', 'Contact enquiry', 'Sample request', 'Commercial order', 'Order retry and recovery', 'Commit, build and deploy']))
expect(landscape.systems).toHaveLength(10)
expect(landscape.scenarios.map((scenario) => scenario.name)).toEqual(expect.arrayContaining(['Place order', 'Register customer', 'Contact enquiry', 'Sample request', 'Commercial order', 'Order retry and recovery', 'Commit, build and deploy', 'Website → Middleware → ERP order']))
expect(landscape.scenarios[0].steps[2].connectionIds).toHaveLength(2)
expect(getPreset('bitbucket')?.category).toBe('development-tool')
expect(landscape.connections.find((connection) => connection.id === 'azure-devops-website')?.connectionType).toBe('deployment')
@@ -51,4 +51,14 @@ describe('landscape model', () => {
const imported = validateLandscape(JSON.parse(JSON.stringify(landscape)))
expect(imported.containers).toEqual(landscape.containers)
})
it('executes restricted middleware mappings and reports validation failures', () => {
const action = getPreset('middleware')!.definition!.actions[0]
const result = executePipeline('{"customerId":"cus_89","sku":"sample-blue"}', action.pipeline!)
expect(result.ok).toBe(true)
expect(JSON.parse(result.payload)).toMatchObject({ accountCode: 'ERP-0042', channel: 'website' })
expect(result.trace.map((item) => item.type)).toEqual(['receive', 'validate', 'transform', 'route', 'send'])
const failed = executePipeline('{"sku":"sample-blue"}', action.pipeline!)
expect(failed.ok).toBe(false)
expect(failed.failureStepId).toBe('validation-failure')
})
})