From 8b0001f7094705465fa8d50dc791a7a04bc0838c Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Tue, 6 Dec 2016 14:51:09 +0100 Subject: [PATCH] test(import): verify data-association in collaboration import * Restructure association import test fixtures * Add data-association + collaboration test cases Related to #638 --- .../AssociationSpec.collaboration.bpmn | 51 ++++++++++ .../AssociationSpec.compensation.bpmn} | 0 .../AssociationSpec.data-association.bpmn} | 8 +- .../AssociationSpec.data-input-output.bpmn} | 8 +- .../elements/AssociationSpec.events.bpmn} | 0 test/spec/import/elements/AssociationSpec.js | 99 ++++++++++++------- .../AssociationSpec.text-annotation.bpmn} | 0 7 files changed, 120 insertions(+), 46 deletions(-) create mode 100644 test/spec/import/elements/AssociationSpec.collaboration.bpmn rename test/{fixtures/bpmn/import/association/compensation.bpmn => spec/import/elements/AssociationSpec.compensation.bpmn} (100%) rename test/{fixtures/bpmn/import/association/data-association.bpmn => spec/import/elements/AssociationSpec.data-association.bpmn} (80%) rename test/{fixtures/bpmn/import/association/data-input-output.bpmn => spec/import/elements/AssociationSpec.data-input-output.bpmn} (80%) rename test/{fixtures/bpmn/import/association/data-association-events.bpmn => spec/import/elements/AssociationSpec.events.bpmn} (100%) rename test/{fixtures/bpmn/import/association/text-annotation.bpmn => spec/import/elements/AssociationSpec.text-annotation.bpmn} (100%) diff --git a/test/spec/import/elements/AssociationSpec.collaboration.bpmn b/test/spec/import/elements/AssociationSpec.collaboration.bpmn new file mode 100644 index 00000000..a253d563 --- /dev/null +++ b/test/spec/import/elements/AssociationSpec.collaboration.bpmn @@ -0,0 +1,51 @@ + + + + + + + + + + + DataObjectReference_1 + + + + + + DataObjectReference_1 + Property_02nwoq1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/fixtures/bpmn/import/association/compensation.bpmn b/test/spec/import/elements/AssociationSpec.compensation.bpmn similarity index 100% rename from test/fixtures/bpmn/import/association/compensation.bpmn rename to test/spec/import/elements/AssociationSpec.compensation.bpmn diff --git a/test/fixtures/bpmn/import/association/data-association.bpmn b/test/spec/import/elements/AssociationSpec.data-association.bpmn similarity index 80% rename from test/fixtures/bpmn/import/association/data-association.bpmn rename to test/spec/import/elements/AssociationSpec.data-association.bpmn index 6be73d9f..4795ce8c 100644 --- a/test/fixtures/bpmn/import/association/data-association.bpmn +++ b/test/spec/import/elements/AssociationSpec.data-association.bpmn @@ -4,12 +4,12 @@ - + DataObjectReference_1 - + DataObjectReference_1 @@ -25,12 +25,12 @@ - + - + diff --git a/test/fixtures/bpmn/import/association/data-input-output.bpmn b/test/spec/import/elements/AssociationSpec.data-input-output.bpmn similarity index 80% rename from test/fixtures/bpmn/import/association/data-input-output.bpmn rename to test/spec/import/elements/AssociationSpec.data-input-output.bpmn index 00e29117..8ed27cec 100644 --- a/test/fixtures/bpmn/import/association/data-input-output.bpmn +++ b/test/spec/import/elements/AssociationSpec.data-input-output.bpmn @@ -6,10 +6,10 @@ - + DataInput_1 - + DataOutput_1 @@ -28,11 +28,11 @@ - + - + diff --git a/test/fixtures/bpmn/import/association/data-association-events.bpmn b/test/spec/import/elements/AssociationSpec.events.bpmn similarity index 100% rename from test/fixtures/bpmn/import/association/data-association-events.bpmn rename to test/spec/import/elements/AssociationSpec.events.bpmn diff --git a/test/spec/import/elements/AssociationSpec.js b/test/spec/import/elements/AssociationSpec.js index 9622e99d..d3d919cf 100644 --- a/test/spec/import/elements/AssociationSpec.js +++ b/test/spec/import/elements/AssociationSpec.js @@ -11,7 +11,7 @@ describe('import - associations', function() { it('connecting task -> text annotation', function(done) { - var xml = require('../../../fixtures/bpmn/import/association/text-annotation.bpmn'); + var xml = require('./AssociationSpec.text-annotation.bpmn'); // given bootstrapViewer(xml)(function(err) { @@ -37,7 +37,7 @@ describe('import - associations', function() { it('connecting boundary -> compensate task', function(done) { - var xml = require('../../../fixtures/bpmn/import/association/compensation.bpmn'); + var xml = require('./AssociationSpec.compensation.bpmn'); // given bootstrapViewer(xml)(function(err) { @@ -65,9 +65,27 @@ describe('import - associations', function() { describe('should import data association', function() { + function expectRendered(elementIds) { + + inject(function(elementRegistry, canvas) { + + elementIds.forEach(function(id) { + + var element = elementRegistry.get(id); + + // then + expect(element).to.exist; + + // data associations always rendered on root + expect(element.parent).to.eql(canvas.getRootElement()); + }); + })(); + } + + it('task -> data object -> task', function(done) { - var xml = require('../../../fixtures/bpmn/import/association/data-association.bpmn'); + var xml = require('./AssociationSpec.data-association.bpmn'); // given bootstrapViewer(xml)(function(err) { @@ -76,26 +94,20 @@ describe('import - associations', function() { return done(err); } - // when - inject(function(elementRegistry) { - - var dataInputAssociation = elementRegistry.get('DataInputAssociation_1'); - var dataOutputAssociation = elementRegistry.get('DataOutputAssociation_1'); - - // then - expect(dataInputAssociation).to.exist; - expect(dataOutputAssociation).to.exist; - - done(); - })(); + // then + expectRendered([ + 'DataInputAssociation', + 'DataOutputAssociation' + ]); + done(); }); }); it('data input -> task -> data output', function(done) { - var xml = require('../../../fixtures/bpmn/import/association/data-input-output.bpmn'); + var xml = require('./AssociationSpec.data-input-output.bpmn'); // given bootstrapViewer(xml)(function(err) { @@ -104,18 +116,35 @@ describe('import - associations', function() { return done(err); } - // when - inject(function(elementRegistry) { + // then + expectRendered([ + 'DataInputAssociation', + 'DataOutputAssociation' + ]); - var dataInputAssociation = elementRegistry.get('DataInputAssociation_1'); - var dataOutputAssociation = elementRegistry.get('DataOutputAssociation_1'); + done(); + }); + }); - // then - expect(dataInputAssociation).to.exist; - expect(dataOutputAssociation).to.exist; - done(); - })(); + it('in collaboration', function(done) { + + var xml = require('./AssociationSpec.collaboration.bpmn'); + + // given + bootstrapViewer(xml)(function(err) { + + if (err) { + return done(err); + } + + // then + expectRendered([ + 'DataInputAssociation', + 'DataOutputAssociation' + ]); + + done(); }); }); @@ -123,7 +152,7 @@ describe('import - associations', function() { it('catch event -> data object -> throw event', function(done) { - var xml = require('../../../fixtures/bpmn/import/association/data-association-events.bpmn'); + var xml = require('./AssociationSpec.events.bpmn'); // given bootstrapViewer(xml)(function(err) { @@ -132,19 +161,13 @@ describe('import - associations', function() { return done(err); } - // when - inject(function(elementRegistry) { - - var dataInputAssociation = elementRegistry.get('DataInputAssociation'); - var dataOutputAssociation = elementRegistry.get('DataOutputAssociation'); - - // then - expect(dataInputAssociation).to.exist; - expect(dataOutputAssociation).to.exist; - - done(); - })(); + // then + expectRendered([ + 'DataInputAssociation', + 'DataOutputAssociation' + ]); + done(); }); }); diff --git a/test/fixtures/bpmn/import/association/text-annotation.bpmn b/test/spec/import/elements/AssociationSpec.text-annotation.bpmn similarity index 100% rename from test/fixtures/bpmn/import/association/text-annotation.bpmn rename to test/spec/import/elements/AssociationSpec.text-annotation.bpmn