diff --git a/lib/features/context-pads/ContextPads.js b/lib/features/context-pads/ContextPads.js index 145b62d6..3aafc44b 100644 --- a/lib/features/context-pads/ContextPads.js +++ b/lib/features/context-pads/ContextPads.js @@ -50,9 +50,8 @@ export default function ContextPads( this.registerHandler('bpmn:Activity', PauseHandler); - this.registerHandler('bpmn:StartEvent', TriggerHandler); - this.registerHandler('bpmn:IntermediateCatchEvent', TriggerHandler); - this.registerHandler('bpmn:BoundaryEvent', TriggerHandler); + this.registerHandler('bpmn:Event', TriggerHandler); + this.registerHandler('bpmn:Gateway', TriggerHandler); this.registerHandler('bpmn:Activity', TriggerHandler); eventBus.on(TOGGLE_MODE_EVENT, LOW_PRIORITY, context => { diff --git a/lib/features/context-pads/handler/TriggerHandler.js b/lib/features/context-pads/handler/TriggerHandler.js index 2ddbf40e..e4cfe1a9 100644 --- a/lib/features/context-pads/handler/TriggerHandler.js +++ b/lib/features/context-pads/handler/TriggerHandler.js @@ -20,9 +20,15 @@ TriggerHandler.prototype.createContextPads = function(element) { TriggerHandler.prototype.createTriggerContextPad = function(element) { const contexts = () => { - return this._findSubscriptions({ + const subscriptions = this._findSubscriptions({ element }); + + const sortedSubscriptions = subscriptions.slice().sort((a, b) => { + return a.event.type === 'none' ? 1 : -1; + }); + + return sortedSubscriptions; }; const html = ` diff --git a/test/spec/SimulationSpec.js b/test/spec/SimulationSpec.js index 4eebd663..55cc940e 100644 --- a/test/spec/SimulationSpec.js +++ b/test/spec/SimulationSpec.js @@ -1485,6 +1485,94 @@ describe('simulation', function() { }); }); + + describe('process', function() { + + describe('implicit-start', function() { + + const diagram = require('./implicit-start.bpmn'); + + beforeEach(bootstrapModeler(diagram, { + additionalModules: [ + ModelerModule, + TestModule + ] + })); + + beforeEach(inject(function(simulationSupport, simulationTrace) { + simulationSupport.toggleSimulation(true); + + simulationTrace.start(); + })); + + + it('should trigger typed event', async function() { + + // when + triggerElement('MESSAGE_START'); + + // then + expectHistory([ + 'GATEWAY', + 'TASK', + 'END', + 'ESCALATION_THROW', + 'MESSAGE_START' + ]); + }); + + + it('should trigger none event independently', async function() { + + // when + triggerElement('NONE_START'); + + // then + expectHistory([ + 'GATEWAY', + 'TASK', + 'END', + 'ESCALATION_THROW', + 'NONE_START' + ]); + }); + + }); + + + describe('implicit-start-no-event', function() { + + const diagram = require('./implicit-start-no-event.bpmn'); + + beforeEach(bootstrapModeler(diagram, { + additionalModules: [ + ModelerModule, + TestModule + ] + })); + + beforeEach(inject(function(simulationSupport, simulationTrace) { + simulationSupport.toggleSimulation(true); + + simulationTrace.start(); + })); + + + it('should trigger task', async function() { + + // when + triggerElement('TASK'); + + // then + expectHistory([ + 'TASK', + 'OTHER_TASK' + ]); + }); + }); + + }); + }); diff --git a/test/spec/implicit-start-no-event.bpmn b/test/spec/implicit-start-no-event.bpmn new file mode 100644 index 00000000..7acf13ed --- /dev/null +++ b/test/spec/implicit-start-no-event.bpmn @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/implicit-start.bpmn b/test/spec/implicit-start.bpmn new file mode 100644 index 00000000..3ba59d5a --- /dev/null +++ b/test/spec/implicit-start.bpmn @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +