Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update no-version-tag rule and add version-tag rule #117

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@bpmn-io/diagram-js-ui": "^0.2.3",
"bpmn-moddle": "^9.0.1",
"bpmnlint": "^10.3.0",
"bpmnlint-plugin-camunda-compat": "^2.25.0",
"bpmnlint-plugin-camunda-compat": "^2.26.0",
"bpmnlint-utils": "^1.0.2",
"camunda-bpmn-moddle": "^7.0.1",
"clsx": "^2.0.0",
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
Loading