diff --git a/package-lock.json b/package-lock.json index ba61263f9..2cd933833 100644 --- a/package-lock.json +++ b/package-lock.json @@ -360,13 +360,13 @@ } }, "@bpmn-io/element-templates-validator": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@bpmn-io/element-templates-validator/-/element-templates-validator-0.3.0.tgz", - "integrity": "sha512-EWFHwW3OXXsBhSkyMqk4h2lUaJPMZV+C3jO5kgB90NX77dBgQyj1ii1v/7HgL2r9RfbW7G6LCTdmw2wsgceOzw==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@bpmn-io/element-templates-validator/-/element-templates-validator-0.4.0.tgz", + "integrity": "sha512-cJtmUHn/4QpkeGQ/tUBQO020Cr1x2AILYczzMioRCGRSEekR/8wSaeEFuEx5ujFNDbHSx2lLN5P2ZmHlpD1Tmg==", "requires": { - "@camunda/element-templates-json-schema": "^0.5.0", + "@camunda/element-templates-json-schema": "^0.6.0", "json-source-map": "^0.6.1", - "min-dash": "^3.8.0" + "min-dash": "^3.8.1" } }, "@bpmn-io/extract-process-variables": { @@ -389,9 +389,9 @@ } }, "@camunda/element-templates-json-schema": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@camunda/element-templates-json-schema/-/element-templates-json-schema-0.5.0.tgz", - "integrity": "sha512-cFOz6SeQsNVpHlndCTQendvJrvGjFDk0rkKBgELCYjDm3XH74EonW9ujChvIcc8o9HECNQo6p7sHSAe980HWXw==" + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@camunda/element-templates-json-schema/-/element-templates-json-schema-0.6.0.tgz", + "integrity": "sha512-sfNIOKSfx/VQesCe1+m1izfIZS64NWDZq3teyMzzfJkn37u0ngwIwEXlc7Voj8Qcg2paePT8HmEgp+TJP39V3Q==" }, "@eslint/eslintrc": { "version": "0.4.3", diff --git a/package.json b/package.json index 17fbe1e40..04f00c173 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ ], "license": "MIT", "dependencies": { - "@bpmn-io/element-templates-validator": "^0.3.0", + "@bpmn-io/element-templates-validator": "^0.4.0", "@bpmn-io/extract-process-variables": "^0.4.4", "array-move": "^3.0.1", "classnames": "^2.3.1", diff --git a/test/spec/provider/element-templates/Validator.spec.js b/test/spec/provider/element-templates/Validator.spec.js index 84fa4e549..1f2a6d8dc 100644 --- a/test/spec/provider/element-templates/Validator.spec.js +++ b/test/spec/provider/element-templates/Validator.spec.js @@ -594,5 +594,42 @@ describe('provider/element-templates - Validator', function() { }); + describe('grouping', function() { + + it('should accept groups', function() { + + // given + const templates = new Validator(); + + const templateDescriptor = require('./fixtures/groups'); + + // when + templates.addAll(templateDescriptor); + + // then + expect(errors(templates)).to.be.empty; + + expect(valid(templates)).to.have.length(templateDescriptor.length); + }); + + + it('should not accept missing group id', function() { + + // given + const templates = new Validator(); + + const templateDescriptor = require('./fixtures/error-groups-missing-id'); + + // when + templates.addAll(templateDescriptor); + + // then + expect(errors(templates)).to.contain('template(id: , name: ): missing id for group "0"'); + + expect(valid(templates)).to.be.empty; + }); + + }); + }); }); diff --git a/test/spec/provider/element-templates/fixtures/error-groups-missing-id.json b/test/spec/provider/element-templates/fixtures/error-groups-missing-id.json new file mode 100644 index 000000000..c07ab9c0e --- /dev/null +++ b/test/spec/provider/element-templates/fixtures/error-groups-missing-id.json @@ -0,0 +1,23 @@ +[ + { + "name": "Missing group id", + "id": "example.com.missingGroupId", + "appliesTo": [ + "bpmn:ServiceTask" + ], + "properties": [], + "groups": [ + { + "label": "Group one" + }, + { + "id": "two", + "label": "Group two" + }, + { + "id": "three", + "label": "Group three" + } + ] + } +] \ No newline at end of file diff --git a/test/spec/provider/element-templates/fixtures/groups.json b/test/spec/provider/element-templates/fixtures/groups.json new file mode 100644 index 000000000..6057dc8fc --- /dev/null +++ b/test/spec/provider/element-templates/fixtures/groups.json @@ -0,0 +1,69 @@ +[ + { + "name": "Grouping", + "id": "example.com.grouping", + "appliesTo": [ + "bpmn:ServiceTask" + ], + "properties": [ + { + "label": "input 1", + "type": "String", + "binding": { + "type": "camunda:inputParameter", + "name": "input1" + } + }, + { + "label": "input 2", + "group": "one", + "type": "String", + "binding": { + "type": "camunda:inputParameter", + "name": "input2" + } + }, + { + "label": "input 3", + "group": "one", + "type": "String", + "binding": { + "type": "camunda:inputParameter", + "name": "input3" + } + }, + { + "label": "input 4", + "group": "two", + "type": "String", + "binding": { + "type": "camunda:inputParameter", + "name": "input4" + } + }, + { + "label": "input 5", + "group": "three", + "type": "String", + "binding": { + "type": "camunda:inputParameter", + "name": "input5" + } + } + ], + "groups": [ + { + "id": "one", + "label": "Group one" + }, + { + "id": "two", + "label": "Group two" + }, + { + "id": "three", + "label": "Group three" + } + ] + } +] \ No newline at end of file