diff --git a/packages/element-templates-json-schema-shared/src/defs/base-properties.json b/packages/element-templates-json-schema-shared/src/defs/base-properties.json index 9d2ef1d..3a4288b 100644 --- a/packages/element-templates-json-schema-shared/src/defs/base-properties.json +++ b/packages/element-templates-json-schema-shared/src/defs/base-properties.json @@ -78,6 +78,9 @@ "$id": "#/properties/property/choices/item/value", "type": "string", "description": "The value of a choice." + }, + "condition": { + "$ref": "condition.json" } }, "required": [ diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-dropdown-choices-invalid.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-dropdown-choices-invalid.js new file mode 100644 index 0000000..f9e21b7 --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-dropdown-choices-invalid.js @@ -0,0 +1,65 @@ +export const template = { + 'name': 'Condition', + 'id': 'example.com.condition', + 'appliesTo': [ + 'bpmn:ServiceTask' + ], + 'properties': [ + { + 'id': 'myId', + 'label': 'input 1', + 'type': 'String', + 'binding': { + 'type': 'property', + 'name': 'input1' + } + }, + { + 'label': 'Dropdown', + 'type': 'Dropdown', + 'choices': [ + { + 'value': 'opt1', + 'name':'opt1' + }, + { + 'value': 'opt2', + 'name': 'opt2' + }, + { + 'value': 'opt3', + 'name': 'opt3', + 'condition': 'myId == 2' + } + ], + 'binding': { + 'type': 'zeebe:property', + 'name': 'method' + } + } + ] +}; + +export const errors = [ + { + keyword: 'type', + dataPath: '/properties/1/choices/2/condition', + schemaPath: '#/type', + params: { type: 'object' }, + message: 'should be object' + }, + { + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { type: 'array' }, + message: 'should be array' + }, + { + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' + } +]; \ No newline at end of file diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-dropdown-choices.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-dropdown-choices.js new file mode 100644 index 0000000..e78b419 --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-dropdown-choices.js @@ -0,0 +1,46 @@ +export const template = { + 'name': 'Condition', + 'id': 'example.com.condition', + 'appliesTo': [ + 'bpmn:ServiceTask' + ], + 'properties': [ + { + 'id': 'myId', + 'label': 'input 1', + 'type': 'String', + 'binding': { + 'type': 'property', + 'name': 'input1' + } + }, + { + 'label': 'Dropdown', + 'type': 'Dropdown', + 'choices': [ + { + 'value': 'opt1', + 'name':'opt1' + }, + { + 'value': 'opt2', + 'name': 'opt2' + }, + { + 'value': 'opt3', + 'name': 'opt3', + 'condition': { + 'property': 'myId', + 'equals': 'text' + } + } + ], + 'binding': { + 'type': 'zeebe:property', + 'name': 'method' + } + } + ] +}; + +export const errors = null; \ No newline at end of file diff --git a/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js b/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js index ffe308b..4ca5d86 100644 --- a/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js +++ b/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js @@ -281,6 +281,11 @@ describe('validation', function() { testTemplate('condition-allMatch-one-condition'); + + testTemplate('condition-dropdown-choices'); + + + testTemplate('condition-dropdown-choices-invalid'); });