Skip to content

Commit

Permalink
fix: support core replace in compensation behavior
Browse files Browse the repository at this point in the history
Closes #2073
  • Loading branch information
barmac authored and nikku committed Jan 9, 2024
1 parent d88a46e commit 11fef5f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
* and remove the potential candidates for connection replacement to have a single compensation activity.
*/
function handleReplacement(context) {
const { targetElement } = context.hints || {},
{ oldShape } = context;
const {
newData,
oldShape
} = context;

// from compensate boundary event
if (isCompensationBoundaryEvent(context.oldShape) &&
targetElement.eventDefinitionType !== 'bpmn:CompensateEventDefinition' ||
targetElement.type !== 'bpmn:BoundaryEvent'
newData.eventDefinitionType !== 'bpmn:CompensateEventDefinition' ||
newData.type !== 'bpmn:BoundaryEvent'
) {
const targetConnection = oldShape.outgoing.find(
({ target }) => isForCompensation(target)
Expand All @@ -112,8 +114,8 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
// to compensate boundary event
else if (
!isCompensationBoundaryEvent(context.oldShape) &&
targetElement.eventDefinitionType === 'bpmn:CompensateEventDefinition' &&
targetElement.type === 'bpmn:BoundaryEvent'
newData.eventDefinitionType === 'bpmn:CompensateEventDefinition' &&
newData.type === 'bpmn:BoundaryEvent'
) {
const targetConnection = oldShape.outgoing.find(
({ target }) => isForCompensationAllowed(target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,27 @@ describe('features/modeling/behavior - compensation boundary event', function()
));


it('should NOT crash when core `replace` component is used', inject(
function(elementRegistry, replace) {

// given
const task = elementRegistry.get('Task_Compensation');

// when
const action = () => {
replace.replaceElement(task,
{
type: 'bpmn:ManualTask'
}
);
};

// then
expect(action).not.to.throw();
}
));


describe('copy and paste', function() {

it('should NOT break on copy and paste', inject(function(canvas, copyPaste, elementRegistry) {
Expand Down

0 comments on commit 11fef5f

Please sign in to comment.