2014-06-27 15:52:34 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var TestHelper = require('../../../TestHelper');
|
2014-06-27 15:52:34 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
var TestContainer = require('mocha-test-container-support');
|
|
|
|
|
2015-06-04 13:24:35 +00:00
|
|
|
var domQuery = require('min-dom/lib/query');
|
|
|
|
|
2016-01-06 16:36:11 +00:00
|
|
|
var is = require('../../../../lib/util/ModelUtil').is;
|
|
|
|
|
2016-08-18 13:23:19 +00:00
|
|
|
var canvasEvent = require('../../../util/MockEvents').createCanvasEvent;
|
|
|
|
|
2016-01-06 16:36:11 +00:00
|
|
|
|
2016-01-25 20:26:46 +00:00
|
|
|
/* global bootstrapModeler, inject */
|
2014-06-27 15:52:34 +00:00
|
|
|
|
|
|
|
|
2014-08-01 05:16:59 +00:00
|
|
|
var contextPadModule = require('../../../../lib/features/context-pad'),
|
2015-04-30 08:52:34 +00:00
|
|
|
coreModule = require('../../../../lib/core'),
|
|
|
|
modelingModule = require('../../../../lib/features/modeling'),
|
2016-01-06 16:36:11 +00:00
|
|
|
replaceMenuModule = require('../../../../lib/features/popup-menu'),
|
2016-08-18 13:23:19 +00:00
|
|
|
createModule = require('diagram-js/lib/features/create'),
|
2017-12-08 20:06:08 +00:00
|
|
|
customRulesModule = require('../../../util/custom-rules'),
|
|
|
|
autoPlaceModule = require('../../../../lib/features/auto-place');
|
2014-06-27 15:52:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features - context-pad', function() {
|
|
|
|
|
2016-01-06 16:36:11 +00:00
|
|
|
var testModules = [
|
|
|
|
coreModule,
|
|
|
|
modelingModule,
|
|
|
|
contextPadModule,
|
|
|
|
replaceMenuModule,
|
2016-08-18 13:23:19 +00:00
|
|
|
customRulesModule,
|
|
|
|
createModule
|
2016-01-06 16:36:11 +00:00
|
|
|
];
|
2014-06-27 15:52:34 +00:00
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('remove action rules', function() {
|
2014-06-27 15:52:34 +00:00
|
|
|
|
2016-01-21 10:17:11 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/simple.bpmn');
|
2014-06-27 15:52:34 +00:00
|
|
|
|
2016-01-21 10:17:11 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
2015-05-08 12:26:05 +00:00
|
|
|
|
|
|
|
|
2015-12-02 11:12:04 +00:00
|
|
|
var deleteAction;
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(inject(function(contextPad) {
|
2015-12-02 11:12:04 +00:00
|
|
|
|
|
|
|
deleteAction = function(element) {
|
2016-01-06 15:36:49 +00:00
|
|
|
return padEntry(contextPad.getPad(element).html, 'delete');
|
2015-12-02 11:12:04 +00:00
|
|
|
};
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should add delete action by default', inject(function(elementRegistry, contextPad) {
|
2015-12-02 11:12:04 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('StartEvent_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
contextPad.open(element);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(deleteAction(element)).to.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
it('should include delete action when rule returns true',
|
2016-06-07 06:46:45 +00:00
|
|
|
inject(function(elementRegistry, contextPad, customRules) {
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
customRules.addRule('elements.delete', 1500, function() {
|
|
|
|
return true;
|
|
|
|
});
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var element = elementRegistry.get('StartEvent_1');
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
contextPad.open(element);
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(deleteAction(element)).to.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-12-02 11:12:04 +00:00
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
it('should NOT include delete action when rule returns false',
|
|
|
|
inject(function(elementRegistry, contextPad, customRules) {
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
customRules.addRule('elements.delete', 1500, function() {
|
|
|
|
return false;
|
|
|
|
});
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var element = elementRegistry.get('StartEvent_1');
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
contextPad.open(element);
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(deleteAction(element)).to.not.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-12-02 11:12:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should call rules with [ element ]', inject(function(elementRegistry, contextPad, customRules) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('StartEvent_1');
|
|
|
|
|
2016-03-23 14:32:10 +00:00
|
|
|
customRules.addRule('elements.delete', 1500, function(context) {
|
2015-12-02 11:12:04 +00:00
|
|
|
|
|
|
|
// element array is actually passed
|
|
|
|
expect(context.elements).to.eql([ element ]);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(function() {
|
|
|
|
contextPad.open(element);
|
|
|
|
}).not.to.throw;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
it('should include delete action when [ element ] is returned from rule',
|
|
|
|
inject(function(elementRegistry, contextPad, customRules) {
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
customRules.addRule('elements.delete', 1500, function(context) {
|
|
|
|
return context.elements;
|
|
|
|
});
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var element = elementRegistry.get('StartEvent_1');
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
contextPad.open(element);
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(deleteAction(element)).to.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-12-02 11:12:04 +00:00
|
|
|
|
|
|
|
|
2015-12-10 11:48:40 +00:00
|
|
|
it('should NOT include delete action when [ ] is returned from rule',
|
|
|
|
inject(function(elementRegistry, contextPad, customRules) {
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
customRules.addRule('elements.delete', 1500, function() {
|
|
|
|
return [];
|
|
|
|
});
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var element = elementRegistry.get('StartEvent_1');
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
contextPad.open(element);
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(deleteAction(element)).to.not.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-12-02 11:12:04 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-01-21 10:17:11 +00:00
|
|
|
describe('available entries', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./ContextPad.activation.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
function expectContextPadEntries(elementOrId, expectedEntries) {
|
|
|
|
|
|
|
|
TestHelper.getBpmnJS().invoke(function(elementRegistry, contextPad) {
|
|
|
|
|
|
|
|
var element = typeof elementOrId === 'string' ? elementRegistry.get(elementOrId) : elementOrId;
|
|
|
|
|
|
|
|
contextPad.open(element, true);
|
|
|
|
|
|
|
|
var entries = contextPad._current.entries;
|
|
|
|
|
|
|
|
expectedEntries.forEach(function(name) {
|
|
|
|
|
|
|
|
if (name.charAt(0) === '!') {
|
|
|
|
name = name.substring(1);
|
|
|
|
|
|
|
|
expect(entries).not.to.have.property(name);
|
|
|
|
} else {
|
|
|
|
expect(entries).to.have.property(name);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
it('should provide Task entries', inject(function() {
|
|
|
|
|
|
|
|
expectContextPadEntries('Task_1', [
|
|
|
|
'connect',
|
|
|
|
'replace',
|
|
|
|
'append.end-event',
|
|
|
|
'append.gateway',
|
|
|
|
'append.append-task',
|
|
|
|
'append.intermediate-event',
|
|
|
|
'append.text-annotation'
|
|
|
|
]);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should provide EventBasedGateway entries', inject(function() {
|
|
|
|
|
|
|
|
expectContextPadEntries('EventBasedGateway_1', [
|
|
|
|
'connect',
|
|
|
|
'replace',
|
|
|
|
'append.receive-task',
|
|
|
|
'append.message-intermediate-event',
|
|
|
|
'append.timer-intermediate-event',
|
|
|
|
'append.condtion-intermediate-event',
|
|
|
|
'append.signal-intermediate-event',
|
|
|
|
'append.text-annotation',
|
|
|
|
'!append.task'
|
|
|
|
]);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should provide EndEvent entries', inject(function() {
|
|
|
|
|
|
|
|
expectContextPadEntries('EndEvent_1', [
|
|
|
|
'connect',
|
|
|
|
'replace',
|
|
|
|
'!append.task'
|
|
|
|
]);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should provide Compensation Activity entries', inject(function() {
|
|
|
|
|
|
|
|
expectContextPadEntries('Task_2', [
|
|
|
|
'connect',
|
|
|
|
'replace',
|
|
|
|
'!append.end-event',
|
|
|
|
'append.text-annotation'
|
|
|
|
]);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should provide Compensate Boundary entries', inject(function() {
|
|
|
|
|
|
|
|
expectContextPadEntries('BoundaryEvent_1', [
|
|
|
|
'connect',
|
|
|
|
'replace',
|
|
|
|
'append.compensation-activity',
|
|
|
|
'!append.end-event'
|
|
|
|
]);
|
|
|
|
}));
|
|
|
|
|
2016-01-25 20:26:46 +00:00
|
|
|
|
|
|
|
it('should provide DataStoreReference entries', inject(function() {
|
|
|
|
|
|
|
|
expectContextPadEntries('DataStoreReference', [
|
|
|
|
'connect',
|
2016-05-31 08:57:46 +00:00
|
|
|
'append.text-annotation',
|
2016-01-25 20:26:46 +00:00
|
|
|
'!replace',
|
2016-05-31 08:57:46 +00:00
|
|
|
'!append.end-event'
|
|
|
|
]);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should provide DataObjectReference entries', inject(function() {
|
|
|
|
|
|
|
|
expectContextPadEntries('DataObjectReference', [
|
|
|
|
'connect',
|
|
|
|
'append.text-annotation',
|
|
|
|
'!replace',
|
|
|
|
'!append.end-event'
|
2016-01-25 20:26:46 +00:00
|
|
|
]);
|
|
|
|
}));
|
|
|
|
|
2016-01-21 10:17:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-01-06 15:36:49 +00:00
|
|
|
describe('replace', function() {
|
2015-05-08 12:26:05 +00:00
|
|
|
|
2016-01-21 10:17:11 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
2015-05-15 09:06:49 +00:00
|
|
|
var container;
|
2016-01-06 15:36:49 +00:00
|
|
|
|
2015-05-15 09:06:49 +00:00
|
|
|
beforeEach(function() {
|
2015-07-15 15:22:19 +00:00
|
|
|
container = TestContainer.get(this);
|
2015-05-15 09:06:49 +00:00
|
|
|
});
|
2015-05-08 12:26:05 +00:00
|
|
|
|
2016-01-06 15:36:49 +00:00
|
|
|
|
|
|
|
it('should show popup menu in the correct position', inject(function(elementRegistry, contextPad) {
|
2015-05-15 09:06:49 +00:00
|
|
|
|
2015-05-08 12:26:05 +00:00
|
|
|
// given
|
2015-06-04 13:24:35 +00:00
|
|
|
var element = elementRegistry.get('StartEvent_1'),
|
2015-05-15 09:06:49 +00:00
|
|
|
padding = 5,
|
|
|
|
replaceMenuRect,
|
|
|
|
padMenuRect;
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2015-06-04 13:24:35 +00:00
|
|
|
contextPad.open(element);
|
|
|
|
padMenuRect = contextPad.getPad(element).html.getBoundingClientRect();
|
2015-05-08 12:26:05 +00:00
|
|
|
|
2015-06-04 13:24:35 +00:00
|
|
|
// mock event
|
|
|
|
var event = {
|
2016-01-06 15:36:49 +00:00
|
|
|
target: padEntry(container, 'replace'),
|
2016-06-07 06:46:45 +00:00
|
|
|
preventDefault: function() {}
|
2015-06-04 13:24:35 +00:00
|
|
|
};
|
2015-05-08 12:26:05 +00:00
|
|
|
|
|
|
|
// when
|
2015-06-04 13:24:35 +00:00
|
|
|
contextPad.trigger('click', event);
|
2015-12-10 11:48:40 +00:00
|
|
|
replaceMenuRect = domQuery('.bpmn-replace', container).getBoundingClientRect();
|
2015-05-08 12:26:05 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(replaceMenuRect.left).to.be.at.most(padMenuRect.left);
|
|
|
|
expect(replaceMenuRect.top).to.be.at.most(padMenuRect.bottom + padding);
|
2015-05-08 12:26:05 +00:00
|
|
|
}));
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2016-01-06 15:36:49 +00:00
|
|
|
|
2016-01-06 16:36:11 +00:00
|
|
|
it('should not include control if replacement is disallowed',
|
2016-01-06 15:36:49 +00:00
|
|
|
inject(function(elementRegistry, contextPad, customRules) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('StartEvent_1');
|
2016-01-06 15:36:49 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// disallow replacement
|
|
|
|
customRules.addRule('shape.replace', function(context) {
|
|
|
|
return !is(context.element, 'bpmn:StartEvent');
|
|
|
|
});
|
2016-01-06 15:36:49 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
contextPad.open(element);
|
2016-01-06 15:36:49 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var padNode = contextPad.getPad(element).html;
|
2016-01-06 15:36:49 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(padEntry(padNode, 'replace')).not.to.exist;
|
2016-08-18 13:23:19 +00:00
|
|
|
}));
|
2016-01-06 15:36:49 +00:00
|
|
|
|
2016-01-06 16:36:11 +00:00
|
|
|
|
|
|
|
it('should include control if replacement is allowed',
|
|
|
|
inject(function(elementRegistry, contextPad, customRules) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('EndEvent_1');
|
2016-01-06 16:36:11 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// disallow replacement
|
|
|
|
customRules.addRule('shape.replace', function(context) {
|
|
|
|
return !is(context.element, 'bpmn:StartEvent');
|
|
|
|
});
|
2016-01-06 16:36:11 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
contextPad.open(element);
|
2016-01-06 16:36:11 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var padNode = contextPad.getPad(element).html;
|
2016-01-06 16:36:11 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(padEntry(padNode, 'replace')).to.exist;
|
2016-08-18 13:23:19 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-08-31 09:02:04 +00:00
|
|
|
it('should open the replace menu after an element is created if it has modifier key',
|
2016-08-18 13:23:19 +00:00
|
|
|
inject(function(create, dragging, canvas, elementFactory) {
|
|
|
|
// given
|
|
|
|
var rootShape = canvas.getRootElement(),
|
|
|
|
startEvent = elementFactory.createShape({ type: 'bpmn:StartEvent' }),
|
|
|
|
replaceMenu;
|
|
|
|
|
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 0, y: 0 }), startEvent);
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 50, y: 50 }));
|
|
|
|
dragging.hover({ element: rootShape });
|
|
|
|
dragging.move(canvasEvent({ x: 75, y: 75 }));
|
|
|
|
|
2016-08-31 09:02:04 +00:00
|
|
|
dragging.end(canvasEvent({ x: 75, y: 75 }, { ctrlKey: true, metaKey: true }));
|
2016-08-18 13:23:19 +00:00
|
|
|
|
|
|
|
replaceMenu = domQuery('.bpmn-replace', container);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(replaceMenu).to.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-09-19 09:39:33 +00:00
|
|
|
it('should open boundary event replace menu after an element is created if it has modifier key',
|
|
|
|
inject(function(create, dragging, canvas, elementFactory, modeling, popupMenu) {
|
|
|
|
// given
|
|
|
|
var rootShape = canvas.getRootElement();
|
|
|
|
var task = elementFactory.createShape({ type: 'bpmn:Task' });
|
|
|
|
var intermediateEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' });
|
|
|
|
|
|
|
|
modeling.createShape(task, { x: 100, y: 100 }, rootShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 0, y: 0 }), intermediateEvent);
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 50, y: 50 }));
|
|
|
|
dragging.hover({ element: task });
|
|
|
|
dragging.move(canvasEvent({ x: 50, y: 65 }));
|
|
|
|
|
|
|
|
dragging.end(canvasEvent({ x: 50, y: 65 }, { ctrlKey: true, metaKey: true }));
|
|
|
|
|
|
|
|
// then
|
|
|
|
var replaceMenu = domQuery.all('[data-id$="-boundary"]', popupMenu._current.container);
|
|
|
|
expect(replaceMenu).to.exist;
|
|
|
|
expect(replaceMenu.length).to.eql(13);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-08-18 13:23:19 +00:00
|
|
|
it('should not open the replace menu after an element is created when there is none',
|
|
|
|
inject(function(create, dragging, canvas, elementFactory) {
|
|
|
|
// given
|
|
|
|
var rootShape = canvas.getRootElement(),
|
|
|
|
dataObject = elementFactory.createShape({ type: 'bpmn:DataObjectReference' }),
|
|
|
|
replaceMenu;
|
|
|
|
|
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 0, y: 0 }), dataObject);
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 50, y: 50 }));
|
|
|
|
dragging.hover({ element: rootShape });
|
|
|
|
dragging.move(canvasEvent({ x: 75, y: 75 }));
|
|
|
|
|
2016-08-31 09:02:04 +00:00
|
|
|
dragging.end(canvasEvent({ x: 75, y: 75 }, { ctrlKey: true, metaKey: true }));
|
2016-08-18 13:23:19 +00:00
|
|
|
|
|
|
|
replaceMenu = domQuery('.bpmn-replace', container);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(replaceMenu).to.not.exist;
|
|
|
|
}));
|
2016-01-06 16:36:11 +00:00
|
|
|
|
2015-05-08 12:26:05 +00:00
|
|
|
});
|
2015-12-02 11:12:04 +00:00
|
|
|
|
2017-12-08 20:06:08 +00:00
|
|
|
|
|
|
|
describe('auto place', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules.concat(autoPlaceModule)
|
|
|
|
}));
|
|
|
|
|
|
|
|
var container;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
container = TestContainer.get(this);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should trigger', inject(function(elementRegistry, contextPad) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
contextPad.open(element);
|
|
|
|
|
|
|
|
// mock event
|
|
|
|
var event = {
|
|
|
|
clientX: 100,
|
|
|
|
clientY: 100,
|
|
|
|
target: padEntry(container, 'append.gateway'),
|
|
|
|
preventDefault: function() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
contextPad.trigger('click', event);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(element.outgoing).to.have.length(1);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('disabled auto-place', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules.concat(autoPlaceModule),
|
|
|
|
contextPad: {
|
|
|
|
autoPlace: false
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
var container;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
container = TestContainer.get(this);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should default to drag start', inject(function(elementRegistry, contextPad, dragging) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
contextPad.open(element);
|
|
|
|
|
|
|
|
// mock event
|
|
|
|
var event = {
|
|
|
|
clientX: 100,
|
|
|
|
clientY: 100,
|
|
|
|
target: padEntry(container, 'append.gateway'),
|
|
|
|
preventDefault: function() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
contextPad.trigger('click', event);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(dragging.context()).to.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-10-27 11:07:57 +00:00
|
|
|
});
|
2016-01-06 15:36:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
function padEntry(element, name) {
|
|
|
|
return domQuery('[data-action="' + name + '"]', element);
|
2016-08-18 13:23:19 +00:00
|
|
|
}
|