Skip to content

Commit

Permalink
fix: allow to create connection + event-based gateway
Browse files Browse the repository at this point in the history
Closes #1490
  • Loading branch information
nikku committed Aug 21, 2023
1 parent 771c2ff commit 3c473c8
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/features/modeling/behavior/EventBasedGatewayBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@ export default function EventBasedGatewayBehavior(eventBus, modeling) {
var sequenceFlows = [];

if (is(source, 'bpmn:EventBasedGateway')) {
sequenceFlows = target.incoming.filter(isSequenceFlow);
sequenceFlows = target.incoming
.filter(flow =>
flow !== connection &&
isSequenceFlow(flow)
);
} else {
sequenceFlows = target.incoming.filter(function(connection) {
return isSequenceFlow(connection)
&& is(connection.source, 'bpmn:EventBasedGateway');
});
sequenceFlows = target.incoming
.filter(flow =>
flow !== connection &&
isSequenceFlow(flow) &&
is(flow.source, 'bpmn:EventBasedGateway')
);
}

sequenceFlows.forEach(function(sequenceFlow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import {
} from 'test/TestHelper';

import coreModule from 'lib/core';
import createModule from 'diagram-js/lib/features/create';
import modelingModule from 'lib/features/modeling';
import replaceModule from 'lib/features/replace';

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


describe('features/modeling/behavior - event-based gateway', function() {

var diagramXML = require('./EventBasedGatewayBehavior.bpmn');
Expand Down Expand Up @@ -145,3 +149,64 @@ describe('features/modeling/behavior - event-based gateway', function() {
});

});


describe('features/modeling/behavior - event-based gateway - integration', function() {

var diagramXML = require('./EventBasedGatewayBehavior.bpmn');

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

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


it('should create with target', inject(
function(create, elementRegistry, elementFactory, dragging) {
// given

Check failure on line 172 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Expected line before comment

Check failure on line 172 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Expected line before comment
const gateway = elementFactory.createShape({
type: "bpmn:EventBasedGateway",

Check failure on line 174 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Strings must use singlequote

Check failure on line 174 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Strings must use singlequote
x: 0,
y: 0
});

const event = elementFactory.createShape({
type: "bpmn:IntermediateCatchEvent",

Check failure on line 180 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Strings must use singlequote

Check failure on line 180 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Strings must use singlequote
eventDefinitionType: "bpmn:MessageEventDefinition",

Check failure on line 181 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Strings must use singlequote

Check failure on line 181 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Strings must use singlequote
x: 120,
y: 120
});

const waypoints = [
{ x: gateway.x, y: gateway.y },
{ x: event.x, y: event.y }
];

const connection = elementFactory.createConnection({
type: "bpmn:SequenceFlow",

Check failure on line 192 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Strings must use singlequote

Check failure on line 192 in test/spec/features/modeling/behavior/EventBasedGatewayBehaviorSpec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04)

Strings must use singlequote
source: gateway,
target: event,
waypoints
});

const rootElement = elementRegistry.get('Process_1');
const rootGfx = elementRegistry.getGraphics('Process_1');

// when
create.start(canvasEvent({ x: 0, y: 0 }), [ gateway, event, connection ]);
dragging.hover({ element: rootElement, gfx: rootGfx });
dragging.move(canvasEvent({ x: 100, y: 200 }));
dragging.end();

// then
expect(elementRegistry.get(connection.id)).to.exist;
}
));

});

0 comments on commit 3c473c8

Please sign in to comment.