Add restricted middleware transformation pipelines
This commit is contained in:
+13
-3
@@ -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')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user