test(Viewer): simplify multiple-diagrams test cases

This commit is contained in:
Maciej Barelkowski 2019-04-16 14:53:06 +02:00 committed by Nico Rehwaldt
parent 87c1d2d142
commit 0affb3b3bc
5 changed files with 146 additions and 5994 deletions

View File

@ -0,0 +1,47 @@
<?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:omgdi="http://www.omg.org/spec/DD/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="3.3.1">
<collaboration id="Collaboration_1">
<participant id="Participant_1" name="Pool" processRef="Process_1"/>
</collaboration>
<process id="Process_1" isExecutable="false">
<laneSet id="LaneSet_1" name="Lane Set 1" />
<task id="Task_A" name="A">
<outgoing>SequenceFlow</outgoing>
</task>
<endEvent id="EndEvent_B" name="B">
<incoming>SequenceFlow</incoming>
</endEvent>
<sequenceFlow id="SequenceFlow" sourceRef="Task_A" targetRef="EndEvent_B" />
</process>
<process id="Process_2" isExecutable="false">
<laneSet id="LaneSet_2" name="Lane Set 2" />
<task id="Task_B" name="B" />
</process>
<bpmndi:BPMNDiagram id="BpmnDiagram_1">
<bpmndi:BPMNPlane id="BpmnPlane_1" bpmnElement="Collaboration_1">
<bpmndi:BPMNShape id="Participant_1_di" bpmnElement="Participant_1">
<omgdc:Bounds x="56" y="31" width="500" height="500" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BpmnDiagram_1_Task_A_di" bpmnElement="Task_A">
<omgdc:Bounds x="156" y="81" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BpmnDiagram_1_EndEvent_B_di" bpmnElement="EndEvent_B">
<omgdc:Bounds x="306" y="103" width="36" height="36" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="320" y="147" width="8" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BpmnDiagram_1_SequenceFlow_di" bpmnElement="SequenceFlow">
<omgdi:waypoint x="256" y="121" />
<omgdi:waypoint x="306" y="121" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BpmnDiagram_2">
<bpmndi:BPMNPlane id="BpmnPlane_2" bpmnElement="Process_2">
<bpmndi:BPMNShape id="BpmnDiagram_2_Task_B_di" bpmnElement="Task_B">
<omgdc:Bounds x="0" y="0" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

File diff suppressed because it is too large Load Diff

View File

@ -116,7 +116,7 @@ describe('Modeler', function() {
}
// when
modeler.open('Diagram_2', function(err, warnings) {
modeler.open('BpmnDiagram_2', function(err, warnings) {
if (err) {
return done(err);

View File

@ -706,7 +706,7 @@ describe('Viewer', function() {
it('should import bpmnDiagram specified by id', function(done) {
// when
createViewer(multipleXML, 'Diagram_3', function(err) {
createViewer(multipleXML, 'BpmnDiagram_2', function(err) {
// then
done(err);
@ -771,14 +771,17 @@ describe('Viewer', function() {
describe('#open', function() {
var multipleXML = require('../fixtures/bpmn/multiple-diagrams.bpmn'),
simpleMultipleXML = require('../fixtures/bpmn/multiple-diagrams-simple.bpmn');
var multipleXMLSimple = require('../fixtures/bpmn/multiple-diagrams.bpmn'),
multipleXMLOverlappingDI = require('../fixtures/bpmn/multiple-diagrams-overlapping-di.bpmn'),
multipleXMLWithLaneSet = require('../fixtures/bpmn/multiple-diagrams-lanesets.bpmn'),
diagram1 = 'BpmnDiagram_1',
diagram2 = 'BpmnDiagram_2';
it('should open the first diagram if id was not provided', function(done) {
// when
createViewer(multipleXML, 'Diagram_1', function(err, warnings, viewer) {
createViewer(multipleXMLSimple, diagram1, function(err, warnings, viewer) {
if (err) {
return done(err);
@ -805,10 +808,12 @@ describe('Viewer', function() {
it('should switch between diagrams', function(done) {
// when
createViewer(multipleXML, 'Diagram_1', function(err, warnings, viewer) {
createViewer(multipleXMLSimple, diagram1, function(err, warnings, viewer) {
// then
expect(err).not.to.exist;
if (err) {
return done(err);
}
expect(warnings).to.be.empty;
@ -816,15 +821,21 @@ describe('Viewer', function() {
expect(definitions).to.exist;
viewer.open('Diagram_2', function(err, warnings) {
viewer.open(diagram2, function(err, warnings) {
// then
expect(err).not.to.exist;
if (err) {
return done(err);
}
expect(warnings).to.be.empty;
expect(definitions).to.equal(viewer.getDefinitions());
expect(viewer.get('elementRegistry').getAll()).to.have.lengthOf(28);
var elementRegistry = viewer.get('elementRegistry');
expect(elementRegistry.get('Task_A')).to.not.exist;
expect(elementRegistry.get('Task_B')).to.exist;
done();
});
@ -837,10 +848,12 @@ describe('Viewer', function() {
it('should switch between diagrams with overlapping DI', function(done) {
// when
createViewer(simpleMultipleXML, 'BpmnDiagram_1', function(err, warnings, viewer) {
createViewer(multipleXMLOverlappingDI, diagram1, function(err, warnings, viewer) {
// then
expect(err).not.to.exist;
if (err) {
return done(err);
}
expect(warnings).to.be.empty;
@ -848,10 +861,13 @@ describe('Viewer', function() {
expect(definitions).to.exist;
viewer.open('BpmnDiagram_2', function(err, warnings) {
viewer.open(diagram2, function(err, warnings) {
// then
expect(err).not.to.exist;
if (err) {
return done(err);
}
expect(warnings).to.be.empty;
expect(definitions).to.equal(viewer.getDefinitions());
@ -860,6 +876,45 @@ describe('Viewer', function() {
});
});
});
it('should switch between diagrams with laneSets', function(done) {
// when
createViewer(multipleXMLWithLaneSet, diagram2, function(err, warnings, viewer) {
// then
if (err) {
return done(err);
}
expect(warnings).to.be.empty;
var definitions = viewer.getDefinitions();
expect(definitions).to.exist;
viewer.open(diagram1, function(err, warnings) {
// then
if (err) {
return done(err);
}
expect(warnings).to.be.empty;
expect(definitions).to.equal(viewer.getDefinitions());
var elementRegistry = viewer.get('elementRegistry');
expect(elementRegistry.get('Task_A')).to.exist;
expect(elementRegistry.get('Task_B')).to.not.exist;
done();
});
});
});
@ -889,10 +944,13 @@ describe('Viewer', function() {
it('should open with error if diagram does not exist', function(done) {
// when
createViewer(multipleXML, 'Diagram_1', function(err, warnings, viewer) {
createViewer(multipleXMLSimple, diagram1, function(err, warnings, viewer) {
// then
expect(err).not.to.exist;
if (err) {
return done(err);
}
expect(warnings).to.be.empty;
var definitions = viewer.getDefinitions();
@ -920,7 +978,7 @@ describe('Viewer', function() {
var events = [];
viewer.importXML(multipleXML, 'Diagram_1', function(err) {
viewer.importXML(multipleXMLSimple, diagram1, function(err) {
// given
viewer.on([
@ -940,7 +998,7 @@ describe('Viewer', function() {
});
// when
viewer.open('Diagram_2', function(err) {
viewer.open(diagram2, function(err) {
// then
expect(events).to.eql([