Skip to content

Commit

Permalink
feat: support zeebe:VersionTag and zeebe:versionTag errors
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Aug 27, 2024
1 parent bfeb12f commit 94b8f9b
Show file tree
Hide file tree
Showing 4 changed files with 390 additions and 6 deletions.
24 changes: 22 additions & 2 deletions lib/utils/error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ function getExtensionElementNotAllowedErrorMessage(report, executionPlatform, ex
return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with <Execution listeners>`, executionPlatform, executionPlatformVersion, allowedVersion);
}

if (is(node, 'bpmn:Process') && is(extensionElement, 'zeebe:VersionTag')) {
return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with <Version tag>`, executionPlatform, executionPlatformVersion, allowedVersion);
}

return message;
}

Expand Down Expand Up @@ -438,7 +442,7 @@ function getPropertyNotAllowedErrorMessage(report, executionPlatform, executionP
}

if (is(node, 'zeebe:AssignmentDefinition') && property === 'candidateUsers') {
return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with defined <Candidate users>`, executionPlatform, executionPlatformVersion, allowedVersion);
return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with <Candidate users>`, executionPlatform, executionPlatformVersion, allowedVersion);
}

if (is(node, 'bpmn:SequenceFlow') && property === 'conditionExpression') {
Expand All @@ -453,6 +457,14 @@ function getPropertyNotAllowedErrorMessage(report, executionPlatform, executionP
return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with <Form type: Camunda form (linked)>`, executionPlatform, executionPlatformVersion, allowedVersion);
}

if (isAny(node, [
'zeebe:CalledDecision',
'zeebe:CalledElement',
'zeebe:FormDefinition'
]) && property === 'versionTag') {
return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with <Version tag>`, executionPlatform, executionPlatformVersion, allowedVersion);
}

return message;
}

Expand Down Expand Up @@ -723,7 +735,15 @@ function getPropertyValueNotAllowedErrorMessage(report, executionPlatform, execu
'zeebe:CalledElement',
'zeebe:FormDefinition'
]) && property === 'bindingType') {
return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with <Binding: deployment>`, executionPlatform, executionPlatformVersion, allowedVersion);
const bindingType = node.get('bindingType');

let bindingTypeString = bindingType;

if (bindingType === 'versionTag') {
bindingTypeString = 'version tag';
}

return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> with <Binding: ${ bindingTypeString }>`, executionPlatform, executionPlatformVersion, allowedVersion);
}

return message;
Expand Down
8 changes: 8 additions & 0 deletions lib/utils/properties-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ export function getEntryIds(report) {
return [ 'bindingType' ];
}

if (isPropertyError(data, 'versionTag') || isExtensionElementNotAllowedError(data, 'zeebe:VersionTag')) {
return [ 'versionTag' ];
}

return [];
}

Expand Down Expand Up @@ -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) {
Expand Down
189 changes: 187 additions & 2 deletions test/spec/utils/error-messages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,33 @@ describe('utils/error-messages', function() {
// then
expect(errorMessage).to.equal('A <Service Task> with <Execution listeners> 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 <Process> with <Version tag> is only supported by Camunda 8.6 or newer');
});

});


Expand Down Expand Up @@ -777,7 +804,7 @@ describe('utils/error-messages', function() {
const errorMessage = getErrorMessage(report, 'Camunda Cloud', '1.0');

// then
expect(errorMessage).to.equal('A <User Task> with defined <Candidate users> is only supported by Camunda 8.2 or newer');
expect(errorMessage).to.equal('A <User Task> with <Candidate users> is only supported by Camunda 8.2 or newer');
});


Expand Down Expand Up @@ -836,6 +863,85 @@ describe('utils/error-messages', function() {
expect(errorMessage).to.equal('A <Timer Intermediate Catch Event> with <Date> 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 <Business Rule Task> with <Version tag> 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 <Call Activity> with <Version tag> 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 <User Task> with <Version tag> is only supported by Camunda 8.6 or newer');
});

});

});


Expand Down Expand Up @@ -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', {
Expand All @@ -1941,6 +2047,85 @@ describe('utils/error-messages', function() {
expect(errorMessage).to.equal('A <Call Activity> with <Binding: deployment> 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 <Business Rule Task> with <Binding: version tag> 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 <Call Activity> with <Binding: version tag> 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 <User Task> with <Binding: version tag> is only supported by Camunda 8.6 or newer');
});

});

});


Expand Down
Loading

0 comments on commit 94b8f9b

Please sign in to comment.