From 938164601b2dbcc74082c2646142283251cbc1d0 Mon Sep 17 00:00:00 2001 From: Niklas Kiefer Date: Tue, 29 Mar 2022 09:49:36 +0200 Subject: [PATCH] fix(camunda-platform/ImplementationProps): use correct business object Related to https://github.com/camunda/camunda-modeler/issues/2865 --- .../properties/ImplementationProps.js | 14 +- .../camunda-platform/ImplementationProps.bpmn | 20 +- .../ImplementationProps.spec.js | 577 +++++++++++++++++- 3 files changed, 595 insertions(+), 16 deletions(-) diff --git a/src/provider/camunda-platform/properties/ImplementationProps.js b/src/provider/camunda-platform/properties/ImplementationProps.js index d9dae068e..7c8361ec9 100644 --- a/src/provider/camunda-platform/properties/ImplementationProps.js +++ b/src/provider/camunda-platform/properties/ImplementationProps.js @@ -1,7 +1,3 @@ -import { - getBusinessObject -} from 'bpmn-js/lib/util/ModelUtil'; - import { TextFieldEntry, isTextFieldEntryEdited } from '@bpmn-io/properties-panel'; import { DmnImplementationProps } from './DmnImplementationProps'; @@ -91,7 +87,7 @@ export function ImplementationProps(props) { export function JavaClass(props) { const { element, - businessObject = getBusinessObject(element), + businessObject = getServiceTaskLikeBusinessObject(element), id = 'javaClass' } = props; @@ -126,7 +122,7 @@ export function JavaClass(props) { export function Expression(props) { const { element, - businessObject = getBusinessObject(element), + businessObject = getServiceTaskLikeBusinessObject(element), id = 'expression' } = props; @@ -165,7 +161,7 @@ function ResultVariable(props) { const translate = useService('translate'); const debounce = useService('debounceInput'); - const businessObject = getBusinessObject(element); + const businessObject = getServiceTaskLikeBusinessObject(element); const getValue = () => { return businessObject.get('camunda:resultVariable'); @@ -194,7 +190,7 @@ function ResultVariable(props) { export function DelegateExpression(props) { const { element, - businessObject = getBusinessObject(element), + businessObject = getServiceTaskLikeBusinessObject(element), id = 'delegateExpression' } = props; @@ -233,7 +229,7 @@ function Topic(props) { const translate = useService('translate'); const debounce = useService('debounceInput'); - const businessObject = getBusinessObject(element); + const businessObject = getServiceTaskLikeBusinessObject(element); const getValue = () => { return businessObject.get('camunda:topic'); diff --git a/test/spec/provider/camunda-platform/ImplementationProps.bpmn b/test/spec/provider/camunda-platform/ImplementationProps.bpmn index 0424661f4..14d10c92a 100644 --- a/test/spec/provider/camunda-platform/ImplementationProps.bpmn +++ b/test/spec/provider/camunda-platform/ImplementationProps.bpmn @@ -1,5 +1,5 @@ - + @@ -44,6 +44,12 @@ + + + + + + @@ -103,6 +109,18 @@ + + + + + + + + + + + + diff --git a/test/spec/provider/camunda-platform/ImplementationProps.spec.js b/test/spec/provider/camunda-platform/ImplementationProps.spec.js index 4c15e7616..9cbf332c2 100644 --- a/test/spec/provider/camunda-platform/ImplementationProps.spec.js +++ b/test/spec/provider/camunda-platform/ImplementationProps.spec.js @@ -55,7 +55,7 @@ describe('provider/camunda-platform - ImplementationProps', function() { }; - describe('camunda:ServiceTaskLike#class', function() { + describe('bpmn:ServiceTask#class', function() { beforeEach(function() { container = TestContainer.get(this); @@ -149,7 +149,101 @@ describe('provider/camunda-platform - ImplementationProps', function() { }); - describe('camunda:ServiceTaskLike#expression', function() { + describe('bpmn:MessageEventDefinition#class', function() { + + beforeEach(function() { + container = TestContainer.get(this); + }); + + beforeEach(bootstrapPropertiesPanel(diagramXML, { + modules: testModules, + moddleExtensions, + debounceInput: false + })); + + + it('should NOT display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_External'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=javaClass]', container); + + // then + expect(input).to.not.exist; + })); + + + it('should display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Class'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=javaClass]', container); + + // then + expect(input.value).to.eql( + getServiceTaskLikeBusinessObject(messageEvent).get('camunda:class') + ); + })); + + + it('should update', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Class'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=javaClass]', container); + changeInput(input, 'newValue'); + + // then + expect(getServiceTaskLikeBusinessObject(messageEvent).get('camunda:class')).to.eql('newValue'); + })); + + + it('should update on external change', + inject(async function(elementRegistry, selection, commandStack) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Class'); + + const originalValue = getServiceTaskLikeBusinessObject(messageEvent).get('camunda:class'); + + await act(() => { + selection.select(messageEvent); + }); + const input = domQuery('input[name=javaClass]', container); + changeInput(input, 'newValue'); + + // when + await act(() => { + commandStack.undo(); + }); + + // then + expect(input.value).to.eql(originalValue); + }) + ); + + }); + + + describe('bpmn:ServiceTask#expression', function() { beforeEach(function() { container = TestContainer.get(this); @@ -243,7 +337,101 @@ describe('provider/camunda-platform - ImplementationProps', function() { }); - describe('camunda:ServiceTaskLike#resultVariable', function() { + describe('bpmn:MessageEventDefinition#expression', function() { + + beforeEach(function() { + container = TestContainer.get(this); + }); + + beforeEach(bootstrapPropertiesPanel(diagramXML, { + modules: testModules, + moddleExtensions, + debounceInput: false + })); + + + it('should NOT display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Class'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=expression]', container); + + // then + expect(input).to.not.exist; + })); + + + it('should display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Expression'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=expression]', container); + + // then + expect(input.value).to.eql( + getServiceTaskLikeBusinessObject(messageEvent).get('camunda:expression') + ); + })); + + + it('should update', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Expression'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=expression]', container); + changeInput(input, 'newValue'); + + // then + expect(getServiceTaskLikeBusinessObject(messageEvent).get('camunda:expression')).to.eql('newValue'); + })); + + + it('should update on external change', + inject(async function(elementRegistry, selection, commandStack) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Expression'); + + const originalValue = getServiceTaskLikeBusinessObject(messageEvent).get('camunda:expression'); + + await act(() => { + selection.select(messageEvent); + }); + const input = domQuery('input[name=expression]', container); + changeInput(input, 'newValue'); + + // when + await act(() => { + commandStack.undo(); + }); + + // then + expect(input.value).to.eql(originalValue); + }) + ); + + }); + + + describe('bpmn:ServiceTaskL#resultVariable', function() { beforeEach(function() { container = TestContainer.get(this); @@ -337,7 +525,101 @@ describe('provider/camunda-platform - ImplementationProps', function() { }); - describe('camunda:ServiceTaskLike#delegateExpression', function() { + describe('bpmn:MessageEventDefinition#resultVariable', function() { + + beforeEach(function() { + container = TestContainer.get(this); + }); + + beforeEach(bootstrapPropertiesPanel(diagramXML, { + modules: testModules, + moddleExtensions, + debounceInput: false + })); + + + it('should NOT display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Class'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=expressionResultVariable]', container); + + // then + expect(input).to.not.exist; + })); + + + it('should display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Expression'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=expressionResultVariable]', container); + + // then + expect(input.value).to.eql( + getServiceTaskLikeBusinessObject(messageEvent).get('camunda:resultVariable') + ); + })); + + + it('should update', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Expression'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=expressionResultVariable]', container); + changeInput(input, 'newValue'); + + // then + expect(getServiceTaskLikeBusinessObject(messageEvent).get('camunda:resultVariable')).to.eql('newValue'); + })); + + + it('should update on external change', + inject(async function(elementRegistry, selection, commandStack) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Expression'); + + const originalValue = getServiceTaskLikeBusinessObject(messageEvent).get('camunda:resultVariable'); + + await act(() => { + selection.select(messageEvent); + }); + const input = domQuery('input[name=expressionResultVariable]', container); + changeInput(input, 'newValue'); + + // when + await act(() => { + commandStack.undo(); + }); + + // then + expect(input.value).to.eql(originalValue); + }) + ); + + }); + + + describe('bpmn:ServiceTask#delegateExpression', function() { beforeEach(function() { container = TestContainer.get(this); @@ -433,7 +715,103 @@ describe('provider/camunda-platform - ImplementationProps', function() { }); - describe('camunda:ServiceTaskLike#topic', function() { + describe('bpmn:MessageEventDefinition#delegateExpression', function() { + + beforeEach(function() { + container = TestContainer.get(this); + }); + + beforeEach(bootstrapPropertiesPanel(diagramXML, { + modules: testModules, + moddleExtensions, + debounceInput: false + })); + + + it('should NOT display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Expression'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=delegateExpression]', container); + + // then + expect(input).to.not.exist; + })); + + + it('should display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_DelegateExpression'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=delegateExpression]', container); + + // then + expect(input.value).to.eql( + getServiceTaskLikeBusinessObject(messageEvent).get('camunda:delegateExpression') + ); + })); + + + it('should update', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_DelegateExpression'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=delegateExpression]', container); + changeInput(input, 'newValue'); + + // then + expect( + getServiceTaskLikeBusinessObject(messageEvent).get('camunda:delegateExpression') + ).to.eql('newValue'); + })); + + + it('should update on external change', + inject(async function(elementRegistry, selection, commandStack) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_DelegateExpression'); + + const originalValue = getServiceTaskLikeBusinessObject(messageEvent).get('camunda:delegateExpression'); + + await act(() => { + selection.select(messageEvent); + }); + const input = domQuery('input[name=delegateExpression]', container); + changeInput(input, 'newValue'); + + // when + await act(() => { + commandStack.undo(); + }); + + // then + expect(input.value).to.eql(originalValue); + }) + ); + + }); + + + describe('bpmn:ServiceTas#topic', function() { beforeEach(function() { container = TestContainer.get(this); @@ -527,7 +905,101 @@ describe('provider/camunda-platform - ImplementationProps', function() { }); - describe('camunda:ServiceTaskLike#connectorId', function() { + describe('bpmn:MessageEventDefinition#topic', function() { + + beforeEach(function() { + container = TestContainer.get(this); + }); + + beforeEach(bootstrapPropertiesPanel(diagramXML, { + modules: testModules, + moddleExtensions, + debounceInput: false + })); + + + it('should NOT display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_DelegateExpression'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=externalTopic]', container); + + // then + expect(input).to.not.exist; + })); + + + it('should display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_External'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=externalTopic]', container); + + // then + expect(input.value).to.eql( + getServiceTaskLikeBusinessObject(messageEvent).get('camunda:topic') + ); + })); + + + it('should update', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_External'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=externalTopic]', container); + changeInput(input, 'newValue'); + + // then + expect(getServiceTaskLikeBusinessObject(messageEvent).get('camunda:topic')).to.eql('newValue'); + })); + + + it('should update on external change', + inject(async function(elementRegistry, selection, commandStack) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_External'); + + const originalValue = getServiceTaskLikeBusinessObject(messageEvent).get('camunda:topic'); + + await act(() => { + selection.select(messageEvent); + }); + const input = domQuery('input[name=externalTopic]', container); + changeInput(input, 'newValue'); + + // when + await act(() => { + commandStack.undo(); + }); + + // then + expect(input.value).to.eql(originalValue); + }) + ); + + }); + + + describe('bpmn:ServiceTask#connectorId', function() { beforeEach(function() { container = TestContainer.get(this); @@ -618,6 +1090,99 @@ describe('provider/camunda-platform - ImplementationProps', function() { }); + + describe('bpmn:MessageEventDefinition#connectorId', function() { + + beforeEach(function() { + container = TestContainer.get(this); + }); + + beforeEach(bootstrapPropertiesPanel(diagramXML, { + modules: testModules, + moddleExtensions, + debounceInput: false + })); + + + it('should NOT display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Class'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=connectorId]', container); + + // then + expect(input).to.not.exist; + })); + + + it('should display', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Connector'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=connectorId]', container); + + // then + expect(input.value).to.eql(getConnector(messageEvent).get('camunda:connectorId')); + })); + + + it('should update', inject(async function(elementRegistry, selection) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Connector'); + + await act(() => { + selection.select(messageEvent); + }); + + // when + const input = domQuery('input[name=connectorId]', container); + changeInput(input, 'newValue'); + + // then + expect(getConnector(messageEvent).get('camunda:connectorId')).to.eql('newValue'); + })); + + + it('should update on external change', + inject(async function(elementRegistry, selection, commandStack) { + + // given + const messageEvent = elementRegistry.get('MessageEndEvent_Connector'); + + const originalValue = getConnector(messageEvent).get('camunda:connectorId'); + + await act(() => { + selection.select(messageEvent); + }); + const input = domQuery('input[name=connectorId]', container); + changeInput(input, 'newValue'); + + // when + await act(() => { + commandStack.undo(); + }); + + // then + expect(input.value).to.eql(originalValue); + }) + ); + + }); + + });