2015-12-10 11:48:40 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
var TestHelper = require('../../../TestHelper');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var globalEvent = require('../../../util/MockEvents').createEvent;
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2018-01-24 10:41:21 +00:00
|
|
|
var coreModule = require('lib/core'),
|
|
|
|
modelingModule = require('lib/features/modeling'),
|
|
|
|
replaceMenuProviderModule = require('lib/features/popup-menu'),
|
2016-01-06 09:34:12 +00:00
|
|
|
customRulesModule = require('../../../util/custom-rules');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
var domQuery = require('min-dom/lib/query'),
|
2016-01-07 08:03:20 +00:00
|
|
|
domClasses = require('min-dom/lib/classes'),
|
|
|
|
find = require('lodash/collection/find');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2018-01-24 10:41:21 +00:00
|
|
|
var is = require('lib/util/ModelUtil').is,
|
|
|
|
isExpanded = require('lib/util/DiUtil').isExpanded;
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
function queryEntry(popupMenu, id) {
|
|
|
|
return queryPopup(popupMenu, '[data-id="' + id + '"]');
|
|
|
|
}
|
|
|
|
|
|
|
|
function queryPopup(popupMenu, selector) {
|
|
|
|
return domQuery(selector, popupMenu._current.container);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets all menu entries from the current open popup menu
|
|
|
|
*
|
|
|
|
* @param {PopupMenu} popupMenu
|
|
|
|
*
|
2016-01-20 10:31:01 +00:00
|
|
|
* @return {<Array>}
|
2015-12-10 11:48:40 +00:00
|
|
|
*/
|
|
|
|
function getEntries(popupMenu) {
|
|
|
|
var element = popupMenu._current.element;
|
|
|
|
|
|
|
|
return popupMenu._current.provider.getEntries(element);
|
|
|
|
}
|
|
|
|
|
2016-01-07 12:26:00 +00:00
|
|
|
function triggerAction(entries, id) {
|
|
|
|
var entry = find(entries, { id: id });
|
|
|
|
|
|
|
|
if (!entry) {
|
|
|
|
throw new Error('entry "'+ id +'" not found in replace menu');
|
|
|
|
}
|
|
|
|
|
|
|
|
entry.action();
|
|
|
|
}
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
describe('features/popup-menu - replace menu provider', function() {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
var diagramXMLMarkers = require('../../../fixtures/bpmn/draw/activity-markers-simple.bpmn'),
|
|
|
|
diagramXMLReplace = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2016-01-06 09:34:12 +00:00
|
|
|
var testModules = [
|
|
|
|
coreModule,
|
|
|
|
modelingModule,
|
|
|
|
replaceMenuProviderModule,
|
|
|
|
customRulesModule
|
|
|
|
];
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
var openPopup = function(element, offset) {
|
|
|
|
offset = offset || 100;
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
TestHelper.getBpmnJS().invoke(function(popupMenu) {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
popupMenu.create('bpmn-replace', element);
|
|
|
|
|
|
|
|
popupMenu.open({ x: element.x + offset, y: element.y + offset });
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('toggle', function() {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXMLMarkers, { modules: testModules }));
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
var toggleActive;
|
|
|
|
|
|
|
|
beforeEach(inject(function(popupMenu) {
|
|
|
|
toggleActive = function(entryCls) {
|
|
|
|
return popupMenu._getEntry(entryCls).active;
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('active attribute', function() {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
it('should be true for parallel marker', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('ParallelTask'),
|
|
|
|
loopCharacteristics = task.businessObject.loopCharacteristics;
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
// assume
|
|
|
|
expect(loopCharacteristics.isSequential).to.be.false;
|
|
|
|
expect(loopCharacteristics.isSequential).to.exist;
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
// when
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(is(loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).to.be.true;
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
expect(toggleActive('toggle-parallel-mi')).to.be.true;
|
2015-12-10 11:48:40 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should be true for sequential marker', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('SequentialTask'),
|
|
|
|
loopCharacteristics = task.businessObject.loopCharacteristics;
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
// assume
|
|
|
|
expect(loopCharacteristics.isSequential).to.be.true;
|
|
|
|
expect(is(loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).to.be.true;
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
// when
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
// then
|
2016-01-20 10:31:01 +00:00
|
|
|
expect(toggleActive('toggle-sequential-mi')).to.be.true;
|
2015-12-10 11:48:40 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should be true for loop marker', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('LoopTask'),
|
|
|
|
loopCharacteristics = task.businessObject.loopCharacteristics;
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
// assume
|
|
|
|
expect(loopCharacteristics.isSequential).not.to.exist;
|
|
|
|
expect(is(loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).to.be.false;
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
// when
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
// then
|
2016-01-20 10:31:01 +00:00
|
|
|
expect(toggleActive('toggle-loop')).to.be.true;
|
2015-12-10 11:48:40 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should be true for ad hoc marker', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var AdHocSubProcess = elementRegistry.get('AdHocSubProcess');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(AdHocSubProcess);
|
|
|
|
|
|
|
|
// then
|
2016-01-20 10:31:01 +00:00
|
|
|
expect(toggleActive('toggle-adhoc')).to.be.true;
|
2015-12-10 11:48:40 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('exclusive toggle buttons', function() {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
it('should not toggle non exclusive buttons off', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
var subProcess = elementRegistry.get('AdHocSubProcess');
|
|
|
|
|
|
|
|
openPopup(subProcess);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(subProcess);
|
|
|
|
|
|
|
|
// then
|
|
|
|
var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc');
|
|
|
|
|
|
|
|
expect(domClasses(adHocEntry).has('active')).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('non exclusive toggle buttons', function() {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
it('should not toggle exclusive buttons off',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var subProcess = elementRegistry.get('SubProcess');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// toggle parallel on
|
|
|
|
openPopup(subProcess);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
popupMenu.trigger(globalEvent(parallelEntry, { x: 0, y: 0 }));
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// toggle ad hoc on
|
|
|
|
openPopup(subProcess);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var adHocSubProcess = popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 }));
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(adHocSubProcess);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
|
|
|
adHocEntry = queryEntry(popupMenu, 'toggle-adhoc');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(domClasses(parallelEntry).has('active')).to.be.true;
|
|
|
|
expect(domClasses(adHocEntry).has('active')).to.be.true;
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
|
|
|
describe('parallel toggle button', function() {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
it('should toggle parallel marker off',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('ParallelTask');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(task);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(task);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(task.businessObject.loopCharacteristics).not.to.exist;
|
|
|
|
expect(domClasses(parallelEntry).has('active')).to.be.false;
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should toggle parallel marker on', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(parallelEntry).has('active')).to.be.true;
|
|
|
|
expect(task.businessObject.loopCharacteristics.isSequential).to.be.false;
|
|
|
|
expect(is(task.businessObject.loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should set sequential button inactive', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('SequentialTask');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var sequentialEntry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(sequentialEntry).has('active')).to.be.false;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should set loop button inactive', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('LoopTask');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var loopEntry = queryEntry(popupMenu, 'toggle-loop');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(loopEntry).has('active')).to.be.false;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
|
|
|
describe('sequential toggle button', function() {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
it('should toggle sequential marker off', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('SequentialTask');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var sequentialEntry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.businessObject.loopCharacteristics).not.to.exist;
|
|
|
|
expect(domClasses(sequentialEntry).has('active')).to.be.false;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should toggle sequential marker on', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var sequentialEntry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(sequentialEntry).has('active')).to.be.true;
|
|
|
|
expect(task.businessObject.loopCharacteristics.isSequential).to.be.true;
|
|
|
|
expect(is(task.businessObject.loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should set loop button inactive', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('LoopTask');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var loopEntry = queryEntry(popupMenu, 'toggle-loop');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(loopEntry).has('active')).to.be.false;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should set parallel button inactive', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('ParallelTask');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(parallelEntry).has('active')).to.be.false;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
|
|
|
describe('loop toggle button', function() {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
it('should toggle loop marker off', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('LoopTask');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-loop');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var loopEntry = queryEntry(popupMenu, 'toggle-loop');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(loopEntry).has('active')).to.be.false;
|
|
|
|
expect(is(task.businessObject.loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).not.to.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should toggle loop marker on', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-loop');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var loopEntry = queryEntry(popupMenu, 'toggle-loop');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(loopEntry).has('active')).to.be.true;
|
|
|
|
expect(is(task.businessObject.loopCharacteristics, 'bpmn:StandardLoopCharacteristics')).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should set sequential button inactive', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('SequentialTask');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-loop');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var sequentialEntry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(sequentialEntry).has('active')).to.be.false;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should set parallel button inactive', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('ParallelTask');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'toggle-loop');
|
|
|
|
|
|
|
|
// when
|
|
|
|
popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(domClasses(parallelEntry).has('active')).to.be.false;
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('replacing', function() {
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXMLMarkers, { modules: testModules }));
|
|
|
|
|
|
|
|
it('should retain the loop characteristics', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('SequentialTask');
|
|
|
|
|
|
|
|
openPopup(task);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'replace-with-send-task');
|
|
|
|
|
|
|
|
// when
|
|
|
|
// replacing the task with a send task
|
|
|
|
var sendTask = popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sendTask.businessObject.loopCharacteristics).to.exist;
|
|
|
|
expect(sendTask.businessObject.loopCharacteristics.isSequential).to.be.true;
|
|
|
|
expect(is(sendTask.businessObject.loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should retain the loop characteristics for call activites',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('SequentialTask');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(task);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entry = queryEntry(popupMenu, 'replace-with-call-activity');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
// replacing the task with a call activity
|
|
|
|
var callActivity = popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(callActivity.businessObject.loopCharacteristics).to.exist;
|
|
|
|
expect(callActivity.businessObject.loopCharacteristics.isSequential).to.be.true;
|
|
|
|
expect(is(callActivity.businessObject.loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).to.be.true;
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should retain expanded status for sub processes',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var subProcess = elementRegistry.get('SubProcess');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(subProcess);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entry = queryEntry(popupMenu, 'replace-with-transaction');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
// replacing the expanded sub process with a transaction
|
|
|
|
var transaction = popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(isExpanded(transaction)).to.equal(isExpanded(subProcess));
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
2016-01-20 10:22:16 +00:00
|
|
|
it('should replace sub processes -> event sub process',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var subProcess = elementRegistry.get('SubProcess');
|
2016-01-20 10:22:16 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(subProcess);
|
2016-01-20 10:22:16 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entry = queryEntry(popupMenu, 'replace-with-event-subprocess');
|
2016-01-20 10:22:16 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
// replacing the expanded sub process with a eventSubProcess
|
|
|
|
var eventSubProcess = popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
2016-01-20 10:22:16 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(eventSubProcess.businessObject.triggeredByEvent).to.be.true;
|
|
|
|
})
|
|
|
|
);
|
2016-01-20 10:22:16 +00:00
|
|
|
|
|
|
|
|
2016-06-14 08:24:12 +00:00
|
|
|
it('should replace event sub processes -> sub process',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var eventSubProcess = elementRegistry.get('EventSubProcess');
|
|
|
|
|
|
|
|
openPopup(eventSubProcess);
|
|
|
|
|
|
|
|
var entry = queryEntry(popupMenu, 'replace-with-subprocess');
|
|
|
|
|
|
|
|
// when
|
|
|
|
// replacing the expanded sub process with a eventSubProcess
|
|
|
|
var subProcess = popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(subProcess.businessObject.triggeredByEvent).to.be.false;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
it('should retain the loop characteristics and the expanded status for transactions',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var transaction = elementRegistry.get('Transaction');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(transaction);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entry = queryEntry(popupMenu, 'replace-with-subprocess');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
// replacing the transaction with an expanded sub process
|
|
|
|
var subProcess = popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(isExpanded(subProcess)).to.equal(isExpanded(transaction));
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should not retain the loop characteristics morphing to an event sub process',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var transaction = elementRegistry.get('Transaction');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
modeling.updateProperties(transaction, { loopCharacteristics: { isparallel: true } });
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(transaction);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entry = queryEntry(popupMenu, 'replace-with-event-subprocess');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
// replacing the transaction with an event sub process
|
|
|
|
var subProcess = popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(isExpanded(subProcess)).to.equal(isExpanded(transaction));
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should retain the expanded property morphing to an event sub processes',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var transaction = elementRegistry.get('Transaction');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(transaction);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entry = queryEntry(popupMenu, 'replace-with-event-subprocess');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
// replacing the transaction with an expanded sub process
|
|
|
|
var eventSubProcess = popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(isExpanded(eventSubProcess)).to.equal(isExpanded(transaction));
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('replace menu', function() {
|
|
|
|
|
|
|
|
|
|
|
|
describe('events', function() {
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXMLReplace, { modules: testModules }));
|
|
|
|
|
|
|
|
it('should contain all except the current one',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(startEvent);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-none-start')).to.be.null;
|
|
|
|
expect(getEntries(popupMenu)).to.have.length(6);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should contain all start events inside event sub process except the current one',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_3');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(startEvent);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-non-interrupting-message-start')).to.be.null;
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-message-start')).to.exist;
|
2016-01-20 10:31:01 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(getEntries(popupMenu)).to.have.length(11);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should contain all non interrupting start events inside event sub process except the current one',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_3');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var newElement = bpmnReplace.replaceElement(startEvent, {
|
|
|
|
type: 'bpmn:StartEvent',
|
|
|
|
eventDefinitionType: 'bpmn:ConditionalEventDefinition',
|
|
|
|
isInterrupting: false
|
|
|
|
});
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(newElement);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-conditional-start')).to.exist;
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-non-interrupting-conditional-start')).to.be.null;
|
2016-01-20 10:31:01 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(getEntries(popupMenu)).to.have.length(11);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should contain all intermediate events except the current one',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var intermediateEvent = elementRegistry.get('IntermediateThrowEvent_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(intermediateEvent);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-none-intermediate-throw')).to.be.null;
|
2016-01-20 10:31:01 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(getEntries(popupMenu)).to.have.length(12);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should contain all end events except the current one',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var endEvent = elementRegistry.get('EndEvent_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(endEvent);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-none-end')).to.be.null;
|
2016-01-20 10:31:01 +00:00
|
|
|
|
2016-08-08 11:51:27 +00:00
|
|
|
expect(getEntries(popupMenu)).to.have.length(8);
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('cancel events', 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, bpmnReplace, popupMenu, replaceMenuProvider) {
|
2016-01-20 10:31:01 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var endEvent = elementRegistry.get('EndEvent_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(endEvent);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(getEntries(popupMenu)).to.have.length(9);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should NOT contain cancel event replace option',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, popupMenu, replaceMenuProvider) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var endEvent = elementRegistry.get('EndEvent_2');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(endEvent);
|
|
|
|
|
|
|
|
// then
|
2016-08-08 11:51:27 +00:00
|
|
|
expect(getEntries(popupMenu)).to.have.length(8);
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should contain cancel event replace option (boundary events)',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, popupMenu) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(boundaryEvent);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(getEntries(popupMenu)).to.have.length(13);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should NOT contain cancel event replace option (boundary events)',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, popupMenu) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_2');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(boundaryEvent, 40);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(getEntries(popupMenu)).to.have.length(13);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('boundary events', function() {
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXMLReplace, { modules: testModules }));
|
|
|
|
|
|
|
|
it('should contain all boundary events for an interrupting boundary event',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(boundaryEvent, 40);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-conditional-intermediate-catch')).to.be.null;
|
|
|
|
expect(getEntries(popupMenu)).to.have.length(12);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should contain all boundary events for a non interrupting boundary event',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_2');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(boundaryEvent, 40);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-non-interrupting-message-intermediate-catch')).to.be.null;
|
|
|
|
expect(getEntries(popupMenu)).to.have.length(12);
|
|
|
|
})
|
|
|
|
);
|
2016-01-20 10:31:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should contain compensation boundary event',
|
|
|
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1');
|
2016-01-20 10:31:01 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(boundaryEvent, 40);
|
2016-01-20 10:31:01 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(queryEntry(popupMenu, 'replace-with-compensation-boundary')).to.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('default flows', function() {
|
|
|
|
|
2016-01-08 11:57:38 +00:00
|
|
|
var diagramXML = require('./ReplaceMenuProvider.defaultFlows.bpmn');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-01-07 08:03:20 +00:00
|
|
|
it('should show default replace option [gateway]', inject(function(elementRegistry, popupMenu) {
|
2015-12-10 11:48:40 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
// then
|
2016-01-20 10:31:01 +00:00
|
|
|
expect(getEntries(popupMenu)).to.have.length(1);
|
2015-12-10 11:48:40 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-01-07 08:03:20 +00:00
|
|
|
it('should show Default replace option [task]', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_15f5knn');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
// then
|
2016-01-20 10:31:01 +00:00
|
|
|
expect(getEntries(popupMenu)).to.have.length(2);
|
2016-01-07 08:03:20 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
it('should NOT show default replace option', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_4');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
// then
|
2016-01-20 10:31:01 +00:00
|
|
|
expect(getEntries(popupMenu)).to.have.length(0);
|
2015-12-10 11:48:40 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('default flows from inclusive gateways', function() {
|
|
|
|
|
2016-01-08 11:57:38 +00:00
|
|
|
var diagramXML = require('./ReplaceMenuProvider.defaultFlowsFromInclusiveGateways.bpmn');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-30 12:43:29 +00:00
|
|
|
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('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;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
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() {
|
|
|
|
|
2016-01-08 11:57:38 +00:00
|
|
|
var diagramXML = require('./ReplaceMenuProvider.conditionalFlows.bpmn');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
it('should show ConditionalFlow replace option', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
var conditionalFlowEntry = queryEntry(popupMenu, 'replace-with-conditional-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(conditionalFlowEntry).to.exist;
|
2016-01-07 12:26:00 +00:00
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
expect(getEntries(popupMenu)).to.have.length(2);
|
2015-12-10 11:48:40 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should NOT show ConditionalFlow replace option', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
// when
|
2015-12-10 11:48:40 +00:00
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
// then
|
|
|
|
expect(getEntries(popupMenu)).to.have.length(0);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('compensate activities', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./ReplaceMenuProvider.compensation-activity.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
2016-08-16 13:42:46 +00:00
|
|
|
it('options should include subProcesses and callActivity', inject(function(elementRegistry, popupMenu) {
|
2016-01-20 10:31:01 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var taskElement = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(taskElement);
|
|
|
|
|
|
|
|
var callActivityEntry = queryEntry(popupMenu, 'replace-with-call-activity'),
|
|
|
|
subProcessEntry = queryEntry(popupMenu, 'replace-with-collapsed-subprocess');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
// then
|
2016-08-16 13:42:46 +00:00
|
|
|
expect(callActivityEntry).to.exist;
|
2016-01-26 15:35:08 +00:00
|
|
|
expect(subProcessEntry).to.exist;
|
2015-12-10 11:48:40 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-06-16 11:57:32 +00:00
|
|
|
describe('collapsed subprocesses', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./ReplaceMenuProvider.collapsedSubProcess.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('options do not include collapsed subprocesses itself', inject(function(elementRegistry, popupMenu) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var collapsedSubProcess = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(collapsedSubProcess);
|
|
|
|
|
|
|
|
var collapsedSubProcessEntry = queryEntry(popupMenu, 'replace-with-collapsed-subprocess');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(collapsedSubProcessEntry).to.not.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('integration', function() {
|
|
|
|
|
|
|
|
|
|
|
|
describe('default flows', function() {
|
|
|
|
|
2016-01-08 11:57:38 +00:00
|
|
|
var diagramXML = require('./ReplaceMenuProvider.defaultFlows.bpmn');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
2016-01-07 08:03:20 +00:00
|
|
|
it('should replace SequenceFlow with DefaultFlow [gateway]', inject(function(elementRegistry, popupMenu) {
|
2015-12-10 11:48:40 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3');
|
|
|
|
|
|
|
|
//when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
2016-01-07 12:26:00 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gateway.businessObject.default).to.equal(sequenceFlow.businessObject);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-01-07 08:03:20 +00:00
|
|
|
it('should replace SequenceFlow with DefaultFlow [task]', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_15f5knn');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
2016-01-07 12:26:00 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2016-01-07 08:03:20 +00:00
|
|
|
|
|
|
|
var task = elementRegistry.get('Task_1ei94kl');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.businessObject.default).to.equal(sequenceFlow.businessObject);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-01-07 10:54:10 +00:00
|
|
|
it('should morph DefaultFlow into a SequenceFlow [task]', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_15f5knn'),
|
|
|
|
entries;
|
|
|
|
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
entries = getEntries(popupMenu);
|
|
|
|
|
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
entries = getEntries(popupMenu);
|
|
|
|
|
|
|
|
triggerAction(entries, 'replace-with-sequence-flow');
|
|
|
|
|
|
|
|
var task = elementRegistry.get('Task_1ei94kl');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.businessObject.default).to.not.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should morph DefaultFlow into a SequenceFlow [task] -> undo',
|
|
|
|
inject(function(elementRegistry, popupMenu, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_15f5knn'),
|
|
|
|
entries;
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(sequenceFlow);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
entries = getEntries(popupMenu);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
entries = getEntries(popupMenu);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-sequence-flow');
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var task = elementRegistry.get('Task_1ei94kl');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.businessObject.default).to.equal(sequenceFlow.businessObject);
|
|
|
|
})
|
|
|
|
);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should morph DefaultFlow into a ConditionalFlow [task]', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_15f5knn'),
|
|
|
|
task = elementRegistry.get('Task_1ei94kl'),
|
|
|
|
entries;
|
|
|
|
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
entries = getEntries(popupMenu);
|
|
|
|
|
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
entries = getEntries(popupMenu);
|
|
|
|
|
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.businessObject.default).to.not.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should morph DefaultFlow into a ConditionalFlow [task] -> undo',
|
|
|
|
inject(function(elementRegistry, popupMenu, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_15f5knn'),
|
|
|
|
task = elementRegistry.get('Task_1ei94kl'),
|
|
|
|
entries;
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(sequenceFlow);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
entries = getEntries(popupMenu);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
entries = getEntries(popupMenu);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.businessObject.default).to.equal(sequenceFlow.businessObject);
|
|
|
|
})
|
|
|
|
);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
|
|
|
|
2016-01-07 08:03:20 +00:00
|
|
|
it('should replace SequenceFlow with DefaultFlow [gateway] -> undo',
|
2015-12-10 11:48:40 +00:00
|
|
|
inject(function(elementRegistry, popupMenu, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
gateway = elementRegistry.get('ExclusiveGateway_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gateway.businessObject.default).to.not.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
2016-01-07 08:03:20 +00:00
|
|
|
it('should replace SequenceFlow with DefaultFlow [task] -> undo',
|
|
|
|
inject(function(elementRegistry, popupMenu, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_15f5knn');
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var task = elementRegistry.get('Task_1ei94kl');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.businessObject.default).to.not.exist;
|
|
|
|
})
|
|
|
|
);
|
2016-01-07 08:03:20 +00:00
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
it('should only have one DefaultFlow', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
sequenceFlow3 = elementRegistry.get('SequenceFlow_3');
|
|
|
|
|
|
|
|
var entries;
|
|
|
|
|
|
|
|
// when
|
|
|
|
// trigger morphing sequenceFlow3 to default flow
|
|
|
|
openPopup(sequenceFlow3);
|
|
|
|
|
|
|
|
entries = getEntries(popupMenu);
|
|
|
|
|
2016-01-07 12:26:00 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
// trigger morphing sequenceFlow to default flow
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
entries = getEntries(popupMenu);
|
|
|
|
|
2016-01-07 12:26:00 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gateway.businessObject.default).to.equal(sequenceFlow.businessObject);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should replace DefaultFlow with SequenceFlow when changing source',
|
|
|
|
inject(function(elementRegistry, popupMenu, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
task = elementRegistry.get('Task_2');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(sequenceFlow);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.reconnectStart(sequenceFlow, task, [
|
|
|
|
{ x: 686, y: 267, original: { x: 686, y: 307 } },
|
|
|
|
{ x: 686, y: 207, original: { x: 686, y: 187 } }
|
|
|
|
]);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gateway.businessObject.default).to.not.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace DefaultFlow with SequenceFlow when changing source -> undo',
|
|
|
|
inject(function(elementRegistry, popupMenu, modeling, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
task = elementRegistry.get('Task_2');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(sequenceFlow);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.reconnectStart(sequenceFlow, task, [
|
|
|
|
{ x: 686, y: 267, original: { x: 686, y: 307 } },
|
|
|
|
{ x: 686, y: 207, original: { x: 686, y: 187 } }
|
|
|
|
]);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gateway.businessObject.default).equal(sequenceFlow.businessObject);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
2016-05-06 13:52:20 +00:00
|
|
|
[
|
|
|
|
'bpmn:StartEvent'
|
|
|
|
].forEach(function(type) {
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2016-05-06 13:52:20 +00:00
|
|
|
it('should replace DefaultFlow with SequenceFlow when changing target to ' + type,
|
|
|
|
inject(function(elementRegistry, elementFactory, canvas, popupMenu, modeling) {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
root = canvas.getRootElement();
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var intermediateEvent = elementFactory.createShape({ type: type });
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
modeling.createShape(intermediateEvent, { x: 686, y: 50 }, root);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(sequenceFlow);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
|
|
|
{ x: 686, y: 267, original: { x: 686, y: 307 } },
|
|
|
|
{ x: 686, y: 50, original: { x: 686, y: 75 } }
|
|
|
|
]);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gateway.businessObject.default).to.not.exist;
|
|
|
|
})
|
|
|
|
);
|
2016-05-06 13:52:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
'bpmn:Activity',
|
|
|
|
'bpmn:EndEvent',
|
|
|
|
'bpmn:IntermediateThrowEvent'
|
|
|
|
].forEach(function(type) {
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2016-05-06 13:52:20 +00:00
|
|
|
it('should keep DefaultFlow when changing target to ' + type,
|
|
|
|
inject(function(elementRegistry, elementFactory, canvas, popupMenu, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
root = canvas.getRootElement();
|
2016-05-06 13:52:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var intermediateEvent = elementFactory.createShape({ type: type });
|
2016-05-06 13:52:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
modeling.createShape(intermediateEvent, { x: 686, y: 50 }, root);
|
2016-05-06 13:52:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(sequenceFlow);
|
2016-05-06 13:52:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2016-05-06 13:52:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2016-05-06 13:52:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
|
|
|
{ x: 686, y: 267, original: { x: 686, y: 307 } },
|
|
|
|
{ x: 686, y: 50, original: { x: 686, y: 75 } }
|
|
|
|
]);
|
2016-05-06 13:52:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gateway.businessObject.default).to.exist;
|
|
|
|
})
|
|
|
|
);
|
2016-05-06 13:52:20 +00:00
|
|
|
});
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace DefaultFlow with SequenceFlow when changing target -> undo',
|
|
|
|
inject(function(elementRegistry, elementFactory, canvas, popupMenu, modeling, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
rootElement = canvas.getRootElement();
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var intermediateEvent = elementFactory.createShape({ type: 'bpmn:StartEvent' });
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
modeling.createShape(intermediateEvent, { x: 686, y: 50 }, rootElement);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(sequenceFlow);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
|
|
|
{ x: 686, y: 267, original: { x: 686, y: 307 } },
|
|
|
|
{ x: 686, y: 50, original: { x: 686, y: 75 } }
|
|
|
|
]);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gateway.businessObject.default).equal(sequenceFlow.businessObject);
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should keep DefaultFlow when morphing Gateway', inject(function(elementRegistry, popupMenu, bpmnReplace) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
exclusiveGateway = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
2016-01-07 12:26:00 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var inclusiveGateway = bpmnReplace.replaceElement(exclusiveGateway, { type: 'bpmn:InclusiveGateway' });
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(inclusiveGateway.businessObject.default).to.equal(sequenceFlow.businessObject);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-01-07 08:03:20 +00:00
|
|
|
it('should keep DefaultFlow when morphing Task', inject(function(elementRegistry, bpmnReplace, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_15f5knn'),
|
|
|
|
task = elementRegistry.get('Task_1ei94kl');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
|
|
|
// trigger DefaultFlow replacement
|
|
|
|
var replaceDefaultFlow = find(entries, { id: 'replace-with-default-flow' });
|
|
|
|
|
|
|
|
replaceDefaultFlow.action();
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var sendTask = bpmnReplace.replaceElement(task, { type: 'bpmn:SendTask' });
|
2016-01-07 08:03:20 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sendTask.businessObject.default).to.equal(sequenceFlow.businessObject);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
it('should keep DefaultFlow when morphing Gateway -> undo',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, popupMenu, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
exclusiveGateway = elementRegistry.get('ExclusiveGateway_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
bpmnReplace.replaceElement(exclusiveGateway, { type: 'bpmn:InclusiveGateway' });
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(exclusiveGateway.businessObject.default).to.equal(sequenceFlow.businessObject);
|
|
|
|
})
|
|
|
|
);
|
2016-01-07 08:03:20 +00:00
|
|
|
|
|
|
|
|
2016-01-07 10:54:10 +00:00
|
|
|
it('should remove any conditionExpression when morphing to DefaultFlow',
|
|
|
|
inject(function(elementRegistry, modeling, popupMenu, moddle) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
exclusiveGateway = elementRegistry.get('ExclusiveGateway_1');
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var conditionExpression = moddle.create('bpmn:FormalExpression', { body: '' });
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
modeling.updateProperties(sequenceFlow, { conditionExpression: conditionExpression });
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// trigger DefaultFlow replacement
|
|
|
|
triggerAction(entries, 'replace-with-default-flow');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(exclusiveGateway.businessObject.default).to.equal(sequenceFlow.businessObject);
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression).to.not.exist;
|
|
|
|
})
|
|
|
|
);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should remove any conditionExpression when morphing to DefaultFlow -> undo',
|
|
|
|
inject(function(elementRegistry, modeling, popupMenu, moddle, commandStack) {
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
exclusiveGateway = elementRegistry.get('ExclusiveGateway_1');
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var conditionExpression = moddle.create('bpmn:FormalExpression', { body: '' });
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
modeling.updateProperties(sequenceFlow, { conditionExpression: conditionExpression });
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
2016-01-07 10:54:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// trigger DefaultFlow replacement
|
|
|
|
entries[0].action();
|
2016-01-07 08:03:20 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(exclusiveGateway.businessObject.default).to.not.exist;
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression).to.equal(conditionExpression);
|
|
|
|
})
|
|
|
|
);
|
2016-01-07 12:26:00 +00:00
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('conditional flows', function() {
|
|
|
|
|
2016-01-08 11:57:38 +00:00
|
|
|
var diagramXML = require('./ReplaceMenuProvider.conditionalFlows.bpmn');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should morph into a ConditionalFlow', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
2016-01-07 12:26:00 +00:00
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression.$type).to.equal('bpmn:FormalExpression');
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should morph into a ConditionalFlow -> undo', inject(function(elementRegistry, popupMenu, commandStack) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
2016-01-07 12:26:00 +00:00
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression).to.not.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should morph back into a SequenceFlow', inject(function(elementRegistry, popupMenu) {
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
|
|
|
// trigger ConditionalFlow replacement
|
2016-01-07 12:26:00 +00:00
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-01-07 12:26:00 +00:00
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
// replace with SequenceFlow
|
2016-01-07 12:26:00 +00:00
|
|
|
triggerAction(entries, 'replace-with-sequence-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression).to.not.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should replace ConditionalFlow with SequenceFlow when changing source',
|
|
|
|
inject(function(elementRegistry, popupMenu, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
startEvent = elementRegistry.get('StartEvent_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.reconnectStart(sequenceFlow, startEvent, [
|
|
|
|
{ x: 196, y: 197, original: { x: 178, y: 197 } },
|
|
|
|
{ x: 497, y: 278, original: { x: 547, y: 278 } }
|
|
|
|
]);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression).to.not.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace ConditionalFlow with SequenceFlow when changing source -> undo',
|
|
|
|
inject(function(elementRegistry, popupMenu, modeling, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
startEvent = elementRegistry.get('StartEvent_1');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(sequenceFlow);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.reconnectStart(sequenceFlow, startEvent, [
|
|
|
|
{ x: 196, y: 197, original: { x: 178, y: 197 } },
|
|
|
|
{ x: 497, y: 278, original: { x: 547, y: 278 } }
|
|
|
|
]);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression.$type).to.equal('bpmn:FormalExpression');
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
|
2016-05-06 13:52:20 +00:00
|
|
|
[
|
|
|
|
'bpmn:StartEvent'
|
|
|
|
].forEach(function(type) {
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2016-05-06 13:52:20 +00:00
|
|
|
it('should replace ConditionalFlow with SequenceFlow when changing target to ' + type,
|
|
|
|
inject(function(elementRegistry, elementFactory, canvas, popupMenu, modeling) {
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
root = canvas.getRootElement(),
|
|
|
|
intermediateEvent = elementFactory.createShape({ type: type });
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
modeling.createShape(intermediateEvent, { x: 497, y: 197 }, root);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
openPopup(sequenceFlow);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
|
|
|
{ x: 389, y: 197, original: { x: 389, y: 197 } },
|
|
|
|
{ x: 497, y: 197, original: { x: 497, y: 197 } }
|
|
|
|
]);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression).to.not.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-05-06 13:52:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
'bpmn:Activity',
|
|
|
|
'bpmn:EndEvent',
|
|
|
|
'bpmn:IntermediateThrowEvent'
|
|
|
|
].forEach(function(type) {
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2016-05-06 13:52:20 +00:00
|
|
|
it('should keep ConditionalFlow when changing target to ' + type,
|
|
|
|
inject(function(elementRegistry, elementFactory, canvas, popupMenu, modeling) {
|
2016-06-07 06:46:45 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
root = canvas.getRootElement(),
|
|
|
|
intermediateEvent = elementFactory.createShape({ type: type });
|
|
|
|
|
|
|
|
modeling.createShape(intermediateEvent, { x: 497, y: 197 }, root);
|
|
|
|
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
|
|
|
{ x: 389, y: 197, original: { x: 389, y: 197 } },
|
|
|
|
{ x: 497, y: 197, original: { x: 497, y: 197 } }
|
|
|
|
]);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression).to.exist;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should replace ConditionalFlow with SequenceFlow when changing target -> undo',
|
|
|
|
inject(function(elementRegistry, elementFactory, canvas, popupMenu, modeling, commandStack) {
|
|
|
|
|
2016-05-06 13:52:20 +00:00
|
|
|
// given
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
root = canvas.getRootElement(),
|
2016-06-07 06:46:45 +00:00
|
|
|
intermediateEvent = elementFactory.createShape({ type: 'bpmn:StartEvent' });
|
2016-05-06 13:52:20 +00:00
|
|
|
|
|
|
|
modeling.createShape(intermediateEvent, { x: 497, y: 197 }, root);
|
|
|
|
|
|
|
|
openPopup(sequenceFlow);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// trigger ConditionalFlow replacement
|
2016-05-06 13:52:20 +00:00
|
|
|
triggerAction(entries, 'replace-with-conditional-flow');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
|
|
|
{ x: 389, y: 197, original: { x: 389, y: 197 } },
|
|
|
|
{ x: 497, y: 197, original: { x: 497, y: 197 } }
|
|
|
|
]);
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
2015-12-10 11:48:40 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.conditionExpression.$type).to.equal('bpmn:FormalExpression');
|
|
|
|
})
|
|
|
|
);
|
2015-12-10 11:48:40 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-01-06 09:34:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('rules', function() {
|
2016-01-06 09:34:12 +00:00
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/basic.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules.concat([ customRulesModule ])
|
|
|
|
}));
|
|
|
|
|
2016-01-06 09:34:12 +00:00
|
|
|
|
|
|
|
it('should get entries by default', inject(function(elementRegistry, popupMenu) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(startEvent);
|
|
|
|
|
|
|
|
var entries = getEntries(popupMenu);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(entries).to.have.length.above(0);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should get entries when custom rule returns true',
|
|
|
|
inject(function(elementRegistry, popupMenu, customRules) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
2016-01-06 09:34:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
customRules.addRule('shape.replace', function() {
|
|
|
|
return true;
|
|
|
|
});
|
2016-01-06 09:34:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
//when
|
|
|
|
openPopup(startEvent);
|
2016-01-06 09:34:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2016-01-06 09:34:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(entries).to.have.length.above(0);
|
|
|
|
})
|
|
|
|
);
|
2016-01-06 09:34:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should get no entries when custom rule returns false',
|
|
|
|
inject(function(elementRegistry, popupMenu, customRules) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
2016-01-06 09:34:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
customRules.addRule('shape.replace', function() {
|
|
|
|
return false;
|
|
|
|
});
|
2016-01-06 09:34:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
openPopup(startEvent);
|
2016-01-06 09:34:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var entries = getEntries(popupMenu);
|
2016-01-06 09:34:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(entries).to.have.length(0);
|
|
|
|
})
|
|
|
|
);
|
2016-01-06 09:34:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should provide element to custom rules', inject(function(elementRegistry, popupMenu, customRules) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
|
|
|
var actual;
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
customRules.addRule('shape.replace', function(context) {
|
2016-01-06 09:34:12 +00:00
|
|
|
actual = context.element;
|
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(startEvent);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(actual).to.equal(startEvent);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should evaluate rule once', inject(function(elementRegistry, popupMenu, customRules) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var callCount = 0;
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
customRules.addRule('shape.replace', function() {
|
2016-01-06 09:34:12 +00:00
|
|
|
callCount++;
|
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
|
|
|
openPopup(startEvent);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(callCount).to.equal(1);
|
|
|
|
}));
|
2016-01-06 15:36:49 +00:00
|
|
|
|
2016-01-06 09:34:12 +00:00
|
|
|
});
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
});
|