Skip to content

Commit

Permalink
test(BpmnEditor): test editor integration with element templates engi…
Browse files Browse the repository at this point in the history
…nes feature

We make sure current modeler version and runtime version is provided to the element templates module.

Closes #4760
  • Loading branch information
jarekdanielak committed Feb 17, 2025
1 parent 0165995 commit 0c187c1
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions client/src/app/tabs/cloud-bpmn/__tests__/BpmnEditorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import Panel from '../../../panel/Panel';

import Flags, { ENABLE_NEW_CONTEXT_PAD } from '../../../../util/Flags';

import Metadata from '../../../../util/Metadata';

const { spy } = sinon;


Expand Down Expand Up @@ -1537,6 +1539,64 @@ describe('cloud-bpmn - <BpmnEditor>', function() {
});


it('should provide modeler version for element templates', async function() {

// given
const modelerVersion = '5.30.0';

Metadata.init({ version: modelerVersion });

// when
const { instance } = await renderEditor(engineProfileXML);
const { modeler } = instance.getCached();

// then
expect(modeler.options.elementTemplates.engines).to.eql({ camundaDesktopModeler: modelerVersion });
});


it('should set templates engines when runtime version changes', async function() {

// given
const appVersion = '5.30.0';

Metadata.init({ version: appVersion });

const elementTemplatesMock = {
setEngines: sinon.spy(),
getEngines: () => ({ camundaDesktopModeler: appVersion })
};

const cache = new Cache();

cache.add('editor', {
cached: {
modeler: new BpmnModeler({
modules: {
elementTemplates: elementTemplatesMock
}
})
}
});

// when
const { instance } = await renderEditor(engineProfileXML, { cache });

instance.engineProfile.set({
executionPlatform: 'Camunda Cloud',
executionPlatformVersion: '8.5'
});

// then
const expectedEngines = {
camundaDesktopModeler: appVersion,
camunda: '8.5'
};

expect(elementTemplatesMock.setEngines).to.be.calledWith(expectedEngines);
});


it('should apply default templates to unsaved diagram', async function() {

// given
Expand Down

0 comments on commit 0c187c1

Please sign in to comment.