2015-07-13 08:37:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
require('../../../TestHelper');
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
|
2018-01-24 10:41:21 +00:00
|
|
|
var modelingModule = require('lib/features/modeling'),
|
|
|
|
coreModule = require('lib/core');
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
|
2015-08-13 16:05:54 +00:00
|
|
|
describe('features/modeling - update attachment', function() {
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/boundary-events.bpmn');
|
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule ];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
var subProcessElement, subProcess, task, boundaryEventElement, boundaryEvent;
|
|
|
|
|
|
|
|
beforeEach(inject(function(elementFactory, elementRegistry, canvas, modeling) {
|
|
|
|
task = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
subProcessElement = elementRegistry.get('SubProcess_1');
|
|
|
|
|
|
|
|
subProcess = subProcessElement.businessObject;
|
|
|
|
|
|
|
|
boundaryEventElement = elementFactory.createShape({
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
host: task,
|
|
|
|
x: 513, y: 254
|
|
|
|
});
|
|
|
|
|
|
|
|
boundaryEvent = boundaryEventElement.businessObject;
|
|
|
|
|
|
|
|
canvas.addShape(boundaryEventElement, subProcessElement);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-08-13 16:05:54 +00:00
|
|
|
describe('should reattach BoundaryEvent', function() {
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2015-08-13 16:05:54 +00:00
|
|
|
it('execute', inject(function(modeling, elementRegistry) {
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
// when
|
2015-08-13 16:05:54 +00:00
|
|
|
modeling.updateAttachment(boundaryEventElement, subProcessElement);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(boundaryEvent.attachedToRef).to.equal(subProcess);
|
|
|
|
|
|
|
|
expect(boundaryEvent.cancelActivity).to.equal(true);
|
|
|
|
|
|
|
|
expect(subProcessElement.attachers).to.include(boundaryEventElement);
|
|
|
|
expect(task.attachers).not.to.include(boundaryEventElement);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-08-13 16:05:54 +00:00
|
|
|
it('undo', inject(function(elementRegistry, commandStack, modeling) {
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
// given
|
2015-08-13 16:05:54 +00:00
|
|
|
modeling.updateAttachment(boundaryEventElement, subProcessElement);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(boundaryEvent.attachedToRef).to.equal(task.businessObject);
|
|
|
|
expect(boundaryEvent.cancelActivity).to.equal(true);
|
|
|
|
|
|
|
|
expect(subProcessElement.attachers).not.to.include(boundaryEventElement);
|
|
|
|
expect(task.attachers).to.include(boundaryEventElement);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-08-13 16:05:54 +00:00
|
|
|
it('redo', inject(function(elementRegistry, commandStack, modeling) {
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
// given
|
2015-08-13 16:05:54 +00:00
|
|
|
modeling.updateAttachment(boundaryEventElement, subProcessElement);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(boundaryEvent.attachedToRef).to.equal(subProcess);
|
|
|
|
expect(boundaryEvent.cancelActivity).to.equal(true);
|
|
|
|
|
|
|
|
expect(subProcessElement.attachers).to.include(boundaryEventElement);
|
|
|
|
expect(task.attachers).not.to.include(boundaryEventElement);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|