diff --git a/lib/features/modeling/behavior/DataStoreBehavior.js b/lib/features/modeling/behavior/DataStoreBehavior.js index ff41d637..74242e56 100644 --- a/lib/features/modeling/behavior/DataStoreBehavior.js +++ b/lib/features/modeling/behavior/DataStoreBehavior.js @@ -132,15 +132,14 @@ export default function DataStoreBehavior( }); - // update data store parents on participant deleted + // update data store parents on participant or subprocess deleted this.postExecute('shape.delete', function(event) { var context = event.context, shape = context.shape, - rootElement; - - if (isAny(shape, [ 'bpmn:Participant', 'bpmn:SubProcess' ])) { - rootElement = canvas.getRootElement(); + rootElement = canvas.getRootElement(); + if (isAny(shape, [ 'bpmn:Participant', 'bpmn:SubProcess' ]) + && is(rootElement, 'bpmn:Collaboration')) { getDataStores(rootElement) .filter(function(dataStore) { return isDescendant(dataStore, shape); diff --git a/test/spec/features/modeling/behavior/DataStoreBehavior.process.bpmn b/test/spec/features/modeling/behavior/DataStoreBehavior.process.bpmn index 16d63a77..c1da3990 100644 --- a/test/spec/features/modeling/behavior/DataStoreBehavior.process.bpmn +++ b/test/spec/features/modeling/behavior/DataStoreBehavior.process.bpmn @@ -1,7 +1,8 @@ - + + @@ -11,6 +12,9 @@ + + + diff --git a/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js b/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js index c99a27bc..d84a7aca 100644 --- a/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js @@ -1,3 +1,5 @@ +/* global sinon */ + import { bootstrapModeler, inject @@ -312,6 +314,32 @@ describe('features/modeling/behavior - data store', function() { }); + describe('process', function() { + var processDiagramXML = require('./DataStoreBehavior.process.bpmn'); + + beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules })); + + it('should not update parent on subprocess delete', inject( + function(elementRegistry, eventBus, modeling) { + + // given + var spy = sinon.spy(); + + eventBus.on('commandStack.dataStore.updateContainment.execute', spy); + + var subProcessElement = elementRegistry.get('SubProcess'); + + // when + modeling.removeShape(subProcessElement); + + // then + expect(spy).to.not.have.been.called; + } + )); + + }); + + describe('collaboration', function() { describe('update parent on participant removed', function() {