-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: re-add
zeebe-user-task
rule as a warning
Related to camunda/camunda-modeler#4690
- Loading branch information
Showing
8 changed files
with
194 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, { deprecateOnly: true }); | ||
|
||
if (errors && errors.length) { | ||
reportErrors(node, reporter, errors); | ||
} | ||
} | ||
|
||
return { | ||
check | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/camunda-cloud/integration/zeebe-user-task-errors.bpmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters