2014-12-02 07:36:15 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
require('../../../../TestHelper');
|
2014-12-02 07:36:15 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
|
2018-03-14 20:43:53 +00:00
|
|
|
var find = require('min-dash').find;
|
2014-12-02 07:36:15 +00:00
|
|
|
|
2018-01-24 10:41:21 +00:00
|
|
|
var modelingModule = require('lib/features/modeling'),
|
|
|
|
coreModule = require('lib/core');
|
2014-12-02 07:36:15 +00:00
|
|
|
|
|
|
|
|
2014-12-07 12:08:50 +00:00
|
|
|
describe('features/modeling - append text-annotation', function() {
|
2014-12-02 07:36:15 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var diagramXML = require('../../../../fixtures/bpmn/containers.bpmn');
|
2014-12-02 07:36:15 +00:00
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule ];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('should append', function() {
|
|
|
|
|
|
|
|
it('in lane');
|
|
|
|
|
|
|
|
it('in participant', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var eventShape = elementRegistry.get('IntermediateCatchEvent_1'),
|
|
|
|
process = elementRegistry.get('Participant_1').businessObject.processRef;
|
|
|
|
|
|
|
|
// when
|
2014-12-07 12:08:50 +00:00
|
|
|
var annotationShape = modeling.appendShape(eventShape, { type: 'bpmn:TextAnnotation' }),
|
2014-12-02 07:36:15 +00:00
|
|
|
annotation = annotationShape.businessObject;
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
var connectingConnection = find(annotationShape.incoming, function(c) {
|
2014-12-02 07:36:15 +00:00
|
|
|
return c.target === annotationShape;
|
|
|
|
});
|
|
|
|
|
|
|
|
var connecting = connectingConnection.businessObject;
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(annotationShape).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(annotation.$instanceOf('bpmn:TextAnnotation')).to.be.true;
|
2014-12-02 07:36:15 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(connecting.$instanceOf('bpmn:Association')).to.be.true;
|
|
|
|
expect(connecting.sourceRef).to.eql(eventShape.businessObject);
|
|
|
|
expect(connecting.targetRef).to.eql(annotation);
|
2014-12-02 07:36:15 +00:00
|
|
|
|
|
|
|
// correctly assign artifact parent
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(annotation.$parent).to.eql(process);
|
|
|
|
expect(connecting.$parent).to.eql(process);
|
2014-12-02 07:36:15 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(process.artifacts).to.include(annotation);
|
|
|
|
expect(process.artifacts).to.include(connecting);
|
2014-12-02 07:36:15 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('in sub process', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var eventShape = elementRegistry.get('IntermediateThrowEvent_1');
|
|
|
|
|
|
|
|
// when
|
2014-12-07 12:08:50 +00:00
|
|
|
var annotationShape = modeling.appendShape(eventShape, { type: 'bpmn:TextAnnotation' }),
|
2014-12-02 07:36:15 +00:00
|
|
|
annotation = annotationShape.businessObject;
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
var connectingConnection = find(annotationShape.incoming, function(c) {
|
2014-12-02 07:36:15 +00:00
|
|
|
return c.target === annotationShape;
|
|
|
|
});
|
|
|
|
|
|
|
|
var connecting = connectingConnection.businessObject;
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(annotationShape).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(annotation.$instanceOf('bpmn:TextAnnotation')).to.be.true;
|
2014-12-02 07:36:15 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(connecting.$instanceOf('bpmn:Association')).to.be.true;
|
|
|
|
expect(connecting.sourceRef).to.eql(eventShape.businessObject);
|
|
|
|
expect(connecting.targetRef).to.eql(annotation);
|
2014-12-02 07:36:15 +00:00
|
|
|
|
|
|
|
// correctly assign artifact parent
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(annotation.$parent.id).to.equal('Transaction_2');
|
|
|
|
expect(connecting.$parent.id).to.equal('Transaction_2');
|
2014-12-02 07:36:15 +00:00
|
|
|
}));
|
|
|
|
|
2016-03-03 16:51:07 +00:00
|
|
|
it('with right size', inject(function(elementRegistry, elementFactory, modeling) {
|
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
// given
|
2016-03-03 16:51:07 +00:00
|
|
|
var eventShape = elementRegistry.get('IntermediateCatchEvent_1');
|
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
// when
|
2016-03-03 16:51:07 +00:00
|
|
|
var annotationShape = modeling.appendShape(eventShape, { type: 'bpmn:TextAnnotation' });
|
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
// then
|
2016-03-03 16:51:07 +00:00
|
|
|
expect(annotationShape.width).to.eql(100);
|
2016-12-01 12:17:44 +00:00
|
|
|
expect(annotationShape.height).to.eql(30);
|
2016-03-03 16:51:07 +00:00
|
|
|
}));
|
2014-12-02 07:36:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-03-03 16:51:07 +00:00
|
|
|
|
2014-12-02 07:36:15 +00:00
|
|
|
describe('undo', function() {
|
|
|
|
|
|
|
|
it('should undo wire connection source + target', inject(function(elementRegistry, modeling, commandStack) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var eventShape = elementRegistry.get('IntermediateCatchEvent_1'),
|
|
|
|
process = elementRegistry.get('Participant_1').businessObject.processRef;
|
|
|
|
|
2014-12-07 12:08:50 +00:00
|
|
|
var annotationShape = modeling.appendShape(eventShape, { type: 'bpmn:TextAnnotation' }),
|
2014-12-02 07:36:15 +00:00
|
|
|
annotation = annotationShape.businessObject;
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
var connectingConnection = find(annotationShape.incoming, function(c) {
|
2014-12-02 07:36:15 +00:00
|
|
|
return c.target === annotationShape;
|
|
|
|
});
|
|
|
|
|
|
|
|
var connecting = connectingConnection.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(connecting.sourceRef).to.be.null;
|
|
|
|
expect(connecting.targetRef).to.be.null;
|
|
|
|
expect(connecting.$parent).to.be.null;
|
|
|
|
expect(process.artifacts).not.to.include(connecting);
|
2014-12-02 07:36:15 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(annotation.$parent).to.be.null;
|
|
|
|
expect(process.artifacts).not.to.include(annotation);
|
2014-12-02 07:36:15 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|