Skip to content

Commit

Permalink
fix(drd): correct append behavior
Browse files Browse the repository at this point in the history
+ test cover dat stuff

Related to camunda/camunda-modeler#1604
  • Loading branch information
nikku authored and fake-join[bot] committed Nov 26, 2019
1 parent 7d9cd36 commit 8896209
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
function appendListener(event, element) {

var shape = elementFactory.createShape(assign({ type: type }, options));
create.start(event, shape, element);

create.start(event, shape, {
source: element
});
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import modelingModule from 'src/features/modeling';
import createModule from 'diagram-js/lib/features/create';
import customRulesModule from '../../../util/custom-rules';

import {
createCanvasEvent as canvasEvent
} from '../../../util/MockEvents';


describe('features - context-pad', function() {

Expand Down Expand Up @@ -260,6 +264,7 @@ describe('features - context-pad', function() {

});


describe('replace', function() {

var diagramXML = require('./ContextPad.dmn');
Expand Down Expand Up @@ -329,9 +334,55 @@ describe('features - context-pad', function() {

});


describe('append', function() {

var diagramXML = require('./ContextPad.dmn');

beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));


it('should append decision', inject(function(dragging, contextPad, elementRegistry) {

// given
var decision = elementRegistry.get('guestCount');

var decisionTargets = decision.outgoing.length;

// when
contextPad.open(decision);

contextPad.trigger('dragstart', padEvent('append.decision'));

dragging.move(canvasEvent({ x: decision.x, y: decision.y }));
dragging.hover({ element: decision.parent });
dragging.move(canvasEvent({ x: decision.x - 100, y: decision.y - 90 }));
dragging.end();

// then
expect(decision.outgoing).to.have.length(decisionTargets + 1);
}));

});

});


function padEntry(element, name) {
return domQuery('[data-action="' + name + '"]', element);
}

function padEvent(entry) {

return getDrdJS().invoke(function(overlays) {

var target = padEntry(overlays._overlayRoot, entry);

return {
target: target,
preventDefault: function() {},
clientX: 100,
clientY: 100
};
});
}

0 comments on commit 8896209

Please sign in to comment.