mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(Set Node): Preserve binary data by default (#9668)
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -69,7 +69,7 @@ describe('test Set2, composeReturnItem', () => {
|
||||
include: 'none',
|
||||
};
|
||||
|
||||
const result = composeReturnItem.call(fakeExecuteFunction, 0, inputItem, newData, options);
|
||||
const result = composeReturnItem.call(fakeExecuteFunction, 0, inputItem, newData, options, 3.4);
|
||||
|
||||
expect(result).toEqual({
|
||||
json: {
|
||||
@@ -114,7 +114,7 @@ describe('test Set2, composeReturnItem', () => {
|
||||
include: 'selected',
|
||||
};
|
||||
|
||||
const result = composeReturnItem.call(fakeExecuteFunction, 0, inputItem, newData, options);
|
||||
const result = composeReturnItem.call(fakeExecuteFunction, 0, inputItem, newData, options, 3.4);
|
||||
|
||||
expect(result).toEqual({
|
||||
json: {
|
||||
@@ -132,6 +132,122 @@ describe('test Set2, composeReturnItem', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should include binary when expected in version <3.4', () => {
|
||||
const fakeExecuteFunction = createMockExecuteFunction({});
|
||||
|
||||
const inputItem = {
|
||||
json: {
|
||||
input1: 'value1',
|
||||
input2: 2,
|
||||
input3: [1, 2, 3],
|
||||
},
|
||||
pairedItem: {
|
||||
item: 0,
|
||||
input: undefined,
|
||||
},
|
||||
binary: {
|
||||
data: {
|
||||
data: 'content',
|
||||
mimeType: 'image/jpg',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const newData = {
|
||||
num1: 55,
|
||||
str1: '42',
|
||||
arr1: ['foo', 'bar'],
|
||||
obj: {
|
||||
key: 'value',
|
||||
},
|
||||
};
|
||||
|
||||
const resultWithIncludeBinary = composeReturnItem.call(
|
||||
fakeExecuteFunction,
|
||||
0,
|
||||
inputItem,
|
||||
newData,
|
||||
{
|
||||
include: 'all',
|
||||
includeBinary: true,
|
||||
},
|
||||
3.3,
|
||||
);
|
||||
|
||||
expect(resultWithIncludeBinary.binary).toEqual(inputItem.binary);
|
||||
|
||||
const resultWithoutIncludeBinary = composeReturnItem.call(
|
||||
fakeExecuteFunction,
|
||||
0,
|
||||
inputItem,
|
||||
newData,
|
||||
{
|
||||
include: 'all',
|
||||
},
|
||||
3.3,
|
||||
);
|
||||
|
||||
expect(resultWithoutIncludeBinary.binary).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should include binary when expected in version >=3.4', () => {
|
||||
const fakeExecuteFunction = createMockExecuteFunction({});
|
||||
|
||||
const inputItem = {
|
||||
json: {
|
||||
input1: 'value1',
|
||||
input2: 2,
|
||||
input3: [1, 2, 3],
|
||||
},
|
||||
pairedItem: {
|
||||
item: 0,
|
||||
input: undefined,
|
||||
},
|
||||
binary: {
|
||||
data: {
|
||||
data: 'content',
|
||||
mimeType: 'image/jpg',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const newData = {
|
||||
num1: 55,
|
||||
str1: '42',
|
||||
arr1: ['foo', 'bar'],
|
||||
obj: {
|
||||
key: 'value',
|
||||
},
|
||||
};
|
||||
|
||||
const resultWithStripBinary = composeReturnItem.call(
|
||||
fakeExecuteFunction,
|
||||
0,
|
||||
inputItem,
|
||||
newData,
|
||||
{
|
||||
include: 'all',
|
||||
stripBinary: true,
|
||||
},
|
||||
3.4,
|
||||
);
|
||||
|
||||
expect(resultWithStripBinary.binary).toBeUndefined();
|
||||
|
||||
const resultWithoutStripBinary = composeReturnItem.call(
|
||||
fakeExecuteFunction,
|
||||
0,
|
||||
inputItem,
|
||||
newData,
|
||||
{
|
||||
include: 'all',
|
||||
},
|
||||
3.4,
|
||||
);
|
||||
|
||||
expect(resultWithoutStripBinary.binary).toEqual(inputItem.binary);
|
||||
});
|
||||
});
|
||||
|
||||
describe('test Set2, parseJsonParameter', () => {
|
||||
|
||||
Reference in New Issue
Block a user