2014-12-02 07:36:15 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var TestHelper = require('../../../../TestHelper');
|
2014-12-02 07:36:15 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var find = require('lodash/collection/find');
|
2014-12-02 07:36:15 +00:00
|
|
|
|
|
|
|
var modelingModule = require('../../../../../lib/features/modeling'),
|
|
|
|
coreModule = require('../../../../../lib/core');
|
|
|
|
|
|
|
|
|
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
|
|
|
|
expect(annotationShape).toBeDefined();
|
|
|
|
expect(annotation.$instanceOf('bpmn:TextAnnotation')).toBe(true);
|
|
|
|
|
|
|
|
expect(connecting.$instanceOf('bpmn:Association')).toBe(true);
|
|
|
|
expect(connecting.sourceRef).toBe(eventShape.businessObject);
|
|
|
|
expect(connecting.targetRef).toBe(annotation);
|
|
|
|
|
|
|
|
// correctly assign artifact parent
|
|
|
|
expect(annotation.$parent).toBe(process);
|
|
|
|
expect(connecting.$parent).toBe(process);
|
|
|
|
|
|
|
|
expect(process.artifacts).toContain(annotation);
|
|
|
|
expect(process.artifacts).toContain(connecting);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
expect(annotationShape).toBeDefined();
|
|
|
|
expect(annotation.$instanceOf('bpmn:TextAnnotation')).toBe(true);
|
|
|
|
|
|
|
|
expect(connecting.$instanceOf('bpmn:Association')).toBe(true);
|
|
|
|
expect(connecting.sourceRef).toBe(eventShape.businessObject);
|
|
|
|
expect(connecting.targetRef).toBe(annotation);
|
|
|
|
|
|
|
|
// correctly assign artifact parent
|
|
|
|
expect(annotation.$parent.id).toBe('Transaction_2');
|
|
|
|
expect(connecting.$parent.id).toBe('Transaction_2');
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
expect(connecting.sourceRef).toBe(null);
|
|
|
|
expect(connecting.targetRef).toBe(null);
|
|
|
|
expect(connecting.$parent).toBe(null);
|
|
|
|
expect(process.artifacts).not.toContain(connecting);
|
|
|
|
|
|
|
|
expect(annotation.$parent).toBe(null);
|
|
|
|
expect(process.artifacts).not.toContain(annotation);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|