2015-03-31 13:02:04 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-04-28 08:52:21 +00:00
|
|
|
var TestHelper = require('../../../../TestHelper');
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
|
2015-04-28 08:52:21 +00:00
|
|
|
var modelingModule = require('../../../../../lib/features/modeling'),
|
|
|
|
coreModule = require('../../../../../lib/core');
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - create participant', function() {
|
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule ];
|
|
|
|
|
|
|
|
|
|
|
|
describe('on process diagram', function() {
|
|
|
|
|
|
|
|
describe('should transform diagram into collaboration', function() {
|
|
|
|
|
2015-04-28 08:52:21 +00:00
|
|
|
var processDiagramXML = require('../../../../fixtures/bpmn/collaboration/process-empty.bpmn');
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('execute', inject(function(modeling, elementFactory, canvas) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var processShape = canvas.getRootElement(),
|
|
|
|
process = processShape.businessObject,
|
|
|
|
participantShape = elementFactory.createParticipantShape(true),
|
|
|
|
participant = participantShape.businessObject,
|
|
|
|
diRoot = process.di.$parent;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.createShape(participantShape, { x: 350, y: 200 }, processShape);
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.processRef).to.eql(process);
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
var collaborationRoot = canvas.getRootElement(),
|
|
|
|
collaboration = collaborationRoot.businessObject,
|
|
|
|
collaborationDi = collaboration.di;
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(collaboration.$instanceOf('bpmn:Collaboration')).to.be.true;
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
// participant / collaboration are wired
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.$parent).to.eql(collaboration);
|
|
|
|
expect(collaboration.participants).to.include(participant);
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
// collaboration is added to root elements
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(collaboration.$parent).to.eql(process.$parent);
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
// di is wired
|
|
|
|
var participantDi = participant.di;
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participantDi.$parent).to.eql(collaborationDi);
|
|
|
|
expect(collaborationDi.$parent).to.eql(diRoot);
|
2015-03-31 13:02:04 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('undo', inject(function(modeling, elementFactory, canvas, commandStack) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var processShape = canvas.getRootElement(),
|
|
|
|
process = processShape.businessObject,
|
|
|
|
processDi = process.di,
|
|
|
|
participantShape = elementFactory.createParticipantShape(true),
|
|
|
|
participant = participantShape.businessObject,
|
|
|
|
oldParticipantProcessRef = participant.processRef,
|
|
|
|
diRoot = process.di.$parent;
|
|
|
|
|
|
|
|
modeling.createShape(participantShape, { x: 350, y: 200 }, processShape);
|
|
|
|
|
|
|
|
var collaborationRoot = canvas.getRootElement(),
|
|
|
|
collaboration = collaborationRoot.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.processRef).to.eql(oldParticipantProcessRef);
|
2015-03-31 13:02:04 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.$parent).to.be.null;
|
|
|
|
expect(collaboration.participants).not.to.include(participant);
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
// collaboration is detached
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(collaboration.$parent).to.be.null;
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
// di is wired
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(processDi.$parent).to.eql(diRoot);
|
2015-03-31 13:02:04 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should wrap existing elements', function() {
|
|
|
|
|
2015-04-28 08:52:21 +00:00
|
|
|
var processDiagramXML = require('../../../../fixtures/bpmn/collaboration/process.bpmn');
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('execute', inject(function(modeling, elementFactory, canvas) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var processShape = canvas.getRootElement(),
|
|
|
|
process = processShape.businessObject,
|
|
|
|
participantShape = elementFactory.createParticipantShape(true),
|
|
|
|
participant = participantShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.createShape(participantShape, { x: 350, y: 200 }, processShape);
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.processRef).to.eql(process);
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
var newRootShape = canvas.getRootElement(),
|
|
|
|
collaboration = newRootShape.businessObject;
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(collaboration.$instanceOf('bpmn:Collaboration')).to.be.true;
|
2015-03-31 13:02:04 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.$parent).to.eql(collaboration);
|
|
|
|
expect(collaboration.participants).to.include(participant);
|
2015-03-31 13:02:04 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-04 12:59:26 +00:00
|
|
|
it('undo', inject(function(modeling, elementFactory, elementRegistry, canvas, commandStack) {
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var processShape = canvas.getRootElement(),
|
|
|
|
participantShape = elementFactory.createParticipantShape(true);
|
|
|
|
|
|
|
|
modeling.createShape(participantShape, { x: 350, y: 200 }, processShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
2015-05-04 12:59:26 +00:00
|
|
|
var startEventElement = elementRegistry.get('StartEvent_1'),
|
|
|
|
startEventDi = startEventElement.businessObject.di,
|
|
|
|
rootElement = canvas.getRootElement(),
|
|
|
|
rootShapeDi = rootElement.businessObject.di;
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participantShape.children.length).to.equal(0);
|
|
|
|
expect(processShape.children.length).to.equal(9);
|
2015-05-04 12:59:26 +00:00
|
|
|
|
|
|
|
// children di is wired
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(startEventDi.$parent).to.eql(rootShapeDi);
|
|
|
|
expect(rootShapeDi.planeElement).to.include(startEventDi);
|
2015-05-04 12:59:26 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should detach DI on update canvas root', inject(function(canvas, elementFactory, commandStack, modeling, elementRegistry) {
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.makeCollaboration();
|
|
|
|
|
|
|
|
var startEventElement = elementRegistry.get('StartEvent_1'),
|
|
|
|
startEventDi = startEventElement.businessObject.di,
|
|
|
|
rootElement = canvas.getRootElement(),
|
|
|
|
rootShapeDi = rootElement.businessObject.di;
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(startEventDi.$parent).to.not.be.ok;
|
|
|
|
expect(rootShapeDi.planeElement).not.to.include(startEventDi);
|
2015-03-31 13:02:04 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should add to collaboration', function() {
|
|
|
|
|
2015-04-28 08:52:21 +00:00
|
|
|
var collaborationDiagramXML = require('../../../../fixtures/bpmn/collaboration/collaboration-participant.bpmn');
|
2015-03-31 13:02:04 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(collaborationDiagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('execute', inject(function(modeling, elementFactory, canvas) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var collaborationRoot = canvas.getRootElement(),
|
|
|
|
collaboration = collaborationRoot.businessObject,
|
|
|
|
participantShape = elementFactory.createParticipantShape(true),
|
|
|
|
participant = participantShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.createShape(participantShape, { x: 350, y: 500 }, collaborationRoot);
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(collaborationRoot.children).to.include(participantShape);
|
2015-03-31 13:02:04 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.$parent).to.eql(collaboration);
|
|
|
|
expect(collaboration.participants).to.include(participant);
|
2015-03-31 13:02:04 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('undo', inject(function(modeling, elementFactory, canvas, commandStack) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var collaborationRoot = canvas.getRootElement(),
|
|
|
|
collaboration = collaborationRoot.businessObject,
|
|
|
|
participantShape = elementFactory.createParticipantShape(true),
|
|
|
|
participant = participantShape.businessObject;
|
|
|
|
|
|
|
|
modeling.createShape(participantShape, { x: 350, y: 500 }, collaborationRoot);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(collaborationRoot.children).not.to.include(participantShape);
|
2015-03-31 13:02:04 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.$parent).to.not.be.ok;
|
|
|
|
expect(collaboration.participants).not.to.include(participant);
|
2015-03-31 13:02:04 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
});
|