Skip to content

Commit d07190b

Browse files
yT0n1philippfromme
authored andcommitted
test: add zeebe:adHoc tests
related to camunda/tmp-camunda-modeler-adhoc-subprocess#2
1 parent 5a88659 commit d07190b

File tree

3 files changed

+137
-1
lines changed

3 files changed

+137
-1
lines changed

test/fixtures/ad-hoc-broken.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[
2+
{
3+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
4+
"name": "AdHoc Missing TaskDefinition",
5+
"id": "io.camunda.examples.AdHoc.MissingTaskDefinition",
6+
"version": 1,
7+
"appliesTo": ["bpmn:AdHocSubProcess"],
8+
"elementType": {"value": "bpmn:AdHocSubProcess"},
9+
"properties": [
10+
{
11+
"type": "Hidden",
12+
"binding": {"type": "zeebe:adHoc", "property": "outputCollection"},
13+
"value": "toolCallResults"
14+
},
15+
{
16+
"type": "String",
17+
"binding": {"type": "zeebe:adHoc", "property": "outputElement"},
18+
"feel": "required",
19+
"value": "={ id: toolCall._meta.id, name: toolCall._meta.name, content: toolCallResult }"
20+
}
21+
]
22+
},
23+
{
24+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
25+
"name": "AdHoc Missing Output Collection",
26+
"id": "io.camunda.examples.AdHoc.MissingOutputCollection",
27+
"version": 1,
28+
"appliesTo": ["bpmn:AdHocSubProcess"],
29+
"elementType": {"value": "bpmn:AdHocSubProcess"},
30+
"properties": [
31+
{
32+
"type": "Hidden",
33+
"binding": {"type": "zeebe:taskDefinition", "property": "type"},
34+
"value": "io.camunda.agenticai:aiagent-job-worker:1"
35+
},
36+
{
37+
"type": "String",
38+
"binding": {"type": "zeebe:adHoc", "property": "outputElement"},
39+
"feel": "required",
40+
"value": "={ id: toolCall._meta.id, name: toolCall._meta.name, content: toolCallResult }"
41+
}
42+
]
43+
}
44+
]

test/fixtures/ad-hoc.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[
2+
{
3+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
4+
"name": "AdHoc Template",
5+
"id": "io.camunda.examples.AdHoc.Valid.v1",
6+
"version": 1,
7+
"appliesTo": ["bpmn:AdHocSubProcess"],
8+
"elementType": {"value": "bpmn:AdHocSubProcess"},
9+
"properties": [
10+
{
11+
"type": "Hidden",
12+
"binding": {"type": "zeebe:taskDefinition", "property": "type"},
13+
"value": "io.camunda.agenticai:aiagent-job-worker:1"
14+
},
15+
{
16+
"type": "Hidden",
17+
"binding": {"type": "zeebe:adHoc", "property": "outputCollection"},
18+
"value": "toolCallResults"
19+
},
20+
{
21+
"type": "Hidden",
22+
"binding": {"type": "zeebe:adHoc", "property": "outputElement"},
23+
"value": "={ id: toolCall._meta.id, name: toolCall._meta.name, content: toolCallResult }"
24+
}
25+
]
26+
},
27+
{
28+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
29+
"name": "AdHoc Template",
30+
"id": "io.camunda.examples.AdHoc.Valid.v2",
31+
"version": 1,
32+
"appliesTo": ["bpmn:AdHocSubProcess"],
33+
"elementType": {"value": "bpmn:AdHocSubProcess"},
34+
"properties": [
35+
{
36+
"type": "Hidden",
37+
"binding": {"type": "zeebe:taskDefinition", "property": "type"},
38+
"value": "io.camunda.agenticai:aiagent-job-worker:1"
39+
},
40+
{
41+
"type": "String",
42+
"binding": {"type": "zeebe:adHoc", "property": "outputCollection"},
43+
"value": "toolCallResults"
44+
},
45+
{
46+
"type": "String",
47+
"feel": "required",
48+
"binding": {"type": "zeebe:adHoc", "property": "outputElement"},
49+
"value": "={ id: toolCall._meta.id, name: toolCall._meta.name, content: toolCallResult }"
50+
}
51+
]
52+
}
53+
]

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, zeebe:priorityDefinition }'
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, zeebe:adHoc }'
338338
},
339339
{
340340
message: 'property.binding "zeebe:taskHeader" requires key'
@@ -599,6 +599,45 @@ describe('Validator', function() {
599599
});
600600

601601

602+
it('should validate zeebe:adHoc', function() {
603+
604+
// given
605+
const samples = require('../fixtures/ad-hoc.json');
606+
607+
// when
608+
const {
609+
valid,
610+
results
611+
} = validateAllZeebe(samples);
612+
613+
// then
614+
expect(valid).to.be.true;
615+
expect(results.length).to.eql(samples.length);
616+
617+
expect(results.every(r => r.valid)).to.be.true;
618+
619+
expect(results.map(r => r.object)).to.eql(samples);
620+
});
621+
622+
623+
it('should validate zeebe:adHoc with errors', function() {
624+
625+
// given
626+
const samples = require('../fixtures/ad-hoc-broken.json');
627+
628+
// when
629+
const {
630+
valid,
631+
results
632+
} = validateAllZeebe(samples);
633+
634+
// then
635+
expect(valid).to.be.false;
636+
expect(results.every(r => !r.valid)).to.be.true;
637+
expect(results.map(r => r.object)).to.eql(samples);
638+
});
639+
640+
602641
it('should validate linked resource templates', function() {
603642

604643
// given

0 commit comments

Comments
 (0)