From 7c965b07a0db639500857744f49ee2faab5d128e Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Wed, 14 Feb 2024 15:59:26 +0100 Subject: [PATCH] feat: support zeebe:userTask Related to https://github.com/camunda/camunda-modeler/issues/4087 --- resources/zeebe.json | 17 ++++++ ...formDefinition-externalReference.part.bpmn | 9 +++ .../xml/userTask-zeebe-formDefinition.bpmn | 26 +++++++++ .../xml/userTask-zeebe-userTask.part.bpmn | 9 +++ test/spec/xml/read.js | 55 +++++++++++++++++++ test/spec/xml/roundtrip.js | 6 ++ test/spec/xml/write.js | 44 +++++++++++++++ 7 files changed, 166 insertions(+) create mode 100644 test/fixtures/xml/userTask-zeebe-formDefinition-externalReference.part.bpmn create mode 100644 test/fixtures/xml/userTask-zeebe-formDefinition.bpmn create mode 100644 test/fixtures/xml/userTask-zeebe-userTask.part.bpmn diff --git a/resources/zeebe.json b/resources/zeebe.json index 9216911..f368c3d 100644 --- a/resources/zeebe.json +++ b/resources/zeebe.json @@ -292,9 +292,26 @@ "name": "formId", "type": "String", "isAttr": true + }, + { + "name": "externalReference", + "type": "String", + "isAttr": true } ] }, + { + "name": "UserTask", + "superClass": [ + "Element" + ], + "meta": { + "allowedIn": [ + "bpmn:UserTask" + ] + }, + "properties": [] + }, { "name": "CalledDecision", "superClass": [ diff --git a/test/fixtures/xml/userTask-zeebe-formDefinition-externalReference.part.bpmn b/test/fixtures/xml/userTask-zeebe-formDefinition-externalReference.part.bpmn new file mode 100644 index 0000000..522fe61 --- /dev/null +++ b/test/fixtures/xml/userTask-zeebe-formDefinition-externalReference.part.bpmn @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/test/fixtures/xml/userTask-zeebe-formDefinition.bpmn b/test/fixtures/xml/userTask-zeebe-formDefinition.bpmn new file mode 100644 index 0000000..34efb66 --- /dev/null +++ b/test/fixtures/xml/userTask-zeebe-formDefinition.bpmn @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/fixtures/xml/userTask-zeebe-userTask.part.bpmn b/test/fixtures/xml/userTask-zeebe-userTask.part.bpmn new file mode 100644 index 0000000..74ea34b --- /dev/null +++ b/test/fixtures/xml/userTask-zeebe-userTask.part.bpmn @@ -0,0 +1,9 @@ + + + + + diff --git a/test/spec/xml/read.js b/test/spec/xml/read.js index 167f054..c50bcba 100644 --- a/test/spec/xml/read.js +++ b/test/spec/xml/read.js @@ -582,11 +582,66 @@ describe('read', function() { }); }); + + it('zeebe:externalReference', async function() { + + // given + var xml = readFile('test/fixtures/xml/userTask-zeebe-formDefinition-externalReference.part.bpmn'); + + // when + const { + rootElement: proc + } = await moddle.fromXML(xml, 'bpmn:UserTask'); + + // then + expect(proc).to.jsonEqual({ + $type: 'bpmn:UserTask', + id: 'user-task-1', + extensionElements: { + $type: 'bpmn:ExtensionElements', + values: [ + { + $type: 'zeebe:FormDefinition', + externalReference: 'form-1' + } + ] + } + }); + }); }); }); + describe('zeebe:userTask', function() { + + it('should read', async function() { + + // given + var xml = readFile('test/fixtures/xml/userTask-zeebe-userTask.part.bpmn'); + + // when + const { + rootElement: proc + } = await moddle.fromXML(xml, 'bpmn:UserTask'); + + // then + expect(proc).to.jsonEqual({ + $type: 'bpmn:UserTask', + id: 'user-task-1', + extensionElements: { + $type: 'bpmn:ExtensionElements', + values: [ + { + $type: 'zeebe:UserTask' + } + ] + } + }); + }); + }); + + describe('zeebe:calledDecision', function() { it('on BusinessRuleTask', async function() { diff --git a/test/spec/xml/roundtrip.js b/test/spec/xml/roundtrip.js index 81cea6f..04583b8 100644 --- a/test/spec/xml/roundtrip.js +++ b/test/spec/xml/roundtrip.js @@ -54,4 +54,10 @@ describe('import -> export roundtrip', function() { it('should keep zeebe:modelerTemplate', validateExport('test/fixtures/xml/rootElement.bpmn')); + + + describe('userTask', function() { + + it('should keep zeebe:formDefinition properties', validateExport('test/fixtures/xml/userTask-zeebe-formDefinition.bpmn')); + }); }); diff --git a/test/spec/xml/write.js b/test/spec/xml/write.js index 1994180..c0c6d89 100644 --- a/test/spec/xml/write.js +++ b/test/spec/xml/write.js @@ -281,6 +281,50 @@ describe('write', function() { expect(xml).to.eql(expectedXML); }); + + it('zeebe:externalReference', async function() { + + // given + var proc = moddle.create('bpmn:UserTask', { + extensionElements: moddle.create('bpmn:ExtensionElements', { + values: [ + moddle.create('zeebe:FormDefinition', { + externalReference: 'form-1' + }) + ] + }) + }); + + var expectedXML = + '' + + '' + + '' + + '' + + ''; + + // when + const xml = await write(proc); + + // then + expect(xml).to.eql(expectedXML); + }); + }); + + + it('zeebe:userTask', async function() { + + // given + var userTask = moddle.create('zeebe:UserTask', {}); + + var expectedXML = ''; + + // when + const xml = await write(userTask); + + // then + expect(xml).to.eql(expectedXML); });