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(platform): make HTTL an info hint #100

Merged
merged 4 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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: 4 additions & 0 deletions lib/utils/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export function getDocumentationUrl(rule) {
return getUrl('message-reference');
}

if (rule === 'camunda-compat/history-time-to-live') {
return getUrl('history-time-to-live');
}

return null;
}

Expand Down
4 changes: 0 additions & 4 deletions lib/utils/properties-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,6 @@ export function getErrorMessage(id, report) {
return 'Not supported.';
}

if (id === 'historyTimeToLive') {
return 'Time to live must be defined.';
}

if (id === 'taskScheduleDueDate') {
if (data.type === ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED) {
return 'Not supported.';
Expand Down
12 changes: 10 additions & 2 deletions test/spec/modeler/Linting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,21 @@ describe('Linting', function() {
container.innerHTML = '';

reports.map((report) => {
const { id, message, category, rule } = report;
const { id, message, category, rule, documentation } = report;

if (category === 'rule-error') {
return domify(`<div class="errorItem">Rule error: Rule <${ escapeHTML(rule) }> errored with the following message: ${ escapeHTML(message) }</div>`);
}

const element = domify(`<div class="errorItem">${ id }: ${escapeHTML(message) }</div>`);
const element = domify(`<div class="errorItem">${ id }: ${escapeHTML(message) } </div>`);
nikku marked this conversation as resolved.
Show resolved Hide resolved

if (documentation.url) {
const documentationLink = domify(`<a href="${ documentation.url }" rel="noopener" target="_blank">ref</a>`);

documentationLink.addEventListener('click', e => e.stopPropagation());

element.appendChild(documentationLink);
}

element.addEventListener('click', () => {
linting.showError(report);
Expand Down
28 changes: 1 addition & 27 deletions test/spec/utils/error-messages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import {
} from '../../../lib/utils/error-messages';

import {
createElement,
createElementCamundaPlatform
createElement
} from '../../helper';

import {
Expand Down Expand Up @@ -2022,31 +2021,6 @@ describe('utils/error-messages', function() {

});


describe('Camunda Platform (Camunda 7)', function() {

describe('property required', function() {

it('should adjust (history time to live)', async function() {

// given
const node = createElementCamundaPlatform('bpmn:Process');

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-platform/history-time-to-live');

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

// when
const errorMessage = getErrorMessage(report);

// then
expect(errorMessage).to.equal('A <Process> must have a defined <History time to live>');
});

});

});

});

describe('#getExecutionPlatformLabel', function() {
Expand Down
59 changes: 2 additions & 57 deletions test/spec/utils/properties-panel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import {

import {
createElement,
createElementCamundaPlatform,
createModdle,
createModdleCamundaPlatform
createModdle
} from '../../helper';

import {
Expand All @@ -20,7 +18,6 @@ import {

import propertiesPanelXML from './properties-panel.bpmn';
import propertiesPanelInfoXML from './properties-panel-info.bpmn';
import propertiesPanelPlatformXML from './properties-panel-platform.bpmn';

describe('utils/properties-panel', function() {

Expand Down Expand Up @@ -1918,61 +1915,9 @@ describe('utils/properties-panel', function() {

});


describe('Camunda Platform (Camunda 7)', function() {

describe('#getEntryId and #getErrorMessage', function() {

it('History cleanup (no time to live)', async function() {

// given
const node = createElementCamundaPlatform('bpmn:Process', { isExecutable: true });

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-platform/history-time-to-live');

const report = await getLintError(node, rule, { platform: 'camunda-platform', version: '7.19' });

// when
const entryIds = getEntryIds(report);

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


expectErrorMessage(entryIds[ 0 ], 'Time to live must be defined.', report);
});

});


describe('#getErrors', function() {

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

// given
const linter = new Linter();

const { root } = await createModdleCamundaPlatform(propertiesPanelPlatformXML);

const reports = await linter.lint(root);

// when
let element = root.rootElements[ 0 ];

let errors = getErrors(reports, element);

// then
expect(errors).to.eql({
historyTimeToLive: 'Time to live must be defined.'
});
});

});

});

});


function expectErrorMessage(id, expectedErrorMessage, report) {

// when
Expand Down
Loading