|
| 1 | +/** |
| 2 | + * @vitest-environment node |
| 3 | + */ |
| 4 | +import { describe, expect, it } from 'vitest' |
| 5 | +import { |
| 6 | + OracleFusionRiskManagementBlock, |
| 7 | + OracleFusionRiskManagementBlockMeta, |
| 8 | +} from '@/blocks/blocks/oracle_fusion_risk_management' |
| 9 | +import { selectorManifest } from '@/lib/selectors/manifest' |
| 10 | +import { evaluateSubBlockCondition } from '@/lib/workflows/subblocks/visibility' |
| 11 | +import * as riskTools from '@/tools/oracle_fusion_risk_management' |
| 12 | + |
| 13 | +const block = OracleFusionRiskManagementBlock |
| 14 | + |
| 15 | +describe('Risk Management block contracts', () => { |
| 16 | + it('exposes every action and required input in both input modes', () => { |
| 17 | + const tools = Object.values(riskTools) |
| 18 | + expect([...block.tools.access].sort()).toEqual(tools.map((tool) => tool.id).sort()) |
| 19 | + expect(new Set(block.subBlocks.map((field) => field.id)).size).toBe(block.subBlocks.length) |
| 20 | + for (const tool of tools) { |
| 21 | + const values = { operation: tool.id } |
| 22 | + expect(block.tools.config.tool(values)).toBe(tool.id) |
| 23 | + for (const [param, config] of Object.entries(tool.params)) { |
| 24 | + if (!config.required || config.visibility === 'hidden') continue |
| 25 | + for (const mode of ['basic', 'advanced']) { |
| 26 | + const fields = block.subBlocks.filter((field) => |
| 27 | + (field.canonicalParamId ?? field.id) === param && |
| 28 | + (!field.mode || field.mode === mode) && |
| 29 | + evaluateSubBlockCondition(field.condition, values) |
| 30 | + ) |
| 31 | + expect(fields.length, `${tool.id}: ${param} in ${mode}`).toBeGreaterThan(0) |
| 32 | + expect(fields.every((field) => field.required === true)).toBe(true) |
| 33 | + } |
| 34 | + } |
| 35 | + for (const output of Object.keys(tool.outputs ?? {})) expect(block.outputs).toHaveProperty(output) |
| 36 | + } |
| 37 | + expect(OracleFusionRiskManagementBlockMeta.templates.length).toBeGreaterThanOrEqual(7) |
| 38 | + }) |
| 39 | + |
| 40 | + it('preserves dynamic references during tool selection and exact IDs during mapping', () => { |
| 41 | + const params = { |
| 42 | + operation: 'oracle_fusion_risk_management_get_process', |
| 43 | + processId: '<previous.record.ProcessId>', |
| 44 | + limit: '<previous.limit>', |
| 45 | + } |
| 46 | + expect(block.tools.config.tool(params)).toBe(params.operation) |
| 47 | + expect(params.processId).toBe('<previous.record.ProcessId>') |
| 48 | + const mapped = block.tools.config.params!({ ...params, processId: '9007199254740993' }) |
| 49 | + expect(mapped).toEqual({ processId: '9007199254740993' }) |
| 50 | + expect(block.tools.config.params!({ operation: 'oracle_fusion_risk_management_list_processes', limit: '25', offset: '0', totalResults: 'false' })).toEqual({ limit: 25, offset: 0, totalResults: false }) |
| 51 | + }) |
| 52 | + |
| 53 | + it('binds selectors to the shared service and credential context', () => { |
| 54 | + for (const field of block.subBlocks) { |
| 55 | + if (!field.selectorKey) continue |
| 56 | + const manifest = selectorManifest[field.selectorKey] |
| 57 | + expect(manifest.classification).toBe('provider-server') |
| 58 | + expect(manifest.listMode).toBe('paginated') |
| 59 | + expect(manifest.context.allowed).toEqual(['oauthCredential']) |
| 60 | + expect(field.dependsOn).toEqual(['oauthCredential']) |
| 61 | + expect(field.serviceId).toBe('oracle_fusion_risk_management') |
| 62 | + } |
| 63 | + }) |
| 64 | +}) |
0 commit comments