From 91dd1b696cad8b13b161a0ddc8c966e63b30ecfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Brengesj=C3=B6?= Date: Thu, 30 Jun 2016 14:43:29 +0200 Subject: [PATCH] fix(replace):ComplexGateway can have default sequence flows The BPMN 2.0 specification[1] states "a Sequence Flow that has an Exclusive, Inclusive or Complex Gateway or an Activity as its source can also be defined with as default." This commit will honor that statement by allowing sequence flows from Complex Gateway to be defined as default. [1] = http://www.omg.org/spec/BPMN/2.0/ --- .../popup-menu/ReplaceMenuProvider.js | 2 + ...vider.defaultFlowsFromComplexGateways.bpmn | 48 +++++++++++++++++++ .../popup-menu/ReplaceMenuProviderSpec.js | 43 +++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromComplexGateways.bpmn diff --git a/lib/features/popup-menu/ReplaceMenuProvider.js b/lib/features/popup-menu/ReplaceMenuProvider.js index 85780e59..b78cfafb 100644 --- a/lib/features/popup-menu/ReplaceMenuProvider.js +++ b/lib/features/popup-menu/ReplaceMenuProvider.js @@ -291,6 +291,7 @@ ReplaceMenuProvider.prototype._createSequenceFlowEntries = function(element, rep if (businessObject.sourceRef.default !== businessObject && (is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') || is(businessObject.sourceRef, 'bpmn:InclusiveGateway') || + is(businessObject.sourceRef, 'bpmn:ComplexGateway') || is(businessObject.sourceRef, 'bpmn:Activity'))) { menuEntries.push(self._createMenuEntry(entry, element, function() { @@ -318,6 +319,7 @@ ReplaceMenuProvider.prototype._createSequenceFlowEntries = function(element, rep // conditional flows if ((is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') || is(businessObject.sourceRef, 'bpmn:InclusiveGateway') || + is(businessObject.sourceRef, 'bpmn:ComplexGateway') || is(businessObject.sourceRef, 'bpmn:Activity')) && businessObject.sourceRef.default === businessObject) { diff --git a/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromComplexGateways.bpmn b/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromComplexGateways.bpmn new file mode 100644 index 00000000..ab4d1ff4 --- /dev/null +++ b/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromComplexGateways.bpmn @@ -0,0 +1,48 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + SequenceFlow_2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js index 4b3d5141..8602df1e 100644 --- a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +++ b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js @@ -979,6 +979,49 @@ describe('features/popup-menu - replace menu provider', function() { }); + describe('default flows from complex gateways', function() { + + var diagramXML = require('./ReplaceMenuProvider.defaultFlowsFromComplexGateways.bpmn'); + + beforeEach(bootstrapModeler(diagramXML, { + modules: testModules + })); + + + it('should show default replace option', inject(function(elementRegistry, popupMenu) { + // given + var sequenceFlow = elementRegistry.get('SequenceFlow_2'); + + // when + openPopup(sequenceFlow); + + var sequenceFlowEntry = queryEntry(popupMenu, 'replace-with-sequence-flow'), + defaultFlowEntry = queryEntry(popupMenu, 'replace-with-default-flow'); + + // then + expect(sequenceFlowEntry).to.not.exist; + expect(defaultFlowEntry).to.exist; + })); + + + it('should NOT show default replace option', inject(function(elementRegistry, popupMenu) { + // given + var sequenceFlow = elementRegistry.get('SequenceFlow_1'); + + // when + openPopup(sequenceFlow); + + var sequenceFlowEntry = queryEntry(popupMenu, 'replace-with-sequence-flow'), + defaultFlowEntry = queryEntry(popupMenu, 'replace-with-default-flow'); + + // then + expect(sequenceFlowEntry).to.exist; + expect(defaultFlowEntry).to.not.exist; + })); + + }); + + describe('conditional flows', function() { var diagramXML = require('./ReplaceMenuProvider.conditionalFlows.bpmn');