From acb37167169434935868a79400a6b0440c4d0835 Mon Sep 17 00:00:00 2001 From: pedesen Date: Thu, 19 Nov 2015 13:28:39 +0100 Subject: [PATCH] fix(replace): properly set parent of event definitions Related to bpmn-io/bpmn-js-properties-panel#82 --- lib/features/replace/BpmnReplace.js | 1 + test/spec/features/replace/BpmnReplaceSpec.js | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/features/replace/BpmnReplace.js b/lib/features/replace/BpmnReplace.js index b356645f..f848be98 100644 --- a/lib/features/replace/BpmnReplace.js +++ b/lib/features/replace/BpmnReplace.js @@ -76,6 +76,7 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection, modelin var eventDefinitions = businessObject.get('eventDefinitions'), eventDefinition = moddle.create(target.eventDefinition); + eventDefinition.$parent = businessObject; eventDefinitions.push(eventDefinition); } diff --git a/test/spec/features/replace/BpmnReplaceSpec.js b/test/spec/features/replace/BpmnReplaceSpec.js index 01114b68..fa6e9bd7 100644 --- a/test/spec/features/replace/BpmnReplaceSpec.js +++ b/test/spec/features/replace/BpmnReplaceSpec.js @@ -1374,4 +1374,26 @@ describe('features/replace', function() { }); + describe('events', function() { + + var diagramXML = require('../../../fixtures/bpmn/basic.bpmn'); + + beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); + + it('should properly set parent of event definitions', inject(function(elementRegistry, modeling, bpmnReplace) { + + var startEvent = elementRegistry.get('StartEvent_1'); + + var messageEvent = bpmnReplace.replaceElement(startEvent, { + type: 'bpmn:StartEvent', + eventDefinition: 'bpmn:MessageEventDefinition' + }); + + var parent = messageEvent.businessObject.eventDefinitions[0].$parent; + + expect(parent).to.exist; + expect(parent).to.equal(messageEvent.businessObject); + })); + }); + });