From 94b8f9be14f461cdc2fa467694f4cc216fd6808a Mon Sep 17 00:00:00 2001 From: Philipp Fromme Date: Mon, 26 Aug 2024 17:21:51 +0200 Subject: [PATCH] feat: support `zeebe:VersionTag` and `zeebe:versionTag` errors Related to https://github.com/camunda/camunda-modeler/issues/4480 --- lib/utils/error-messages.js | 24 ++- lib/utils/properties-panel.js | 8 + test/spec/utils/error-messages.spec.js | 189 ++++++++++++++++++++++- test/spec/utils/properties-panel.spec.js | 175 ++++++++++++++++++++- 4 files changed, 390 insertions(+), 6 deletions(-) diff --git a/lib/utils/error-messages.js b/lib/utils/error-messages.js index 6693247..ca35010 100644 --- a/lib/utils/error-messages.js +++ b/lib/utils/error-messages.js @@ -336,6 +336,10 @@ function getExtensionElementNotAllowedErrorMessage(report, executionPlatform, ex return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with `, executionPlatform, executionPlatformVersion, allowedVersion); } + if (is(node, 'bpmn:Process') && is(extensionElement, 'zeebe:VersionTag')) { + return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with `, executionPlatform, executionPlatformVersion, allowedVersion); + } + return message; } @@ -438,7 +442,7 @@ function getPropertyNotAllowedErrorMessage(report, executionPlatform, executionP } if (is(node, 'zeebe:AssignmentDefinition') && property === 'candidateUsers') { - return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with defined `, executionPlatform, executionPlatformVersion, allowedVersion); + return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with `, executionPlatform, executionPlatformVersion, allowedVersion); } if (is(node, 'bpmn:SequenceFlow') && property === 'conditionExpression') { @@ -453,6 +457,14 @@ function getPropertyNotAllowedErrorMessage(report, executionPlatform, executionP return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with
`, executionPlatform, executionPlatformVersion, allowedVersion); } + if (isAny(node, [ + 'zeebe:CalledDecision', + 'zeebe:CalledElement', + 'zeebe:FormDefinition' + ]) && property === 'versionTag') { + return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with `, executionPlatform, executionPlatformVersion, allowedVersion); + } + return message; } @@ -723,7 +735,15 @@ function getPropertyValueNotAllowedErrorMessage(report, executionPlatform, execu 'zeebe:CalledElement', 'zeebe:FormDefinition' ]) && property === 'bindingType') { - return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with `, executionPlatform, executionPlatformVersion, allowedVersion); + const bindingType = node.get('bindingType'); + + let bindingTypeString = bindingType; + + if (bindingType === 'versionTag') { + bindingTypeString = 'version tag'; + } + + return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with `, executionPlatform, executionPlatformVersion, allowedVersion); } return message; diff --git a/lib/utils/properties-panel.js b/lib/utils/properties-panel.js index e0605ca..1a5c94a 100644 --- a/lib/utils/properties-panel.js +++ b/lib/utils/properties-panel.js @@ -344,6 +344,10 @@ export function getEntryIds(report) { return [ 'bindingType' ]; } + if (isPropertyError(data, 'versionTag') || isExtensionElementNotAllowedError(data, 'zeebe:VersionTag')) { + return [ 'versionTag' ]; + } + return []; } @@ -576,6 +580,10 @@ export function getErrorMessage(id, report) { if (id === 'bindingType') { return getNotSupportedMessage('', allowedVersion); } + + if (id === 'versionTag') { + return getNotSupportedMessage('', allowedVersion); + } } function isExtensionElementNotAllowedError(data, extensionElement, type) { diff --git a/test/spec/utils/error-messages.spec.js b/test/spec/utils/error-messages.spec.js index 71ae4d6..aaa7bb9 100644 --- a/test/spec/utils/error-messages.spec.js +++ b/test/spec/utils/error-messages.spec.js @@ -500,6 +500,33 @@ describe('utils/error-messages', function() { // then expect(errorMessage).to.equal('A with is only supported by Camunda 8.6 or newer'); }); + + + it('should adjust (zeebe:VersionTag)', async function() { + + // given + const executionPlatformVersion = '8.5'; + + const node = createElement('bpmn:Process', { + isExecutable: true, + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:VersionTag') + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag'); + + const report = await getLintError(node, rule, { version: executionPlatformVersion }); + + // when + const errorMessage = getErrorMessage(report, 'Camunda Cloud', executionPlatformVersion); + + // then + expect(errorMessage).to.equal('A with is only supported by Camunda 8.6 or newer'); + }); + }); @@ -777,7 +804,7 @@ describe('utils/error-messages', function() { const errorMessage = getErrorMessage(report, 'Camunda Cloud', '1.0'); // then - expect(errorMessage).to.equal('A with defined is only supported by Camunda 8.2 or newer'); + expect(errorMessage).to.equal('A with is only supported by Camunda 8.2 or newer'); }); @@ -836,6 +863,85 @@ describe('utils/error-messages', function() { expect(errorMessage).to.equal('A with is only supported by Camunda 8.3 or newer'); }); + + describe('version tag', function() { + + it('should adjust (business rule task)', async function() { + + // given + const node = createElement('bpmn:BusinessRuleTask', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:CalledDecision', { + versionTag: 'v1.0.0' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag'); + + const report = await getLintError(node, rule); + + // when + const errorMessage = getErrorMessage(report, 'Camunda Cloud', '1.0', 'desktop'); + + // then + expect(errorMessage).to.equal('A with is only supported by Camunda 8.6 or newer'); + }); + + + it('should adjust (call activity)', async function() { + + // given + const node = createElement('bpmn:CallActivity', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:CalledElement', { + versionTag: 'v1.0.0' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag'); + + const report = await getLintError(node, rule); + + // when + const errorMessage = getErrorMessage(report, 'Camunda Cloud', '1.0', 'desktop'); + + // then + expect(errorMessage).to.equal('A with is only supported by Camunda 8.6 or newer'); + }); + + + it('should adjust (user task)', async function() { + + // given + const node = createElement('bpmn:UserTask', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:FormDefinition', { + versionTag: 'v1.0.0' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag'); + + const report = await getLintError(node, rule); + + // when + const errorMessage = getErrorMessage(report, 'Camunda Cloud', '1.0', 'desktop'); + + // then + expect(errorMessage).to.equal('A with is only supported by Camunda 8.6 or newer'); + }); + + }); + }); @@ -1917,7 +2023,7 @@ describe('utils/error-messages', function() { }); - it('should adjust (binding type set to false)', async function() { + it('should adjust (binding type set to deployment)', async function() { // given const node = createElement('bpmn:CallActivity', { @@ -1941,6 +2047,85 @@ describe('utils/error-messages', function() { expect(errorMessage).to.equal('A with is only supported by Camunda 8.6 or newer'); }); + + describe('binding type set to version tag', function() { + + it('should adjust (business rule task)', async function() { + + // given + const node = createElement('bpmn:BusinessRuleTask', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:CalledDecision', { + bindingType: 'versionTag' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-binding-type'); + + const report = await getLintError(node, rule); + + // when + const errorMessage = getErrorMessage(report, 'Camunda Cloud', '1.0'); + + // then + expect(errorMessage).to.equal('A with is only supported by Camunda 8.6 or newer'); + }); + + + it('should adjust (call activity)', async function() { + + // given + const node = createElement('bpmn:CallActivity', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:CalledElement', { + bindingType: 'versionTag' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-binding-type'); + + const report = await getLintError(node, rule); + + // when + const errorMessage = getErrorMessage(report, 'Camunda Cloud', '1.0'); + + // then + expect(errorMessage).to.equal('A with is only supported by Camunda 8.6 or newer'); + }); + + + it('should adjust (user task)', async function() { + + // given + const node = createElement('bpmn:UserTask', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:FormDefinition', { + bindingType: 'versionTag' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-binding-type'); + + const report = await getLintError(node, rule); + + // when + const errorMessage = getErrorMessage(report, 'Camunda Cloud', '1.0'); + + // then + expect(errorMessage).to.equal('A with is only supported by Camunda 8.6 or newer'); + }); + + }); + }); diff --git a/test/spec/utils/properties-panel.spec.js b/test/spec/utils/properties-panel.spec.js index 8a93f78..c69095b 100644 --- a/test/spec/utils/properties-panel.spec.js +++ b/test/spec/utils/properties-panel.spec.js @@ -1938,7 +1938,7 @@ describe('utils/properties-panel', function() { }); - it('should support `waitForCompletion`', async function() { + it('intermediate throw event - Wait for completion', async function() { // given const node = createElement('bpmn:IntermediateThrowEvent', { @@ -1963,7 +1963,7 @@ describe('utils/properties-panel', function() { }); - describe('execution listener', async function() { + describe('Execution listeners', async function() { it('should mark type as required', async function() { @@ -2039,6 +2039,177 @@ describe('utils/properties-panel', function() { }); }); + + + describe('Binding', function() { + + it('business rule task', async function() { + + // given + const node = createElement('bpmn:BusinessRuleTask', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:CalledDecision', { + bindingType: 'deployment' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-binding-type'); + + const report = await getLintError(node, rule); + + // when + const entryIds = getEntryIds(report); + + // then + expect(entryIds).to.eql([ 'bindingType' ]); + + expectErrorMessage(entryIds[ 0 ], 'Only supported by Camunda 8.6 or newer.', report); + }); + + + it('call activity', async function() { + + // given + const node = createElement('bpmn:CallActivity', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:CalledElement', { + bindingType: 'deployment' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-binding-type'); + + const report = await getLintError(node, rule); + + // when + const entryIds = getEntryIds(report); + + // then + expect(entryIds).to.eql([ 'bindingType' ]); + + expectErrorMessage(entryIds[ 0 ], 'Only supported by Camunda 8.6 or newer.', report); + }); + + + it('user task', async function() { + + // given + const node = createElement('bpmn:UserTask', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:FormDefinition', { + bindingType: 'deployment' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-binding-type'); + + const report = await getLintError(node, rule); + + // when + const entryIds = getEntryIds(report); + + // then + expect(entryIds).to.eql([ 'bindingType' ]); + + expectErrorMessage(entryIds[ 0 ], 'Only supported by Camunda 8.6 or newer.', report); + }); + + }); + + + describe('Version tag', function() { + + it('business rule task', async function() { + + // given + const node = createElement('bpmn:BusinessRuleTask', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:CalledDecision', { + versionTag: 'v1.0.0' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag'); + + const report = await getLintError(node, rule); + + // when + const entryIds = getEntryIds(report); + + // then + expect(entryIds).to.eql([ 'versionTag' ]); + + expectErrorMessage(entryIds[ 0 ], 'Only supported by Camunda 8.6 or newer.', report); + }); + + + it('call activity', async function() { + + // given + const node = createElement('bpmn:CallActivity', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:CalledElement', { + versionTag: 'v1.0.0' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag'); + + const report = await getLintError(node, rule); + + // when + const entryIds = getEntryIds(report); + + // then + expect(entryIds).to.eql([ 'versionTag' ]); + + expectErrorMessage(entryIds[ 0 ], 'Only supported by Camunda 8.6 or newer.', report); + }); + + + it('user task', async function() { + + // given + const node = createElement('bpmn:UserTask', { + extensionElements: createElement('bpmn:ExtensionElements', { + values: [ + createElement('zeebe:FormDefinition', { + versionTag: 'v1.0.0' + }) + ] + }) + }); + + const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag'); + + const report = await getLintError(node, rule); + + // when + const entryIds = getEntryIds(report); + + // then + expect(entryIds).to.eql([ 'versionTag' ]); + + expectErrorMessage(entryIds[ 0 ], 'Only supported by Camunda 8.6 or newer.', report); + }); + + }); + });