test: verify copy and paste between Modeler instances
This commit is contained in:
parent
c9a9f259fc
commit
345bd7e4a9
|
@ -0,0 +1,16 @@
|
|||
<?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_1q7lgbo" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.151.0">
|
||||
<bpmn:process id="Process_1" isExecutable="true">
|
||||
<bpmn:startEvent id="A" name="A" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="Event_083mmcb_di" bpmnElement="A">
|
||||
<dc:Bounds x="152" y="82" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="167" y="125" width="7" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -0,0 +1,16 @@
|
|||
<?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_1q7lgbo" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.151.0">
|
||||
<bpmn:process id="Process_1" isExecutable="true">
|
||||
<bpmn:startEvent id="B" name="B" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="Event_083mmcb_di" bpmnElement="B">
|
||||
<dc:Bounds x="102" y="82" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="117" y="125" width="7" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -2,10 +2,12 @@ import Modeler from 'lib/Modeler';
|
|||
import Viewer from 'lib/Viewer';
|
||||
import NavigatedViewer from 'lib/NavigatedViewer';
|
||||
|
||||
import Clipboard from 'diagram-js/lib/features/clipboard/Clipboard';
|
||||
|
||||
import TestContainer from 'mocha-test-container-support';
|
||||
|
||||
import {
|
||||
createEvent
|
||||
createCanvasEvent
|
||||
} from '../util/MockEvents';
|
||||
|
||||
import {
|
||||
|
@ -312,11 +314,11 @@ describe('Modeler', function() {
|
|||
|
||||
// when
|
||||
bendpointMove.start(
|
||||
createEvent(canvas, { x: 0, y: 0 }),
|
||||
createCanvasEvent({ x: 0, y: 0 }),
|
||||
elementRegistry.get('SequenceFlow_1'),
|
||||
1
|
||||
);
|
||||
dragging.move(createEvent(canvas, { x: 200, y: 200 }));
|
||||
dragging.move(createCanvasEvent({ x: 200, y: 200 }));
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -544,6 +546,7 @@ describe('Modeler', function() {
|
|||
|
||||
});
|
||||
|
||||
|
||||
it('should inject mandatory modules', function() {
|
||||
|
||||
// given
|
||||
|
@ -588,6 +591,91 @@ describe('Modeler', function() {
|
|||
});
|
||||
|
||||
|
||||
describe('copy and paste', function() {
|
||||
|
||||
var m1, m2;
|
||||
|
||||
afterEach(function() {
|
||||
if (m1) {
|
||||
m1.destroy();
|
||||
}
|
||||
|
||||
if (m2) {
|
||||
m2.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
it('should share Clipboard', function() {
|
||||
|
||||
var aXML = require('./Modeler.copy-paste.a.bpmn');
|
||||
var bXML = require('./Modeler.copy-paste.b.bpmn');
|
||||
|
||||
var clipboardModule = {
|
||||
'clipboard': [ 'value', new Clipboard() ]
|
||||
};
|
||||
|
||||
m2 = new Modeler({
|
||||
container: container,
|
||||
additionalModules: [
|
||||
clipboardModule
|
||||
]
|
||||
});
|
||||
|
||||
m1 = new Modeler({
|
||||
container: container,
|
||||
additionalModules: [
|
||||
clipboardModule
|
||||
]
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
m1.importXML(aXML),
|
||||
m2.importXML(bXML)
|
||||
]).then(function() {
|
||||
|
||||
// given
|
||||
// copy element <A> from m1
|
||||
m1.invoke(function(selection, elementRegistry, editorActions) {
|
||||
selection.select(elementRegistry.get('A'));
|
||||
|
||||
editorActions.trigger('copy');
|
||||
});
|
||||
|
||||
// TODO(nikku): needed for our canvas utilities to work
|
||||
setBpmnJS(m2);
|
||||
|
||||
m2.invoke(function(dragging, editorActions, elementRegistry) {
|
||||
|
||||
// when
|
||||
// paste element <A> to m2, first try
|
||||
editorActions.trigger('paste');
|
||||
dragging.move(createCanvasEvent({ x: 150, y: 150 }));
|
||||
dragging.move(createCanvasEvent({ x: 170, y: 150 }));
|
||||
|
||||
dragging.end();
|
||||
|
||||
// then
|
||||
expect(elementRegistry.get('A')).to.exist;
|
||||
|
||||
// but when
|
||||
// paste element <A> to m2, second try
|
||||
editorActions.trigger('paste');
|
||||
dragging.move(createCanvasEvent({ x: 150, y: 150 }));
|
||||
dragging.move(createCanvasEvent({ x: 200, y: 150 }));
|
||||
|
||||
dragging.end();
|
||||
|
||||
// TODO(nikku): assert newly created element exists
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should expose Viewer and NavigatedViewer', function() {
|
||||
expect(Modeler.Viewer).to.equal(Viewer);
|
||||
expect(Modeler.NavigatedViewer).to.equal(NavigatedViewer);
|
||||
|
|
Loading…
Reference in New Issue