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: re-add zeebe-user-task rule as a warning #183

Merged
merged 1 commit into from
Dec 11, 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
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ const camundaCloud86Rules = withConfig({
'duplicate-execution-listeners': 'error',
'execution-listener': 'error',
'priority-definition': 'error',
'version-tag': 'error'
'version-tag': 'error',
'zeebe-user-task': 'warn',
}, { version: '8.6' });

const camundaCloud87Rules = withConfig({
Expand Down Expand Up @@ -162,6 +163,7 @@ const rules = {
'no-zeebe-properties': './rules/camunda-cloud/no-zeebe-properties',
'no-zeebe-user-task': './rules/camunda-cloud/no-zeebe-user-task',
'priority-definition': './rules/camunda-cloud/priority-definition',
'zeebe-user-task': './rules/camunda-cloud/zeebe-user-task',
'secrets': './rules/camunda-cloud/secrets',
'sequence-flow-condition': './rules/camunda-cloud/sequence-flow-condition',
'signal-reference': './rules/camunda-cloud/signal-reference',
Expand Down
25 changes: 25 additions & 0 deletions rules/camunda-cloud/zeebe-user-task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { is } = require('bpmnlint-utils');

const { reportErrors } = require('../utils/reporter');

const { skipInNonExecutableProcess } = require('../utils/rule');

const { hasExtensionElement } = require('../utils/element');

module.exports = skipInNonExecutableProcess(function() {
function check(node, reporter) {
if (!is(node, 'bpmn:UserTask')) {
return;
}

const errors = hasExtensionElement(node, 'zeebe:UserTask', node);

if (errors && errors.length) {
reportErrors(node, reporter, errors);
}
}

return {
check
};
});
18 changes: 18 additions & 0 deletions test/camunda-cloud/integration/zeebe-user-task-errors.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"
id="Definitions_2"
targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="Process_2" isExecutable="true">
<bpmn:userTask id="UserTask_1">
<bpmn:extensionElements>
<!-- Missing zeebe:UserTask extension element -->
<zeebe:OtherExtension />
</bpmn:extensionElements>
</bpmn:userTask>
</bpmn:process>
</bpmn:definitions>
17 changes: 17 additions & 0 deletions test/camunda-cloud/integration/zeebe-user-task.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"
id="Definitions_1"
targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:userTask id="UserTask_1">
<bpmn:extensionElements>
<zeebe:UserTask />
</bpmn:extensionElements>
</bpmn:userTask>
</bpmn:process>
</bpmn:definitions>
75 changes: 75 additions & 0 deletions test/camunda-cloud/integration/zeebe-user-task.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const { expect } = require('chai');

const Linter = require('bpmnlint/lib/linter');

const NodeResolver = require('bpmnlint/lib/resolver/node-resolver');

const { readModdle } = require('../../helper');

const versions = [
'8.6',
'8.7'
];

describe('integration - zeebe-user-task', function() {

versions.forEach(function(version) {

let linter;

beforeEach(function() {
linter = new Linter({
config: {
extends: `plugin:camunda-compat/camunda-cloud-${ version.replace('.', '-') }`
},
resolver: new NodeResolver()
});
});


describe(`Camunda Cloud ${ version }`, function() {

describe('no errors', function() {

it('should not have errors', async function() {

// given
const { root } = await readModdle('test/camunda-cloud/integration/zeebe-user-task.bpmn');

// when
const reports = await linter.lint(root);

// then
expect(reports[ 'camunda-compat/zeebe-user-task' ]).to.be.undefined;
});

});


describe('errors', function() {

it('should have errors', async function() {

// given
const { root } = await readModdle('test/camunda-cloud/integration/zeebe-user-task-errors.bpmn');

// when
const reports = await linter.lint(root);

// then
expect(reports[ 'camunda-compat/zeebe-user-task' ]).to.exist;
expect(reports[ 'camunda-compat/zeebe-user-task' ]).to.have.lengthOf(1);

const [ error ] = reports[ 'camunda-compat/zeebe-user-task' ];

expect(error.message).to.equal('Element of type <bpmn:UserTask> must have one extension element of type <zeebe:UserTask>');
expect(error.id).to.equal('UserTask_1');
});

});

});

});

});
52 changes: 52 additions & 0 deletions test/camunda-cloud/zeebe-user-task.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const RuleTester = require('bpmnlint/lib/testers/rule-tester');

const rule = require('../../rules/camunda-cloud/zeebe-user-task');

const {
createModdle,
createProcess,
} = require('../helper');

const { ERROR_TYPES } = require('../../rules/utils/element');

const valid = [
{
name: 'UserTask with one zeebe:UserTask extension element',
moddleElement: createModdle(createProcess(`
<bpmn:userTask id="UserTask_1">
<bpmn:extensionElements>
<zeebe:UserTask />
</bpmn:extensionElements>
</bpmn:userTask>
`))
}
];

const invalid = [
{
name: 'UserTask with no zeebe:UserTask extension element (invalid if required)',
moddleElement: createModdle(createProcess(`
<bpmn:userTask id="UserTask_5">
<bpmn:extensionElements>
<zeebe:OtherExtension />
</bpmn:extensionElements>
</bpmn:userTask>
`)),
report: {
id: 'UserTask_5',
message: 'Element of type <bpmn:UserTask> must have one extension element of type <zeebe:UserTask>',
path: [],
data: {
type: ERROR_TYPES.EXTENSION_ELEMENT_REQUIRED,
node: 'UserTask_5',
parentNode: null,
requiredExtensionElement: 'zeebe:UserTask'
}
}
}
];

RuleTester.verify('zeebe-user-task', rule, {
valid,
invalid
});
3 changes: 3 additions & 0 deletions test/config/configs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ describe('configs', function() {
'no-multiple-none-start-events' : [ 'error', { version: '8.6' } ],
'no-task-listeners': [ 'error', { version: '8.6' } ],
'priority-definition': [ 'error', { version: '8.6' } ],
'zeebe-user-task': [ 'warn', { version: '8.6' } ],
'secrets': [ 'warn', { version: '8.6' } ],
'sequence-flow-condition': [ 'error', { version: '8.6' } ],
'signal-reference': [ 'error', { version: '8.6' } ],
Expand Down Expand Up @@ -420,6 +421,7 @@ describe('configs', function() {
'no-loop': [ 'error', { version: '8.7' } ],
'no-multiple-none-start-events' : [ 'error', { version: '8.7' } ],
'priority-definition': [ 'error', { version: '8.7' } ],
'zeebe-user-task': [ 'warn', { version: '8.7' } ],
'secrets': [ 'warn', { version: '8.7' } ],
'sequence-flow-condition': [ 'error', { version: '8.7' } ],
'signal-reference': [ 'error', { version: '8.7' } ],
Expand Down Expand Up @@ -495,6 +497,7 @@ describe('configs', function() {
'no-zeebe-properties': 'error',
'no-zeebe-user-task': 'error',
'priority-definition': 'error',
'zeebe-user-task': 'warn',
'secrets': 'warn',
'sequence-flow-condition': 'error',
'signal-reference': 'error',
Expand Down
Loading