diff --git a/lib/features/popup-menu/ReplaceMenuProvider.js b/lib/features/popup-menu/ReplaceMenuProvider.js index e7602391..851bdf0d 100644 --- a/lib/features/popup-menu/ReplaceMenuProvider.js +++ b/lib/features/popup-menu/ReplaceMenuProvider.js @@ -484,9 +484,15 @@ ReplaceMenuProvider.prototype._getAdHocEntry = function(element) { active: isAdHoc, action: function(event, entry) { if (isAdHoc) { - return replaceElement(element, { type: 'bpmn:SubProcess' }); + return replaceElement(element, { type: 'bpmn:SubProcess' }, { + autoResize: false, + layoutConnection: false + }); } else { - return replaceElement(element, { type: 'bpmn:AdHocSubProcess' }); + return replaceElement(element, { type: 'bpmn:AdHocSubProcess' }, { + autoResize: false, + layoutConnection: false + }); } } }; diff --git a/test/spec/features/popup-menu/ReplaceMenuProvider.collapsedSubProcess.bpmn b/test/spec/features/popup-menu/ReplaceMenuProvider.collapsedSubProcess.bpmn index aa2b19e1..21cf22e5 100644 --- a/test/spec/features/popup-menu/ReplaceMenuProvider.collapsedSubProcess.bpmn +++ b/test/spec/features/popup-menu/ReplaceMenuProvider.collapsedSubProcess.bpmn @@ -1,13 +1,95 @@ - + + + SequenceFlow_3 + + SequenceFlow_1 + + + SequenceFlow_1 + SequenceFlow_2 + + + + SequenceFlow_2 + + + + + SequenceFlow_3 + + + + + SequenceFlow_4 + + + SequenceFlow_4 + SequenceFlow_5 + + + SequenceFlow_5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js index 527ee3a4..35891bfc 100644 --- a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +++ b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js @@ -1,3 +1,5 @@ +/* global sinon */ + import { bootstrapModeler, getBpmnJS, @@ -8,10 +10,11 @@ import { createEvent as globalEvent } from '../../../util/MockEvents'; +import autoResizeModule from 'lib/features/auto-resize'; import coreModule from 'lib/core'; +import customRulesModule from '../../../util/custom-rules'; import modelingModule from 'lib/features/modeling'; import replaceMenuProviderModule from 'lib/features/popup-menu'; -import customRulesModule from '../../../util/custom-rules'; import { query as domQuery, @@ -58,6 +61,8 @@ function triggerAction(entries, id) { entry.action(); } +var spy = sinon.spy; + describe('features/popup-menu - replace menu provider', function() { @@ -1884,6 +1889,100 @@ describe('features/popup-menu - replace menu provider', function() { }); + + describe('adhoc sub process', function() { + + var diagramXML = require('./ReplaceMenuProvider.collapsedSubProcess.bpmn'); + + beforeEach(bootstrapModeler(diagramXML, { + modules: testModules.concat(autoResizeModule) + })); + + + describe('sub process -> adhoc', function() { + + it('should not resize', inject(function(elementRegistry, modeling, popupMenu) { + + // given + var subProcess = elementRegistry.get('SubProcess_1'); + + var resizeShapeSpy = spy(modeling, 'resizeShape'); + + // when + openPopup(subProcess); + + var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc'); + + popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 })); + + // then + expect(resizeShapeSpy).not.to.have.been.called; + })); + + + it('should not lay out connection', inject(function(elementRegistry, modeling, popupMenu) { + + // given + var subProcess = elementRegistry.get('SubProcess_1'); + + var layoutConnectionSpy = spy(modeling, 'layoutConnection'); + + // when + openPopup(subProcess); + + var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc'); + + popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 })); + + // then + expect(layoutConnectionSpy).not.to.have.been.called; + })); + + }); + + describe('adhoc -> sub process', function() { + + it('should not resize', inject(function(elementRegistry, modeling, popupMenu) { + + // given + var adhocSubProcess = elementRegistry.get('AdhocSubProcess_1'); + + var resizeShapeSpy = spy(modeling, 'resizeShape'); + + // when + openPopup(adhocSubProcess); + + var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc'); + + popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 })); + + // then + expect(resizeShapeSpy).not.to.have.been.called; + })); + + + it('should not lay out connection', inject(function(elementRegistry, modeling, popupMenu) { + + // given + var adhocSubProcess = elementRegistry.get('AdhocSubProcess_1'); + + var layoutConnectionSpy = spy(modeling, 'layoutConnection'); + + // when + openPopup(adhocSubProcess); + + var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc'); + + popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 })); + + // then + expect(layoutConnectionSpy).not.to.have.been.called; + })); + + }); + + }); + });