fix(elementFactory): ensure `collapsed` is set

This commit is contained in:
Martin Stamm 2021-12-15 11:21:53 +01:00 committed by fake-join[bot]
parent 83ffdff08f
commit eed6c3b662
3 changed files with 41 additions and 0 deletions

View File

@ -117,6 +117,10 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
applyAttribute(di, attrs, 'isExpanded');
}
if (is(businessObject, 'bpmn:SubProcess')) {
attrs.collapsed = !isExpanded(businessObject, di);
}
if (is(businessObject, 'bpmn:ExclusiveGateway')) {
di.isMarkerVisible = true;
}

View File

@ -116,6 +116,19 @@ describe('features - element factory', function() {
}));
it('should add collapsed attribute to subprocess', inject(function(elementFactory) {
// when
var subprocess = elementFactory.createShape({
type: 'bpmn:SubProcess',
isExpanded: false
});
// then
expect(subprocess.collapsed).to.be.true;
}));
describe('integration', function() {
it('should create event definition with ID', inject(function(elementFactory) {

View File

@ -1027,6 +1027,30 @@ describe('features/replace - bpmn replace', function() {
);
it('should allow expanding newly created subprocess',
inject(function(bpmnReplace, elementFactory) {
// given
var collapsedProcess = elementFactory.createShape({
type: 'bpmn:SubProcess',
isExpanded: false
});
var newElementData = {
type: 'bpmn:SubProcess',
isExpanded: true
};
// when
var newElement = bpmnReplace.replaceElement(collapsedProcess, newElementData);
// then
expect(is(newElement, 'bpmn:SubProcess')).to.be.true;
expect(isExpanded(newElement)).to.be.true;
})
);
it('should keep size when morphing ad hoc',
inject(function(bpmnReplace, elementRegistry, modeling) {