Skip to content

Commit

Permalink
fix(drilldown): gracefully handle missing BPMNDiagram#plane
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku authored May 27, 2024
1 parent bc24a60 commit a66d850
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/features/drilldown/SubprocessCompatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ SubprocessCompatibility.prototype._handleImport = function(definitions) {
self._processToDiagramMap[diagram.plane.bpmnElement.id] = diagram;
});

var newDiagrams = [];
definitions.diagrams.forEach(function(diagram) {
var createdDiagrams = self._createNewDiagrams(diagram.plane);
Array.prototype.push.apply(newDiagrams, createdDiagrams);
});
var newDiagrams = definitions.diagrams
.filter(diagram => diagram.plane)
.flatMap(diagram => self._createNewDiagrams(diagram.plane));

newDiagrams.forEach(function(diagram) {
self._movePlaneElementsToOrigin(diagram.plane);
Expand Down
38 changes: 37 additions & 1 deletion test/spec/features/drilldown/DrilldownSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ describe('features - drilldown', function() {
});


describe('Legacy Processes', function() {
describe('features - drilldown - Legacy Processes', function() {

beforeEach(bootstrapViewer(legacyXML, { modules: testModules }));

Expand Down Expand Up @@ -454,6 +454,42 @@ describe('features - drilldown', function() {
});


describe('features/drilldown - integration', function() {

var testModules = [
coreModule,
DrilldownModule
];

var missingDiXML = require('./missing-di-bpmndiagram-plane.bpmn');

var multiLayerXML = require('./nested-subprocesses.bpmn');

beforeEach(bootstrapViewer(multiLayerXML, { modules: testModules }));


describe('error handling', function() {

it('should import diagram with missing BPMNDiagram#plane', inject(
async function(bpmnjs) {

let error;

try {
await bpmnjs.importXML(missingDiXML);
} catch (_error) {
error = _error;
}

expect(error).not.to.exist;
}
));

});

});


// helpers

function getBreadcrumbs() {
Expand Down
17 changes: 17 additions & 0 deletions test/spec/features/drilldown/missing-di-bpmndiagram-plane.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="DEFINITIONS" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.23.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.21.0">
<bpmn:process id="PROCESS" isExecutable="true">
<bpmn:subProcess id="SUB_PROCESS">
<bpmn:subProcess id="SUB_PROCESS_NESTED_NO_DI" />
</bpmn:subProcess>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PROCESS">
<bpmndi:BPMNShape id="SUB_PROCESS_di" bpmnElement="SUB_PROCESS" isExpanded="false">
<dc:Bounds x="355" y="160" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_2">
</bpmndi:BPMNDiagram>
</bpmn:definitions>

0 comments on commit a66d850

Please sign in to comment.