Skip to content

Commit 484bdf0

Browse files
committed
test: add zeebe:priorityDefinition tests
1 parent c99df5a commit 484bdf0

File tree

4 files changed

+158
-2
lines changed

4 files changed

+158
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ All notable changes to [element-templates-validator](https://github.com/bpmn-io/
44

55
## Unreleased
66

7-
___Note:__ Yet to be released changes appear here._
7+
* `FEAT`: support `zeebe:priorityDefinition` binding ([#64](https://github.com/bpmn-io/element-templates-validator/pull/64))
8+
* `DEPS`: update to `@camunda/[email protected]`
89

910
## 2.9.0
1011

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[
2+
{
3+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
4+
"name": "Priority Definition",
5+
"id": "priority-definition-invalid-property",
6+
"description": "A template to define task priority based on a variable.",
7+
"version": 1,
8+
"appliesTo": [
9+
"bpmn:Task"
10+
],
11+
"elementType": {
12+
"value": "bpmn:UserTask"
13+
},
14+
"properties": [
15+
{
16+
"type": "Hidden",
17+
"binding": {
18+
"type": "zeebe:userTask"
19+
}
20+
},
21+
{
22+
"label": "Prio",
23+
"value": "100",
24+
"description": "Prio for task",
25+
"constraints": {
26+
"notEmpty": true
27+
},
28+
"type": "String",
29+
"binding": {
30+
"type": "zeebe:priorityDefinition",
31+
"property": "youShallNotPass"
32+
}
33+
}
34+
]
35+
},
36+
{
37+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
38+
"name": "Priority Definition",
39+
"id": "priority-definition-invalid-values",
40+
"description": "A template to define task priority based on a variable.",
41+
"version": 1,
42+
"appliesTo": [
43+
"bpmn:Task"
44+
],
45+
"elementType": {
46+
"value": "bpmn:UserTask"
47+
},
48+
"properties": [
49+
{
50+
"type": "Hidden",
51+
"binding": {
52+
"type": "zeebe:userTask"
53+
}
54+
},
55+
{
56+
"label": "Prio",
57+
"value": -1,
58+
"description": "Prio for task",
59+
"type": "Number",
60+
"binding": {
61+
"type": "zeebe:priorityDefinition",
62+
"property": "priority"
63+
}
64+
}
65+
]
66+
}
67+
]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[
2+
{
3+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
4+
"name": "Priority Definition",
5+
"id": "priority-definition",
6+
"description": "A template to define user task priority based on a variable",
7+
"appliesTo": [
8+
"bpmn:Task"
9+
],
10+
"elementType": {
11+
"value": "bpmn:UserTask"
12+
},
13+
"properties": [
14+
{
15+
"type": "Hidden",
16+
"binding": {
17+
"type": "zeebe:userTask"
18+
}
19+
},
20+
{
21+
"label": "Prio",
22+
"value": "100",
23+
"description": "Prio for task",
24+
"constraints": {
25+
"notEmpty": true
26+
},
27+
"type": "Dropdown",
28+
"binding": {
29+
"type": "zeebe:priorityDefinition",
30+
"property": "priority"
31+
},
32+
"choices": [
33+
{
34+
"name": "High",
35+
"value": "100"
36+
},
37+
{
38+
"name": "Medium",
39+
"value": "50"
40+
},
41+
{
42+
"name": "Low",
43+
"value": "0"
44+
}
45+
]
46+
}
47+
]
48+
}
49+
]

test/spec/validationSpec.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ describe('Validator', function() {
334334
message: 'must provide choices=[] with "Dropdown" type'
335335
},
336336
{
337-
message: 'invalid property.binding type "zeebe:taskDefinition:foo"; must be any of { property, zeebe:taskDefinition:type, zeebe:input, zeebe:output, zeebe:property, zeebe:taskHeader, bpmn:Message#property, bpmn:Message#zeebe:subscription#property, zeebe:taskDefinition, zeebe:calledElement, zeebe:linkedResource, zeebe:userTask, zeebe:formDefinition, zeebe:calledDecision, zeebe:script, zeebe:assignmentDefinition }'
337+
message: 'invalid property.binding type "zeebe:taskDefinition:foo"; must be any of { property, zeebe:taskDefinition:type, zeebe:input, zeebe:output, zeebe:property, zeebe:taskHeader, bpmn:Message#property, bpmn:Message#zeebe:subscription#property, zeebe:taskDefinition, zeebe:calledElement, zeebe:linkedResource, zeebe:userTask, zeebe:formDefinition, zeebe:calledDecision, zeebe:script, zeebe:assignmentDefinition, zeebe:priorityDefinition }'
338338
},
339339
{
340340
message: 'property.binding "zeebe:taskHeader" requires key'
@@ -893,6 +893,45 @@ describe('Validator', function() {
893893
});
894894

895895

896+
it('should validate priorityDefinition templates', function() {
897+
898+
// given
899+
const samples = require('../fixtures/priority-definition.json');
900+
901+
// when
902+
const {
903+
valid,
904+
results
905+
} = validateAllZeebe(samples);
906+
907+
// then
908+
expect(valid).to.be.true;
909+
expect(results.length).to.eql(samples.length);
910+
911+
expect(results.every(r => r.valid)).to.be.true;
912+
913+
expect(results.map(r => r.object)).to.eql(samples);
914+
});
915+
916+
917+
it('should validate priorityDefinition templates with errors', function() {
918+
919+
// given
920+
const samples = require('../fixtures/priority-definition-broken.json');
921+
922+
// when
923+
const {
924+
valid,
925+
results
926+
} = validateAllZeebe(samples);
927+
928+
// then
929+
expect(valid).to.be.false;
930+
expect(results.every(r => !r.valid)).to.be.true;
931+
expect(results.map(r => r.object)).to.eql(samples);
932+
});
933+
934+
896935
describe('property', function() {
897936

898937
it('should validate', function() {

0 commit comments

Comments
 (0)