2022-10-12 14:21:19 +00:00
|
|
|
import TestContainer from 'mocha-test-container-support';
|
|
|
|
import {
|
|
|
|
BpmnPropertiesPanelModule,
|
|
|
|
BpmnPropertiesProviderModule,
|
|
|
|
} from 'bpmn-js-properties-panel';
|
|
|
|
import { query as domQuery } from 'min-dom';
|
|
|
|
import { getBusinessObject } from 'bpmn-js/lib/util/ModelUtil';
|
2022-11-07 19:35:53 +00:00
|
|
|
import { inject } from 'bpmn-js/test/helper';
|
2022-10-12 14:21:19 +00:00
|
|
|
import {
|
|
|
|
bootstrapPropertiesPanel,
|
|
|
|
changeInput,
|
2022-11-11 16:41:03 +00:00
|
|
|
expectSelected,
|
|
|
|
findButton,
|
|
|
|
findGroupEntry,
|
|
|
|
pressButton,
|
2022-10-12 14:21:19 +00:00
|
|
|
} from './helpers';
|
|
|
|
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
|
|
|
import callActivity from '../../app/spiffworkflow/callActivity';
|
|
|
|
|
|
|
|
describe('Call Activities should work', function () {
|
|
|
|
const xml = require('./bpmn/call_activity.bpmn').default;
|
|
|
|
let container;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
container = TestContainer.get(this);
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(
|
|
|
|
bootstrapPropertiesPanel(xml, {
|
|
|
|
container,
|
|
|
|
debounceInput: false,
|
|
|
|
additionalModules: [
|
|
|
|
callActivity,
|
|
|
|
BpmnPropertiesPanelModule,
|
|
|
|
BpmnPropertiesProviderModule,
|
|
|
|
],
|
|
|
|
moddleExtensions: {
|
|
|
|
spiffworkflow: spiffModdleExtension,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
it('should allow you to view the called element section of a Call Activity', async function () {
|
|
|
|
const shapeElement = await expectSelected('the_call_activity');
|
|
|
|
expect(shapeElement, "Can't find Call Activity").to.exist;
|
|
|
|
const entry = findGroupEntry('called_element', container);
|
|
|
|
expect(entry).to.exist;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow you to edit the called element section of a Call Activity', async function () {
|
|
|
|
const shapeElement = await expectSelected('the_call_activity');
|
|
|
|
expect(shapeElement, "Can't find Call Activity").to.exist;
|
|
|
|
const businessObject = getBusinessObject(shapeElement);
|
|
|
|
expect(businessObject.get('calledElement')).to.equal('ProcessIdTBD1');
|
|
|
|
|
|
|
|
const entry = findGroupEntry('called_element', container);
|
|
|
|
expect(entry).to.exist;
|
|
|
|
|
|
|
|
const textInput = domQuery('input', entry);
|
|
|
|
changeInput(textInput, 'newProcessId');
|
|
|
|
expect(businessObject.get('calledElement')).to.equal('newProcessId');
|
|
|
|
});
|
2022-11-07 19:35:53 +00:00
|
|
|
|
2022-11-11 16:41:03 +00:00
|
|
|
it('should issue an event to the event bus if user clicks the edit button', inject(async function (
|
|
|
|
eventBus
|
|
|
|
) {
|
2022-11-07 19:35:53 +00:00
|
|
|
const shapeElement = await expectSelected('the_call_activity');
|
|
|
|
expect(shapeElement, "Can't find Call Activity").to.exist;
|
|
|
|
const businessObject = getBusinessObject(shapeElement);
|
|
|
|
expect(businessObject.get('calledElement')).to.equal('ProcessIdTBD1');
|
|
|
|
|
|
|
|
const entry = findGroupEntry('called_element', container);
|
|
|
|
const button = findButton('spiffworkflow-open-call-activity-button', entry);
|
|
|
|
expect(button).to.exist;
|
|
|
|
|
|
|
|
let launchEvent;
|
|
|
|
eventBus.on('spiff.callactivity.edit', function (event) {
|
|
|
|
launchEvent = event;
|
|
|
|
});
|
|
|
|
await pressButton(button);
|
|
|
|
expect(launchEvent.processId).to.exist;
|
|
|
|
}));
|
2022-11-11 16:41:03 +00:00
|
|
|
|
|
|
|
it('should issue an event to the event bus if user clicks the search button', inject(async function (
|
|
|
|
eventBus
|
|
|
|
) {
|
|
|
|
const shapeElement = await expectSelected('the_call_activity');
|
|
|
|
expect(shapeElement, "Can't find Call Activity").to.exist;
|
|
|
|
const businessObject = getBusinessObject(shapeElement);
|
|
|
|
expect(businessObject.get('calledElement')).to.equal('ProcessIdTBD1');
|
|
|
|
|
|
|
|
const entry = findGroupEntry('called_element', container);
|
|
|
|
const button = findButton(
|
|
|
|
'spiffworkflow-search-call-activity-button',
|
|
|
|
entry
|
|
|
|
);
|
|
|
|
expect(button).to.exist;
|
|
|
|
|
|
|
|
let launchEvent;
|
|
|
|
eventBus.on('spiff.callactivity.search', function (event) {
|
|
|
|
launchEvent = event;
|
|
|
|
});
|
|
|
|
await pressButton(button);
|
|
|
|
expect(launchEvent.processId).to.exist;
|
2022-11-18 15:03:38 +00:00
|
|
|
expect(launchEvent.element).to.exist;
|
2022-11-11 16:41:03 +00:00
|
|
|
|
2022-11-18 15:03:38 +00:00
|
|
|
eventBus.fire('spiff.callactivity.update', {value: 'searchedProcessId', element: launchEvent.element});
|
2022-11-11 16:41:03 +00:00
|
|
|
const textInput = domQuery('input', entry);
|
|
|
|
expect(businessObject.get('calledElement')).to.equal('searchedProcessId');
|
|
|
|
|
|
|
|
}));
|
2022-10-12 14:21:19 +00:00
|
|
|
});
|