mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
fix(Execute Workflow Node): Pass binary data to sub-workflow (#12635)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
parent
35cb10c5e7
commit
e9c152e369
|
@ -97,7 +97,7 @@ export function getFieldEntries(context: IWorkflowNodeContext): FieldValueOption
|
|||
export function getWorkflowInputValues(this: ISupplyDataFunctions): INodeExecutionData[] {
|
||||
const inputData = this.getInputData();
|
||||
|
||||
return inputData.map((item, itemIndex) => {
|
||||
return inputData.map(({ json, binary }, itemIndex) => {
|
||||
const itemFieldValues = this.getNodeParameter(
|
||||
'workflowInputs.value',
|
||||
itemIndex,
|
||||
|
@ -106,13 +106,14 @@ export function getWorkflowInputValues(this: ISupplyDataFunctions): INodeExecuti
|
|||
|
||||
return {
|
||||
json: {
|
||||
...item.json,
|
||||
...json,
|
||||
...itemFieldValues,
|
||||
},
|
||||
index: itemIndex,
|
||||
pairedItem: {
|
||||
item: itemIndex,
|
||||
},
|
||||
binary,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
import { mock } from 'jest-mock-extended';
|
||||
import type { ISupplyDataFunctions } from 'n8n-workflow';
|
||||
|
||||
import { getWorkflowInputValues } from '../GenericFunctions';
|
||||
|
||||
describe('getWorkflowInputValues', () => {
|
||||
const supplyDataFunctions = mock<ISupplyDataFunctions>();
|
||||
|
||||
it('should correctly map the binary property', () => {
|
||||
supplyDataFunctions.getInputData.mockReturnValue([
|
||||
{
|
||||
json: { key1: 'value1' },
|
||||
binary: { file1: { data: 'binaryData1', mimeType: 'image/png' } },
|
||||
},
|
||||
{
|
||||
json: { key2: 'value2' },
|
||||
binary: { file2: { data: 'binaryData2', mimeType: 'image/jpeg' } },
|
||||
},
|
||||
]);
|
||||
|
||||
supplyDataFunctions.getNodeParameter
|
||||
.calledWith('workflowInputs.value', 0)
|
||||
.mockReturnValueOnce({ additionalKey1: 'additionalValue1' });
|
||||
supplyDataFunctions.getNodeParameter
|
||||
.calledWith('workflowInputs.value', 1)
|
||||
.mockReturnValueOnce({ additionalKey2: 'additionalValue2' });
|
||||
|
||||
const result = getWorkflowInputValues.call(supplyDataFunctions);
|
||||
|
||||
expect(result).toEqual([
|
||||
{
|
||||
json: {
|
||||
key1: 'value1',
|
||||
additionalKey1: 'additionalValue1',
|
||||
},
|
||||
binary: { file1: { data: 'binaryData1', mimeType: 'image/png' } },
|
||||
index: 0,
|
||||
pairedItem: { item: 0 },
|
||||
},
|
||||
{
|
||||
json: {
|
||||
key2: 'value2',
|
||||
additionalKey2: 'additionalValue2',
|
||||
},
|
||||
binary: { file2: { data: 'binaryData2', mimeType: 'image/jpeg' } },
|
||||
index: 1,
|
||||
pairedItem: { item: 1 },
|
||||
},
|
||||
]);
|
||||
|
||||
expect(supplyDataFunctions.getInputData).toHaveBeenCalled();
|
||||
expect(supplyDataFunctions.getNodeParameter).toHaveBeenCalledWith(
|
||||
'workflowInputs.value',
|
||||
0,
|
||||
{},
|
||||
);
|
||||
expect(supplyDataFunctions.getNodeParameter).toHaveBeenCalledWith(
|
||||
'workflowInputs.value',
|
||||
1,
|
||||
{},
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue