(
language = 'javascript',
options: ConstructorParameters<typeof VariableResolver>[3] = {}
)
| 64 | } |
| 65 | |
| 66 | function createResolver( |
| 67 | language = 'javascript', |
| 68 | options: ConstructorParameters<typeof VariableResolver>[3] = {} |
| 69 | ) { |
| 70 | const producer = createBlock('producer', 'Producer', BlockType.API) |
| 71 | const functionBlock = createBlock('function', 'Function', BlockType.FUNCTION, { |
| 72 | language, |
| 73 | }) |
| 74 | const workflow: SerializedWorkflow = { |
| 75 | version: '1', |
| 76 | blocks: [producer, functionBlock], |
| 77 | connections: [], |
| 78 | loops: {}, |
| 79 | parallels: {}, |
| 80 | } |
| 81 | const state = new ExecutionState() |
| 82 | state.setBlockOutput('producer', { |
| 83 | result: 'hello world', |
| 84 | items: ['a', 'b'], |
| 85 | file: { |
| 86 | id: 'file-1', |
| 87 | name: 'image.png', |
| 88 | url: 'https://example.com/image.png', |
| 89 | key: 'execution/workspace-1/workflow-1/execution-1/image.png', |
| 90 | context: 'execution', |
| 91 | size: 12 * 1024 * 1024, |
| 92 | type: 'image/png', |
| 93 | base64: 'large-inline-base64', |
| 94 | }, |
| 95 | }) |
| 96 | const ctx = { |
| 97 | blockStates: state.getBlockStates(), |
| 98 | blockLogs: [], |
| 99 | environmentVariables: {}, |
| 100 | workflowVariables: {}, |
| 101 | decisions: { router: new Map(), condition: new Map() }, |
| 102 | loopExecutions: new Map(), |
| 103 | executedBlocks: new Set(), |
| 104 | activeExecutionPath: new Set(), |
| 105 | completedLoops: new Set(), |
| 106 | metadata: {}, |
| 107 | } as ExecutionContext |
| 108 | |
| 109 | return { |
| 110 | block: functionBlock, |
| 111 | ctx, |
| 112 | resolver: new VariableResolver(workflow, {}, state, options), |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | describe('VariableResolver function block inputs', () => { |
| 117 | it('returns empty inputs when params are missing', async () => { |
no test coverage detected