diff --git a/lib/features/popup-menu/ReplaceMenuProvider.js b/lib/features/popup-menu/ReplaceMenuProvider.js index d2b1887b..4aaf2fe6 100644 --- a/lib/features/popup-menu/ReplaceMenuProvider.js +++ b/lib/features/popup-menu/ReplaceMenuProvider.js @@ -155,7 +155,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) { var target = entry.target; - if (target.eventDefinition == 'bpmn:CancelEventDefinition' && + if (target.eventDefinitionType == 'bpmn:CancelEventDefinition' && !is(businessObject.attachedToRef, 'bpmn:Transaction')) { return false; } diff --git a/test/fixtures/bpmn/features/replace/cancel-events.bpmn b/test/fixtures/bpmn/features/replace/cancel-events.bpmn index 4e781881..2e5d4d80 100644 --- a/test/fixtures/bpmn/features/replace/cancel-events.bpmn +++ b/test/fixtures/bpmn/features/replace/cancel-events.bpmn @@ -1,5 +1,5 @@ - + @@ -11,39 +11,58 @@ + + + + + + + - - - - - + + - + - + - - + + + + + - + - - + + + + + - + + + + + + + + + + diff --git a/test/spec/features/context-pad/ContextPadProviderSpec.js b/test/spec/features/context-pad/ContextPadProviderSpec.js index adfb5804..24553ecd 100644 --- a/test/spec/features/context-pad/ContextPadProviderSpec.js +++ b/test/spec/features/context-pad/ContextPadProviderSpec.js @@ -479,7 +479,7 @@ describe('features - context-pad', function() { // then var replaceMenu = domQueryAll('[data-id$="-boundary"]', popupMenu._current.container); expect(replaceMenu).to.exist; - expect(replaceMenu.length).to.eql(13); + expect(replaceMenu.length).to.eql(12); } )); @@ -630,4 +630,4 @@ function padEvent(entry) { clientY: 100 }; }); -} \ No newline at end of file +} diff --git a/test/spec/features/modeling/behavior/ReplaceElementBehaviourSpec.js b/test/spec/features/modeling/behavior/ReplaceElementBehaviourSpec.js index 60521247..0881dce6 100644 --- a/test/spec/features/modeling/behavior/ReplaceElementBehaviourSpec.js +++ b/test/spec/features/modeling/behavior/ReplaceElementBehaviourSpec.js @@ -315,7 +315,7 @@ describe('features/modeling - move start event behavior', function() { commandStack.undo(); var afterBoundaryEvent = elementRegistry.filter(function(element) { - return (element.type === 'bpmn:BoundaryEvent' && element.id !== 'BoundaryEvent_2'); + return (element.type === 'bpmn:BoundaryEvent' && element.id === 'BoundaryEvent_1'); })[0]; // then @@ -344,7 +344,7 @@ describe('features/modeling - move start event behavior', function() { modeling.moveElements([ newBoundaryEvent ], { x: 500, y: 0 }, subProcess, ATTACH); var movedBoundaryEvent = elementRegistry.filter(function(element) { - return (element.type === 'bpmn:BoundaryEvent' && element.id !== 'BoundaryEvent_2'); + return (element.type === 'bpmn:BoundaryEvent' && element.id === 'BoundaryEvent_1'); })[0]; // then @@ -378,7 +378,7 @@ describe('features/modeling - move start event behavior', function() { commandStack.undo(); var movedBoundaryEvent = elementRegistry.filter(function(element) { - return (element.type === 'bpmn:BoundaryEvent' && element.id !== 'BoundaryEvent_2'); + return (element.type === 'bpmn:BoundaryEvent' && element.id === 'BoundaryEvent_1'); })[0]; // then diff --git a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js index ea92655e..3d41eaf8 100644 --- a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +++ b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js @@ -39,18 +39,6 @@ describe('features/popup-menu - replace menu provider', function() { customRulesModule ]; - var openPopup = function(element, offset) { - offset = offset || 100; - - getBpmnJS().invoke(function(popupMenu) { - - popupMenu.open(element, 'bpmn-replace', { - x: element.x + offset, y: element.y + offset - }); - - }); - }; - describe('data object - collection marker', function() { @@ -952,70 +940,120 @@ describe('features/popup-menu - replace menu provider', function() { }); - describe('cancel events', function() { + describe('cancel event definition', function() { var diagramXML = require('../../../fixtures/bpmn/features/replace/cancel-events.bpmn'); beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); - it('should contain cancel event replace option', - inject(function(elementRegistry) { - // given - var endEvent = elementRegistry.get('EndEvent_1'); + describe('for end events', function() { - // when - openPopup(endEvent); + it('should contain cancel event replace option in transaction', + inject(function(elementRegistry) { - // then - expect(queryEntries()).to.have.length(9); - }) - ); + // given + var endEvent = elementRegistry.get('EndEvent_3'); + + // when + openPopup(endEvent); + + // then + expect(queryEntries()).to.have.length(9); + + expect(queryEntry('replace-with-cancel-end')).to.exist; + }) + ); - it('should NOT contain cancel event replace option', - inject(function(elementRegistry) { + it('should NOT contain cancel event replace option in transaction when already set', + inject(function(elementRegistry) { - // given - var endEvent = elementRegistry.get('EndEvent_2'); + // given + var endEvent = elementRegistry.get('EndEvent_1'); - // when - openPopup(endEvent); + // when + openPopup(endEvent); - // then - expect(queryEntries()).to.have.length(8); - }) - ); + // then + expect(queryEntries()).to.have.length(9); + expect(queryEntry('replace-with-cancel-end')).to.be.null; + }) + ); - it('should contain cancel event replace option (boundary events)', - inject(function(elementRegistry) { + it('should NOT contain cancel event replace option outside transaction', + inject(function(elementRegistry) { - // given - var boundaryEvent = elementRegistry.get('BoundaryEvent_1'); + // given + var endEvent = elementRegistry.get('EndEvent_2'); - // when - openPopup(boundaryEvent); + // when + openPopup(endEvent); - // then - expect(queryEntries()).to.have.length(13); - }) - ); + // then + expect(queryEntries()).to.have.length(8); + + expect(queryEntry('replace-with-cancel-end')).to.be.null; + }) + ); + + }); - it('should NOT contain cancel event replace option (boundary events)', - inject(function(elementRegistry) { + describe('for boundary events', function() { - // given - var boundaryEvent = elementRegistry.get('BoundaryEvent_2'); + it('should contain cancel event replace option attachted to Transaction', + inject(function(elementRegistry) { - // when - openPopup(boundaryEvent, 40); + // given + var boundaryEvent = elementRegistry.get('BoundaryEvent_1'); - // then - expect(queryEntries()).to.have.length(13); - }) - ); + // when + openPopup(boundaryEvent); + + // then + expect(queryEntries()).to.have.length(13); + + expect(queryEntry('replace-with-cancel-boundary')).to.exist; + }) + ); + + + it('should NOT contain cancel event replace option attached to SubProcess', + inject(function(elementRegistry) { + + // given + var boundaryEvent = elementRegistry.get('BoundaryEvent_2'); + + // when + openPopup(boundaryEvent); + + // then + expect(queryEntries()).to.have.length(12); + + expect(queryEntry('replace-with-cancel-boundary')).to.be.null; + }) + ); + + + it('should NOT contain cancel event replace option attached to Activity', + inject(function(elementRegistry) { + + // given + var boundaryEvent = elementRegistry.get('BoundaryEvent_3'); + + // when + openPopup(boundaryEvent); + + // then + expect(queryEntries()).to.have.length(12); + + expect(queryEntry('replace-with-cancel-boundary')).to.be.null; + }) + ); + + }); }); @@ -1024,7 +1062,7 @@ describe('features/popup-menu - replace menu provider', function() { beforeEach(bootstrapModeler(diagramXMLReplace, { modules: testModules })); - it('should contain all boundary events for an interrupting boundary event', + it('should contain all boundary events (except for cancel and currently active) for an interrupting boundary event', inject(function(bpmnReplace, elementRegistry) { // given @@ -1035,12 +1073,13 @@ describe('features/popup-menu - replace menu provider', function() { // then expect(queryEntry('replace-with-conditional-intermediate-catch')).to.be.null; - expect(queryEntries()).to.have.length(12); + expect(queryEntry('replace-with-cancel-boundary')).to.be.null; + expect(queryEntries()).to.have.length(11); }) ); - it('should contain all boundary events for a non interrupting boundary event', + it('should contain all boundary events (except for cancel and currently active) for a non interrupting boundary event', inject(function(bpmnReplace, elementRegistry) { // given @@ -1051,7 +1090,8 @@ describe('features/popup-menu - replace menu provider', function() { // then expect(queryEntry('replace-with-non-interrupting-message-intermediate-catch')).to.be.null; - expect(queryEntries()).to.have.length(12); + expect(queryEntry('replace-with-cancel-boundary')).to.be.null; + expect(queryEntries()).to.have.length(11); }) ); @@ -2268,6 +2308,18 @@ describe('features/popup-menu - replace menu provider', function() { // helpers //////////// +function openPopup(element, offset) { + offset = offset || 100; + + getBpmnJS().invoke(function(popupMenu) { + + popupMenu.open(element, 'bpmn-replace', { + x: element.x + offset, y: element.y + offset + }); + + }); +} + function queryEntry(id) { var container = getBpmnJS().get('canvas').getContainer();