Skip to content

Commit

Permalink
FIXUP
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Jun 14, 2019
1 parent a31607c commit 3bef1eb
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 67 deletions.
18 changes: 0 additions & 18 deletions lib/features/modeling/behavior/FixHoverBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@ export default function FixHoverBehavior(elementRegistry, eventBus, canvas) {
}
});


eventBus.on([
'connect.hover',
'connect.move',
'connect.end',
'global-connect.hover'
], HIGH_PRIORITY, function(event) {

var hover = event.hover;

// ensure connections start/end on bpmn:Participant,
// not the underlying bpmn:Lane
if (is(hover, 'bpmn:Lane')) {
event.hover = getLanesRoot(hover) || hover;
event.hoverGfx = elementRegistry.getGraphics(event.hover);
}

});
}

FixHoverBehavior.$inject = [
Expand Down
20 changes: 20 additions & 0 deletions test/spec/features/modeling/behavior/FixHoverBehavior.group.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="sid-38422fae-e03e-43a3-bef4-bd33b32041b2" targetNamespace="http://bpmn.io/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="4.0.0-beta.1">
<process id="Process">
<task id="Task" />
<group id="Group" categoryValueRef="CategoryValue_1heb3m9" />
</process>
<category id="Category_1g60m2v">
<categoryValue id="CategoryValue_1heb3m9" />
</category>
<bpmndi:BPMNDiagram id="BpmnDiagram_1">
<bpmndi:BPMNPlane id="BpmnPlane_1" bpmnElement="Process">
<bpmndi:BPMNShape id="Task_di" bpmnElement="Task">
<omgdc:Bounds x="264" y="81" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Group_di" bpmnElement="Group">
<omgdc:Bounds x="185" y="200" width="150" height="120" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
20 changes: 20 additions & 0 deletions test/spec/features/modeling/behavior/FixHoverBehavior.label.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="sid-38422fae-e03e-43a3-bef4-bd33b32041b2" targetNamespace="http://bpmn.io/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="4.0.0-beta.1">
<process id="Process">
<startEvent id="StartEvent" name="A" />
<task id="Task" />
</process>
<bpmndi:BPMNDiagram id="BpmnDiagram_1">
<bpmndi:BPMNPlane id="BpmnPlane_1" bpmnElement="Process">
<bpmndi:BPMNShape id="StartEvent_di" bpmnElement="StartEvent">
<omgdc:Bounds x="156" y="103" width="36" height="36" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="171" y="146" width="7" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_di" bpmnElement="Task">
<omgdc:Bounds x="264" y="81" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
213 changes: 164 additions & 49 deletions test/spec/features/modeling/behavior/FixHoverBehaviorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,82 +11,197 @@ import moveModule from 'diagram-js/lib/features/move';
import { createCanvasEvent as canvasEvent } from '../../../../util/MockEvents';


var testModules = [
coreModule,
createModule,
moveModule,
modelingModule
];

describe('features/modeling/behavior - fix hover', function() {

var testModules = [
coreModule,
createModule,
moveModule,
modelingModule
];
describe('drop on lane', function() {

var diagramXML = require('./FixHoverBehavior.participant.bpmn');

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

beforeEach(inject(function(dragging) {
dragging.setOptions({ manual: true });
}));

var lane,
laneGfx,
participant;

beforeEach(inject(function(elementRegistry) {
participant = elementRegistry.get('Participant_1');

lane = elementRegistry.get('Lane_1');
laneGfx = elementRegistry.getGraphics(lane);
}));


describe('create', function() {

it('should set participant as hover element', inject(
function(create, dragging, elementFactory) {

// given
var task = elementFactory.createShape({ type: 'bpmn:Task' });

create.start(canvasEvent({ x: 0, y: 0 }), task, true);

// when
dragging.hover({ element: lane, gfx: laneGfx });

dragging.move(canvasEvent({ x: 200, y: 200 }));

dragging.end();

// then
expect(task.parent).to.equal(participant);
}
));

});


describe('move', function() {

it('should set participant as hover element', inject(
function(dragging, elementRegistry, move) {

// given
var task = elementRegistry.get('Task_1');

move.start(canvasEvent({ x: 440, y: 220 }), task, true);

// when
dragging.hover({ element: lane, gfx: laneGfx });

dragging.move(canvasEvent({ x: 240, y: 220 }));

var diagramXML = require('./FixHoverBehavior.participant.bpmn');
dragging.end();

beforeEach(bootstrapModeler(diagramXML, {
modules: testModules
}));
// then
expect(task.parent).to.equal(participant);
}
));

beforeEach(inject(function(dragging) {
dragging.setOptions({ manual: true });
}));
});

var lane,
laneGfx,
participant;
});


describe('label', function() {

var diagramXML = require('./FixHoverBehavior.label.bpmn');

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

beforeEach(inject(function(dragging) {
dragging.setOptions({ manual: true });
}));

beforeEach(inject(function(elementRegistry) {
participant = elementRegistry.get('Participant_1');

lane = elementRegistry.get('Lane_1');
laneGfx = elementRegistry.getGraphics(lane);
}));
describe('move', function() {

describe('create', function() {
it('should set root as hover element', inject(
function(dragging, elementRegistry, move, canvas) {

it('should ensure hovering participant', inject(
function(create, dragging, elementFactory) {
// given
var startEvent = elementRegistry.get('StartEvent');

// given
var task = elementFactory.createShape({ type: 'bpmn:Task' });
var label = startEvent.label;

create.start(canvasEvent({ x: 0, y: 0 }), task, true);
move.start(canvasEvent({ x: 175, y: 150 }), label, true);

// when
dragging.hover({ element: lane, gfx: laneGfx });
// when
dragging.hover({ element: startEvent, gfx: elementRegistry.getGraphics(startEvent) });

dragging.move(canvasEvent({ x: 200, y: 200 }));
dragging.move(canvasEvent({ x: 240, y: 220 }));

dragging.end();
dragging.end();

// then
expect(task.parent).to.equal(participant);
}
));
// then
expect(label.parent).to.equal(canvas.getRootElement());
}
));

});

});


describe('move', function() {
describe('group', function() {

var diagramXML = require('./FixHoverBehavior.group.bpmn');

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

beforeEach(inject(function(dragging) {
dragging.setOptions({ manual: true });
}));


describe('create', function() {

it('should set root as hover element', inject(
function(dragging, elementFactory, elementRegistry, create, canvas) {

// given
var task = elementRegistry.get('Task');

var group = elementFactory.createShape({ type: 'bpmn:Group' });

create.start(canvasEvent({ x: 0, y: 0 }), group, true);

// when
dragging.hover({ element: task, gfx: elementRegistry.getGraphics(task) });

dragging.move(canvasEvent({ x: 240, y: 220 }));

dragging.end();

// then
expect(group.parent).to.equal(canvas.getRootElement());
}
));

});


describe('move', function() {

it('should set root as hover element', inject(
function(dragging, elementRegistry, move, canvas) {

it('should ensure hovering participant', inject(
function(dragging, elementRegistry, move) {
// given
var task = elementRegistry.get('Task');
var group = elementRegistry.get('Group');

// given
var task = elementRegistry.get('Task_1');
move.start(canvasEvent({ x: 175, y: 150 }), group, true);

move.start(canvasEvent({ x: 440, y: 220 }), task, true);
// when
dragging.hover({ element: task, gfx: elementRegistry.getGraphics(task) });

// when
dragging.hover({ element: lane, gfx: laneGfx });
dragging.move(canvasEvent({ x: 240, y: 220 }));

dragging.move(canvasEvent({ x: 240, y: 220 }));
dragging.end();

dragging.end();
// then
expect(group.parent).to.equal(canvas.getRootElement());
}
));

// then
expect(task.parent).to.equal(participant);
}
));
});

});

Expand Down

0 comments on commit 3bef1eb

Please sign in to comment.