From 650c13eb2067fb15d78ca94bb19803bef8af5b80 Mon Sep 17 00:00:00 2001 From: burnettk Date: Fri, 28 Oct 2022 13:52:08 -0400 Subject: [PATCH] Squashed 'bpmn-js-spiffworkflow/' changes from 9c0da0240..4ed985f4a 4ed985f4a kill console fdbad7565 Forgot a test. a185cce56 * For Correlation Properties, should use messagePath and not formalExpression for the name. * When all data input and outputs are removed, the ioSpecification should be removed as well * If an ioSpecification is present, then there shoud be a at least one dataInputset and at least one dataoutputset. git-subtree-dir: bpmn-js-spiffworkflow git-subtree-split: 4ed985f4a2e6ce024928a85d07063b8e69c41e8d --- .../InputOutput/IoInterceptor.js | 12 +++- .../MessageCorrelationPropertiesArray.js | 2 +- test/spec/IOInterceptorSpec.js | 63 +++++++++++++++++++ test/spec/bpmn/basic_message.bpmn | 6 +- test/spec/bpmn/collaboration.bpmn | 12 ++-- test/spec/bpmn/simple_collab.bpmn | 18 +++--- 6 files changed, 92 insertions(+), 21 deletions(-) create mode 100644 test/spec/IOInterceptorSpec.js diff --git a/app/spiffworkflow/InputOutput/IoInterceptor.js b/app/spiffworkflow/InputOutput/IoInterceptor.js index 05c9ea94..6ec92c24 100644 --- a/app/spiffworkflow/InputOutput/IoInterceptor.js +++ b/app/spiffworkflow/InputOutput/IoInterceptor.js @@ -38,6 +38,7 @@ export default class IoInterceptor extends CommandInterceptor { di.bpmnElement = dataIO; di.id = dataIO.id + 'DI'; bpmnUpdater.updateBounds(context.shape); + if (type == 'bpmn:DataInput') { collectionAdd(ioSpecification.get('dataInputs'), dataIO); } else { @@ -60,6 +61,9 @@ export default class IoInterceptor extends CommandInterceptor { if (context.shape.di.$parent) { collectionRemove(context.shape.di.$parent.planeElement, context.shape.di); } + if (ioSpec.dataInputs.length === 0 && ioSpec.dataOutputs.length === 0) { + process.ioSpecification = null; + } } }); @@ -88,13 +92,15 @@ function assureIOSpecificationExists(process, bpmnFactory) { let ioSpecification = process.get('ioSpecification'); if (!ioSpecification) { + let inputSet = bpmnFactory.create('bpmn:InputSet'); + let outputSet = bpmnFactory.create('bpmn:OutputSet'); // Create the BPMN ioSpecification = bpmnFactory.create('bpmn:InputOutputSpecification', { dataInputs: [], - inputSets: [], + inputSets: [inputSet], dataOutputs: [], - outputSets: [] + outputSets: [outputSet], }); ioSpecification.$parent = process; process.ioSpecification = ioSpecification; @@ -102,5 +108,7 @@ function assureIOSpecificationExists(process, bpmnFactory) { return ioSpecification; } + + IoInterceptor.$inject = [ 'eventBus', 'bpmnFactory', 'bpmnUpdater' ]; diff --git a/app/spiffworkflow/messages/propertiesPanel/MessageCorrelationPropertiesArray.js b/app/spiffworkflow/messages/propertiesPanel/MessageCorrelationPropertiesArray.js index bd62c693..68a79379 100644 --- a/app/spiffworkflow/messages/propertiesPanel/MessageCorrelationPropertiesArray.js +++ b/app/spiffworkflow/messages/propertiesPanel/MessageCorrelationPropertiesArray.js @@ -82,7 +82,7 @@ export function MessageCorrelationPropertiesArray(props) { 'bpmn:CorrelationPropertyRetrievalExpression' ); const messageRefElement = getMessageRefElement(element); - const newFormalExpression = moddle.create('bpmn:FormalExpression'); + const newFormalExpression = moddle.create('bpmn:messagePath'); newFormalExpression.body = ''; newRetrievalExpressionElement.messageRef = messageRefElement; diff --git a/test/spec/IOInterceptorSpec.js b/test/spec/IOInterceptorSpec.js new file mode 100644 index 00000000..3701d7f7 --- /dev/null +++ b/test/spec/IOInterceptorSpec.js @@ -0,0 +1,63 @@ +import { bootstrapPropertiesPanel } from './helpers'; +import dataObjectInterceptor from '../../app/spiffworkflow/DataObject'; +import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel'; +import { + inject, +} from 'bpmn-js/test/helper'; +import { findDataObjects } from '../../app/spiffworkflow/DataObject/DataObjectHelpers'; +import IoInterceptor from '../../app/spiffworkflow/InputOutput/IoInterceptor'; +import InputOutput from '../../app/spiffworkflow/InputOutput'; + +describe('Input/Output Interceptor', function() { + + let xml = require('./bpmn/empty_diagram.bpmn').default; + + beforeEach(bootstrapPropertiesPanel(xml, { + debounceInput: false, + additionalModules: [ + InputOutput, + BpmnPropertiesPanelModule, + BpmnPropertiesProviderModule, + ] + })); + + it('New Data Input should create an IOSpecification with a single dataInput object', inject(function(canvas, modeling) { + + expect(canvas.getRootElement().businessObject.ioSpecification).to.be.undefined; + + // IF - a new dataObjectReference is created + let rootShape = canvas.getRootElement(); + const dataInput = modeling.createShape({ type: 'bpmn:DataInput' }, + { x: 220, y: 220 }, rootShape); + + // THEN - the process should now have an IO Specification + const iospec = canvas.getRootElement().businessObject.ioSpecification; + expect(iospec).to.not.be.null; + expect(iospec.dataInputs.length).to.equal(1) + })); + + + it('IOSpecification always contain input sets and output sets if they exist at all.', inject(function(canvas, modeling) { + + expect(canvas.getRootElement().businessObject.ioSpecification).to.be.undefined; + + // IF - a new dataObjectReference is created + let rootShape = canvas.getRootElement(); + const dataInput = modeling.createShape({type: 'bpmn:DataInput'}, + {x: 220, y: 220}, rootShape); + + // THEN - there are inputSets and outputSets + const iospec = canvas.getRootElement().businessObject.ioSpecification; + expect(iospec.inputSets).to.not.be.null; + expect(iospec.outputSets).to.not.be.null; + })); + + it('After removing all input sets, the ioSpecification should be null.', inject(function(canvas, modeling) { + // IF - a new dataObjectReference is created and then deleted. + let rootShape = canvas.getRootElement(); + const dataInput = modeling.createShape({type: 'bpmn:DataInput'}, + {x: 220, y: 220}, rootShape); + modeling.removeShape(dataInput) + expect(canvas.getRootElement().businessObject.ioSpecification).to.be.null; + })); +}); diff --git a/test/spec/bpmn/basic_message.bpmn b/test/spec/bpmn/basic_message.bpmn index 08c6145c..3f141643 100644 --- a/test/spec/bpmn/basic_message.bpmn +++ b/test/spec/bpmn/basic_message.bpmn @@ -14,10 +14,10 @@ - to + to - from.name + from.name @@ -68,7 +68,7 @@ - new + new diff --git a/test/spec/bpmn/collaboration.bpmn b/test/spec/bpmn/collaboration.bpmn index fbc941a5..a193fd3a 100644 --- a/test/spec/bpmn/collaboration.bpmn +++ b/test/spec/bpmn/collaboration.bpmn @@ -26,26 +26,26 @@ - lover.instrument + lover.instrument - from.instrument + from.instrument - lover.name + lover.name - from.name + from.name - heartbreaker + heartbreaker - to.name + to.name diff --git a/test/spec/bpmn/simple_collab.bpmn b/test/spec/bpmn/simple_collab.bpmn index c4fb1463..aae67e99 100644 --- a/test/spec/bpmn/simple_collab.bpmn +++ b/test/spec/bpmn/simple_collab.bpmn @@ -46,46 +46,46 @@ - invoice.invoice_id + invoice.invoice_id - payment.invoice_id + payment.invoice_id - invoice.total + invoice.total - payment.invoice_amount + payment.invoice_amount - invoice.date + invoice.date - payment.invoice_date + payment.invoice_date - payment.date + payment.date - payment.total + payment.total - payment.id + payment.id