From e18370cb10faf16b99e944c5ce6e0c4af662eaf0 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Wed, 19 May 2021 18:44:27 -0500 Subject: [PATCH] :bug: Fix issue with default value for multipleValues string with none stanard default value --- packages/workflow/src/NodeHelpers.ts | 5 +- packages/workflow/test/NodeHelpers.test.ts | 94 ++++++++++++++++++++-- 2 files changed, 88 insertions(+), 11 deletions(-) diff --git a/packages/workflow/src/NodeHelpers.ts b/packages/workflow/src/NodeHelpers.ts index b298038af2..0a86250e2a 100644 --- a/packages/workflow/src/NodeHelpers.ts +++ b/packages/workflow/src/NodeHelpers.ts @@ -612,9 +612,8 @@ export function getNodeParameters(nodePropertiesArray: INodeProperties[], nodeVa if (nodeValues[nodeProperties.name] !== undefined) { nodeParameters[nodeProperties.name] = nodeValues[nodeProperties.name]; } else if (returnDefaults === true) { - // Does not have values defined but defaults should be returned which is in the - // case of a collection with multipleValues always an empty array - nodeParameters[nodeProperties.name] = []; + // Does not have values defined but defaults should be returned + nodeParameters[nodeProperties.name] = JSON.parse(JSON.stringify(nodeProperties.default)); } nodeParametersFull[nodeProperties.name] = nodeParameters[nodeProperties.name]; } else { diff --git a/packages/workflow/test/NodeHelpers.test.ts b/packages/workflow/test/NodeHelpers.test.ts index 048aaeed88..98ce77c4fd 100644 --- a/packages/workflow/test/NodeHelpers.test.ts +++ b/packages/workflow/test/NodeHelpers.test.ts @@ -2174,7 +2174,7 @@ describe('Workflow', () => { typeOptions: { multipleValues: true, }, - default: {}, + default: [], options: [ { displayName: 'string1', @@ -2195,17 +2195,13 @@ describe('Workflow', () => { }, output: { noneDisplayedFalse: { - defaultsFalse: { - // collection1: [], - }, + defaultsFalse: {}, defaultsTrue: { collection1: [], }, }, noneDisplayedTrue: { - defaultsFalse: { - // collection1: [], - }, + defaultsFalse: {}, defaultsTrue: { collection1: [], }, @@ -2940,7 +2936,7 @@ describe('Workflow', () => { }, }, { - description: 'complex type "fixedCollection" with "multipleValues: true". Which contains parameter of type multiOptions and has so an array default value.', + description: 'complex type "fixedCollection" with "multipleValues: true". Which contains parameter of type "multiOptions" and has so an array default value', input: { nodePropertiesArray: [ { @@ -3028,6 +3024,88 @@ describe('Workflow', () => { }, }, }, + { + description: 'complex type "fixedCollection" with "multipleValues: true". Which contains parameter of type "string" with "multipleValues: true" and a custom default value', + input: { + nodePropertiesArray: [ + { + name: 'values', + displayName: 'Values', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + options: [ + { + name: 'propertyValues', + displayName: 'Property', + values: [ + { + displayName: 'MultiString', + name: 'multiString', + type: 'string', + typeOptions: { + multipleValues: true, + }, + default: ['value1'], + }, + ], + }, + ], + }, + ], + nodeValues: { + values: { + propertyValues: [ + { + multiString: ['value1'], + } + ] + }, + }, + }, + output: { + noneDisplayedFalse: { + defaultsFalse: { + values: { + propertyValues: [ + { + } + ], + }, + }, + defaultsTrue: { + values: { + propertyValues: [ + { + multiString: ['value1'], + } + ], + }, + }, + }, + noneDisplayedTrue: { + defaultsFalse: { + values: { + propertyValues: [ + { + } + ], + }, + }, + defaultsTrue: { + values: { + propertyValues: [ + { + multiString: ['value1'], + } + ], + }, + }, + }, + }, + }, ];