Skip to content

Commit

Permalink
feat: update no-version-tag rule and add version-tag rule
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Sep 18, 2024
1 parent e1fdc5d commit 55d1003
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 102 deletions.
9 changes: 7 additions & 2 deletions lib/compiled-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const rules = {
"camunda-compat/timer": "error",
"camunda-compat/user-task-definition": "warn",
"camunda-compat/user-task-form": "error",
"camunda-compat/version-tag": "error",
"camunda-compat/wait-for-completion": "error"
};

Expand Down Expand Up @@ -260,6 +261,10 @@ import rule_42 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/user-tas

cache['bpmnlint-plugin-camunda-compat/user-task-form'] = rule_42;

import rule_43 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/wait-for-completion';
import rule_43 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/version-tag';

cache['bpmnlint-plugin-camunda-compat/wait-for-completion'] = rule_43;
cache['bpmnlint-plugin-camunda-compat/version-tag'] = rule_43;

import rule_44 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/wait-for-completion';

cache['bpmnlint-plugin-camunda-compat/wait-for-completion'] = rule_44;
16 changes: 8 additions & 8 deletions lib/utils/error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,6 @@ 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 @@ -602,6 +594,14 @@ function getPropertyRequiredErrorMessage(report, executionPlatform, executionPla
return `${ getIndefiniteArticle(typeString) } <${ typeString }> must have a defined <Name>`;
}

if (isAny(node, [
'zeebe:CalledDecision',
'zeebe:CalledElement',
'zeebe:FormDefinition'
]) && requiredProperty === 'versionTag') {
return `${ getIndefiniteArticle(typeString) } <${ typeString }> with <Binding: version tag> must have a defined <Version tag>`;
}

return message;
}

Expand Down
6 changes: 5 additions & 1 deletion lib/utils/properties-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,11 @@ export function getErrorMessage(id, report) {
}

if (id === 'versionTag') {
return getNotSupportedMessage('', allowedVersion);
if (type === ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED) {
return getNotSupportedMessage('', allowedVersion);
} else {
return 'Version tag must be defined.';
}
}
}

Expand Down
161 changes: 82 additions & 79 deletions test/spec/utils/error-messages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,85 +863,6 @@ 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 @@ -1713,6 +1634,88 @@ describe('utils/error-messages', function() {
expect(errorMessage).to.equal('An <Execution Listener> must have a defined <Type>');
});


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', {
bindingType: 'versionTag',
versionTag: ''
})
]
})
});

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/version-tag');

const report = await getLintError(node, rule);

// when
const errorMessage = getErrorMessage(report, 'Camunda Cloud', '8.6', 'desktop');

// then
expect(errorMessage).to.equal('A <Business Rule Task> with <Binding: version tag> must have a defined <Version tag>');
});


it('should adjust (call activity)', async function() {

// given
const node = createElement('bpmn:CallActivity', {
extensionElements: createElement('bpmn:ExtensionElements', {
values: [
createElement('zeebe:CalledElement', {
bindingType: 'versionTag',
versionTag: ''
})
]
})
});

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/version-tag');

const report = await getLintError(node, rule);

// when
const errorMessage = getErrorMessage(report, 'Camunda Cloud', '8.6', 'desktop');

// then
expect(errorMessage).to.equal('A <Call Activity> with <Binding: version tag> must have a defined <Version tag>');
});


it('should adjust (user task)', async function() {

// given
const node = createElement('bpmn:UserTask', {
extensionElements: createElement('bpmn:ExtensionElements', {
values: [
createElement('zeebe:FormDefinition', {
bindingType: 'versionTag',
versionTag: ''
})
]
})
});

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/version-tag');

const report = await getLintError(node, rule);

// when
const errorMessage = getErrorMessage(report, 'Camunda Cloud', '8.6', 'desktop');

// then
expect(errorMessage).to.equal('A <User Task> with <Binding: version tag> must have a defined <Version tag>');
});

});

});


Expand Down
27 changes: 15 additions & 12 deletions test/spec/utils/properties-panel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2160,23 +2160,24 @@ describe('utils/properties-panel', function() {
extensionElements: createElement('bpmn:ExtensionElements', {
values: [
createElement('zeebe:CalledDecision', {
versionTag: 'v1.0.0'
bindingType: 'versionTag',
versionTag: ''
})
]
})
});

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag');
const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/version-tag');

const report = await getLintError(node, rule);
const report = await getLintError(node, rule, { version: '8.6' });

// when
const entryIds = getEntryIds(report);

// then
expect(entryIds).to.eql([ 'versionTag' ]);

expectErrorMessage(entryIds[ 0 ], 'Only supported by Camunda 8.6 or newer.', report);
expectErrorMessage(entryIds[ 0 ], 'Version tag must be defined.', report);
});


Expand All @@ -2187,23 +2188,24 @@ describe('utils/properties-panel', function() {
extensionElements: createElement('bpmn:ExtensionElements', {
values: [
createElement('zeebe:CalledElement', {
versionTag: 'v1.0.0'
bindingType: 'versionTag',
versionTag: ''
})
]
})
});

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag');
const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/version-tag');

const report = await getLintError(node, rule);
const report = await getLintError(node, rule, { version: '8.6' });

// when
const entryIds = getEntryIds(report);

// then
expect(entryIds).to.eql([ 'versionTag' ]);

expectErrorMessage(entryIds[ 0 ], 'Only supported by Camunda 8.6 or newer.', report);
expectErrorMessage(entryIds[ 0 ], 'Version tag must be defined.', report);
});


Expand All @@ -2214,23 +2216,24 @@ describe('utils/properties-panel', function() {
extensionElements: createElement('bpmn:ExtensionElements', {
values: [
createElement('zeebe:FormDefinition', {
versionTag: 'v1.0.0'
bindingType: 'versionTag',
versionTag: ''
})
]
})
});

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag');
const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/version-tag');

const report = await getLintError(node, rule);
const report = await getLintError(node, rule, { version: '8.6' });

// when
const entryIds = getEntryIds(report);

// then
expect(entryIds).to.eql([ 'versionTag' ]);

expectErrorMessage(entryIds[ 0 ], 'Only supported by Camunda 8.6 or newer.', report);
expectErrorMessage(entryIds[ 0 ], 'Version tag must be defined.', report);
});

});
Expand Down

0 comments on commit 55d1003

Please sign in to comment.