2022-11-07 19:35:53 +00:00
|
|
|
import { getBpmnJS } from 'bpmn-js/test/helper';
|
|
|
|
|
|
|
|
import {
|
|
|
|
BpmnPropertiesPanelModule,
|
|
|
|
BpmnPropertiesProviderModule,
|
|
|
|
} from 'bpmn-js-properties-panel';
|
|
|
|
import { getBusinessObject } from 'bpmn-js/lib/util/ModelUtil';
|
|
|
|
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
2022-10-12 14:21:19 +00:00
|
|
|
import {
|
2022-11-07 19:35:53 +00:00
|
|
|
bootstrapPropertiesPanel,
|
|
|
|
changeInput,
|
2022-10-12 14:21:19 +00:00
|
|
|
expectSelected,
|
|
|
|
findEntry,
|
2022-11-07 19:35:53 +00:00
|
|
|
findSelect,
|
|
|
|
getPropertiesPanel,
|
2022-10-12 14:21:19 +00:00
|
|
|
} from './helpers';
|
|
|
|
import extensions from '../../app/spiffworkflow/extensions';
|
|
|
|
|
2022-11-07 19:35:53 +00:00
|
|
|
describe('Business Rule Properties Panel', function () {
|
2022-10-12 14:21:19 +00:00
|
|
|
const xml = require('./bpmn/diagram.bpmn').default;
|
|
|
|
|
2022-11-07 19:35:53 +00:00
|
|
|
beforeEach(
|
|
|
|
bootstrapPropertiesPanel(xml, {
|
|
|
|
debounceInput: false,
|
|
|
|
additionalModules: [
|
|
|
|
BpmnPropertiesPanelModule,
|
|
|
|
BpmnPropertiesProviderModule,
|
|
|
|
extensions,
|
|
|
|
],
|
|
|
|
moddleExtensions: {
|
|
|
|
spiffworkflow: spiffModdleExtension,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
2022-10-12 14:21:19 +00:00
|
|
|
|
2022-11-09 16:39:57 +00:00
|
|
|
|
|
|
|
const return_files = (event) => {
|
|
|
|
event.eventBus.fire('spiff.dmn_files.returned', {
|
|
|
|
options: [
|
|
|
|
{ label: 'Calculate Pizza Price', value: 'Decision_Pizza_Price' },
|
|
|
|
{ label: 'Viking Availability', value: 'Decision_Vikings' },
|
|
|
|
{ label: 'Test Decision', value: 'test_decision' },
|
|
|
|
],
|
2022-11-07 19:35:53 +00:00
|
|
|
});
|
|
|
|
}
|
2022-10-12 14:21:19 +00:00
|
|
|
|
2022-11-07 19:35:53 +00:00
|
|
|
it('should display a dropdown to select from available decision tables', async function () {
|
|
|
|
const modeler = getBpmnJS();
|
2022-11-09 16:39:57 +00:00
|
|
|
modeler.get('eventBus').once('spiff.dmn_files.requested', return_files);
|
2022-10-12 14:21:19 +00:00
|
|
|
expectSelected('business_rule_task');
|
|
|
|
// THEN - a properties panel exists with a section for editing that script
|
2022-11-07 19:35:53 +00:00
|
|
|
const entry = findEntry('extension_spiffworkflow:calledDecisionId', getPropertiesPanel());
|
|
|
|
expect(entry, 'No Entry').to.exist;
|
|
|
|
const selectList = findSelect(entry);
|
|
|
|
expect(selectList, 'No Select').to.exist;
|
2022-10-12 14:21:19 +00:00
|
|
|
});
|
|
|
|
|
2022-11-07 19:35:53 +00:00
|
|
|
it('should update the spiffworkflow:calledDecisionId tag when you modify the called decision select box', async function () {
|
2022-10-12 14:21:19 +00:00
|
|
|
// IF - a script tag is selected, and you change the script in the properties panel
|
2022-11-07 19:35:53 +00:00
|
|
|
const modeler = getBpmnJS();
|
2022-11-09 16:39:57 +00:00
|
|
|
modeler.get('eventBus').once('spiff.dmn_files.requested', return_files);
|
2022-10-12 14:21:19 +00:00
|
|
|
const businessRuleTask = await expectSelected('business_rule_task');
|
2022-11-07 19:35:53 +00:00
|
|
|
const entry = findEntry('extension_calledDecisionId', getPropertiesPanel());
|
|
|
|
const selectList = findSelect(entry);
|
|
|
|
changeInput(selectList, 'Decision_Pizza_Price');
|
2022-10-12 14:21:19 +00:00
|
|
|
|
|
|
|
// THEN - the script tag in the BPMN Business object / XML is updated as well.
|
|
|
|
const businessObject = getBusinessObject(businessRuleTask);
|
|
|
|
expect(businessObject.extensionElements).to.exist;
|
2022-11-07 19:35:53 +00:00
|
|
|
const element = businessObject.extensionElements.values[0];
|
|
|
|
expect(element.value).to.equal('Decision_Pizza_Price');
|
2022-10-12 14:21:19 +00:00
|
|
|
});
|
|
|
|
|
2022-11-07 19:35:53 +00:00
|
|
|
it('should load up the xml and the value for the called decision should match the xml', async function () {
|
2022-10-12 14:21:19 +00:00
|
|
|
const businessRuleTask = await expectSelected('business_rule_task');
|
2022-11-07 19:35:53 +00:00
|
|
|
const entry = findEntry('extension_calledDecisionId', getPropertiesPanel());
|
|
|
|
const selectList = findSelect(entry);
|
|
|
|
expect(selectList.value, "initial value is wrong").to.equal('test_decision');
|
2022-10-12 14:21:19 +00:00
|
|
|
|
|
|
|
// THEN - the script tag in the BPMN Business object / XML is updated as well.
|
2022-11-07 19:35:53 +00:00
|
|
|
const businessObject = getBusinessObject(businessRuleTask);
|
2022-10-12 14:21:19 +00:00
|
|
|
expect(businessObject.extensionElements).to.exist;
|
2022-11-07 19:35:53 +00:00
|
|
|
const element = businessObject.extensionElements.values[0];
|
|
|
|
expect(element.value).to.equal('test_decision');
|
2022-10-12 14:21:19 +00:00
|
|
|
});
|
2022-11-09 16:39:57 +00:00
|
|
|
|
2022-10-12 14:21:19 +00:00
|
|
|
});
|