2014-05-21 14:23:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
var Viewer = require('../../../../../lib/Viewer');
|
|
|
|
|
|
|
|
var Matchers = require('../../../Matchers');
|
|
|
|
|
|
|
|
|
|
|
|
describe('import - collapsed container', function() {
|
|
|
|
|
|
|
|
beforeEach(Matchers.add);
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
var loadedXml;
|
|
|
|
|
2014-05-21 14:23:52 +00:00
|
|
|
var container, renderer;
|
|
|
|
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
function ensureLoaded(xml, done) {
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
if (xml !== loadedXml) {
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
// create container
|
|
|
|
container = document.createElement('div');
|
|
|
|
document.getElementsByTagName('body')[0].appendChild(container);
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
renderer = new Viewer(container);
|
2014-05-21 14:23:52 +00:00
|
|
|
|
|
|
|
renderer.importXML(xml, function(err) {
|
|
|
|
if (err) {
|
|
|
|
done(err);
|
|
|
|
} else {
|
2014-05-22 08:51:23 +00:00
|
|
|
loadedXml = xml;
|
2014-05-21 14:23:52 +00:00
|
|
|
done();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
done();
|
|
|
|
}
|
2014-05-22 08:51:23 +00:00
|
|
|
}
|
2014-05-21 14:23:52 +00:00
|
|
|
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
describe('in process', function() {
|
2014-05-21 14:23:52 +00:00
|
|
|
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
beforeEach(function(done) {
|
|
|
|
var xml = fs.readFileSync('test/fixtures/bpmn/import/collapsed.bpmn', 'utf8');
|
|
|
|
ensureLoaded(xml, done);
|
|
|
|
});
|
2014-05-21 14:23:52 +00:00
|
|
|
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
it('should import collapsed subProcess', function() {
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var collapsedShape = elementRegistry.getById('SubProcess_1');
|
|
|
|
var childShape = elementRegistry.getById('IntermediateCatchEvent_1');
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
expect(collapsedShape.collapsed).toBe(true);
|
|
|
|
expect(childShape.hidden).toBe(true);
|
|
|
|
});
|
2014-05-21 14:23:52 +00:00
|
|
|
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
it('should import collapsed transaction', function() {
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var collapsedShape = elementRegistry.getById('Transaction_1');
|
|
|
|
var childShape = elementRegistry.getById('UserTask_1');
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
expect(collapsedShape.collapsed).toBe(true);
|
|
|
|
expect(childShape.hidden).toBe(true);
|
|
|
|
});
|
2014-05-21 14:23:52 +00:00
|
|
|
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
it('should import collapsed adhocSubProcess', function() {
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var collapsedShape = elementRegistry.getById('AdHocSubProcess_1');
|
|
|
|
var childShape = elementRegistry.getById('StartEvent_1');
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
expect(collapsedShape.collapsed).toBe(true);
|
|
|
|
expect(childShape.hidden).toBe(true);
|
|
|
|
});
|
2014-05-21 14:23:52 +00:00
|
|
|
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
it('should import collapsed with nested elements', function() {
|
|
|
|
|
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var collapsedShape = elementRegistry.getById('SubProcess_4');
|
|
|
|
var childShape = elementRegistry.getById('SubProcess_5');
|
|
|
|
var nestedChildShape = elementRegistry.getById('Task_3');
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
expect(collapsedShape.collapsed).toBe(true);
|
|
|
|
expect(childShape.hidden).toBe(true);
|
|
|
|
expect(nestedChildShape.hidden).toBe(true);
|
2014-06-17 09:18:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should import collapsed with nested elements', function() {
|
|
|
|
|
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
|
|
|
|
|
|
|
var hiddenEventShape = elementRegistry.getById('StartEvent_2');
|
|
|
|
expect(hiddenEventShape.label.hidden).toBe(true);
|
|
|
|
|
|
|
|
var hiddenDataShape = elementRegistry.getById('DataObjectReference_1');
|
|
|
|
expect(hiddenDataShape.label.hidden).toBe(true);
|
2014-05-22 08:51:23 +00:00
|
|
|
});
|
2014-05-21 14:23:52 +00:00
|
|
|
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
it('should import expanded subProcess', function() {
|
|
|
|
|
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var expandedShape = elementRegistry.getById('SubProcess_3');
|
|
|
|
var childShape = elementRegistry.getById('Task_2');
|
2014-05-22 08:51:23 +00:00
|
|
|
|
|
|
|
expect(expandedShape.collapsed).toBe(false);
|
|
|
|
expect(childShape.hidden).toBe(false);
|
|
|
|
});
|
|
|
|
|
2014-05-21 14:23:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-05-22 08:51:23 +00:00
|
|
|
describe('in collaboration', function() {
|
|
|
|
|
|
|
|
beforeEach(function(done) {
|
|
|
|
var xml = fs.readFileSync('test/fixtures/bpmn/import/collapsed-collaboration.bpmn', 'utf8');
|
|
|
|
ensureLoaded(xml, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should import collapsed subProcess in pool', function() {
|
|
|
|
|
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var expandedShape = elementRegistry.getById('SubProcess_1');
|
|
|
|
var childShape = elementRegistry.getById('Task_1');
|
2014-05-22 08:51:23 +00:00
|
|
|
|
|
|
|
expect(expandedShape.collapsed).toBe(true);
|
|
|
|
expect(childShape.hidden).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should import expanded subProcess in pool', function() {
|
|
|
|
|
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var expandedShape = elementRegistry.getById('SubProcess_2');
|
|
|
|
var childShape = elementRegistry.getById('StartEvent_1');
|
2014-05-22 08:51:23 +00:00
|
|
|
|
|
|
|
expect(expandedShape.collapsed).toBe(false);
|
|
|
|
expect(childShape.hidden).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should import collapsed subProcess in lane', function() {
|
|
|
|
|
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var expandedShape = elementRegistry.getById('SubProcess_4');
|
|
|
|
var childShape = elementRegistry.getById('Task_2');
|
2014-05-22 08:51:23 +00:00
|
|
|
|
|
|
|
expect(expandedShape.collapsed).toBe(true);
|
|
|
|
expect(childShape.hidden).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should import expanded subProcess in lane', function() {
|
|
|
|
|
|
|
|
var elementRegistry = renderer.get('elementRegistry');
|
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var expandedShape = elementRegistry.getById('SubProcess_3');
|
|
|
|
var childShape = elementRegistry.getById('StartEvent_2');
|
2014-05-22 08:51:23 +00:00
|
|
|
|
|
|
|
expect(expandedShape.collapsed).toBe(false);
|
|
|
|
expect(childShape.hidden).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2014-05-21 14:23:52 +00:00
|
|
|
});
|