Merge branch 'master' into develop

This commit is contained in:
Maciej Barelkowski 2019-07-22 15:37:51 +02:00
commit 4ca0a6c9fb
3 changed files with 118 additions and 2 deletions

View File

@ -768,7 +768,7 @@ function canCreate(shape, target, source, position) {
return false; return false;
} }
if (isLabel(target) || isGroup(target)) { if (isLabel(shape) || isGroup(shape)) {
return true; return true;
} }

View File

@ -7,7 +7,8 @@ import {
expectCanConnect, expectCanConnect,
expectCanDrop, expectCanDrop,
expectCanMove, expectCanMove,
expectCanInsert expectCanInsert,
expectCanCreate
} from './Helper'; } from './Helper';
import modelingModule from 'lib/features/modeling'; import modelingModule from 'lib/features/modeling';
@ -1055,6 +1056,111 @@ describe('features/modeling/rules - BpmnRules', function() {
}); });
describe('create Group', function() {
var group;
beforeEach(inject(function(elementFactory) {
group = elementFactory.createShape({
type: 'bpmn:Group',
x: 413, y: 254
});
}));
it('-> MessageFlow', function() {
expectCanCreate(group, 'MessageFlow_labeled', true);
});
it('-> CollapsedParticipant', function() {
expectCanCreate(group, 'CollapsedParticipant', true);
});
it('-> Collaboration', function() {
// then
expectCanCreate(group, 'Collaboration', true);
});
it('-> Task_in_SubProcess', function() {
expectCanCreate(group, 'Task_in_SubProcess', true);
});
it('-> SequenceFlow', function() {
expectCanCreate(group, 'SequenceFlow', true);
});
it('-> DataOutputAssociation', function() {
expectCanCreate(group, 'DataOutputAssociation', true);
});
it('-> Group', function() {
expectCanCreate(group, 'Group', true);
});
});
describe('reject create on Group', function() {
it('DataStoreReference ->', inject(function(elementFactory) {
var dataStoreReference = elementFactory.createShape({
type: 'bpmn:DataStoreReference',
x: 413, y: 254
});
expectCanCreate(dataStoreReference, 'Group', false);
}));
it('Task ->', inject(function(elementFactory) {
var task = elementFactory.createShape({
type: 'bpmn:Task',
x: 413, y: 254
});
expectCanCreate(task, 'Group', false);
}));
});
describe('reject create on label', function() {
var label;
beforeEach(inject(function(elementRegistry) {
label = elementRegistry.get('MessageFlow_labeled').label;
}));
it('DataStoreReference ->', inject(function(elementFactory) {
var dataStoreReference = elementFactory.createShape({
type: 'bpmn:DataStoreReference',
x: 413, y: 254
});
expectCanCreate(dataStoreReference, label, false);
}));
it('Task ->', inject(function(elementFactory) {
var task = elementFactory.createShape({
type: 'bpmn:Task',
x: 413, y: 254
});
expectCanCreate(task, label, false);
}));
});
}); });

View File

@ -47,6 +47,16 @@ export function expectCanDrop(element, target, expectedResult) {
} }
export function expectCanCreate(element, target, expectedResult) {
var result = getBpmnJS().invoke(function(bpmnRules) {
return bpmnRules.canCreate(get(element), get(target));
});
expect(result).to.eql(expectedResult);
}
export function expectCanInsert(element, target, expectedResult) { export function expectCanInsert(element, target, expectedResult) {
var result = getBpmnJS().invoke(function(bpmnRules) { var result = getBpmnJS().invoke(function(bpmnRules) {