spiff-arena/test/spec/BusinessRulePropsSpec.js
burnettk 392c9a1b44 Squashed 'bpmn-js-spiffworkflow/' changes from 9dcca6c80..6007a770a
6007a770a fix typo
aa524120b Merge pull request #47 from sartography/dependabot/github_actions/crazy-max/ghaction-github-labeler-5.0.0
75556c020 Bump crazy-max/ghaction-github-labeler from 4.2.0 to 5.0.0
9a5c333de Merge pull request #46 from sartography/feature/better_form_nav
c6c955284 Merge pull request #43 from sartography/bugfix/update-data-input-output-specs
094c573e0 fixing a test.
5fcb47125 Assume established naming conventions over requiring a form schema and ui schema each time as separate inputs. Making this one dropdown for the user form instead of two.
53f45dbaa Merge pull request #45 from sartography/dependabot/github_actions/actions/checkout-4
67765a994 Bump actions/checkout from 3 to 4
dbcd66942 Merge pull request #44 from sartography/dependabot/github_actions/crazy-max/ghaction-github-labeler-4.2.0
b8be0e335 Bump crazy-max/ghaction-github-labeler from 4.1.0 to 4.2.0
7743372d2 update iospec to include refs in input/output sets
6e17bda37 use same version of bpmn-js as arena
2c7fca88f missed a type in spiffworkflow.json
d62f021e3 Merge pull request #42 from sartography/bugfix/lowercase-overridden-tags
c625980c5 update extension names
e92ae2f5a make sure tags with extensions are written to xml correctly
eb37b6d29 Merge pull request #41 from sartography/feature/guest_form_submission
1b390c46c added panel extensions for guest access to human tasks w/ burnettk
f01bece04 Merge pull request #40 from sartography/feature/multiinstance-improvements
b8179146b allow attaching pre/post scripts to MI task or instance tasks

git-subtree-dir: bpmn-js-spiffworkflow
git-subtree-split: 6007a770a5938c993173001a013116cedfc80359
2023-10-14 12:30:16 -04:00

88 lines
3.4 KiB
JavaScript

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';
import {
bootstrapPropertiesPanel,
changeInput,
expectSelected,
findEntry,
findSelect,
getPropertiesPanel,
} from './helpers';
import extensions from '../../app/spiffworkflow/extensions';
describe('Business Rule Properties Panel', function () {
const xml = require('./bpmn/diagram.bpmn').default;
beforeEach(
bootstrapPropertiesPanel(xml, {
debounceInput: false,
additionalModules: [
BpmnPropertiesPanelModule,
BpmnPropertiesProviderModule,
extensions,
],
moddleExtensions: {
spiffworkflow: spiffModdleExtension,
},
})
);
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' },
],
});
}
it('should display a dropdown to select from available decision tables', async function () {
const modeler = getBpmnJS();
modeler.get('eventBus').once('spiff.dmn_files.requested', return_files);
expectSelected('business_rule_task');
// THEN - a properties panel exists with a section for editing that script
const entry = findEntry('extension_spiffworkflow:CalledDecisionId', getPropertiesPanel());
expect(entry, 'No Entry').to.exist;
const selectList = findSelect(entry);
expect(selectList, 'No Select').to.exist;
});
it('should update the spiffworkflow:calledDecisionId tag when you modify the called decision select box', async function () {
// IF - a script tag is selected, and you change the script in the properties panel
const modeler = getBpmnJS();
modeler.get('eventBus').once('spiff.dmn_files.requested', return_files);
const businessRuleTask = await expectSelected('business_rule_task');
const entry = findEntry('extension_CalledDecisionId', getPropertiesPanel());
const selectList = findSelect(entry);
changeInput(selectList, 'Decision_Pizza_Price');
// THEN - the script tag in the BPMN Business object / XML is updated as well.
const businessObject = getBusinessObject(businessRuleTask);
expect(businessObject.extensionElements).to.exist;
const element = businessObject.extensionElements.values[0];
expect(element.value).to.equal('Decision_Pizza_Price');
});
it('should load up the xml and the value for the called decision should match the xml', async function () {
const businessRuleTask = await expectSelected('business_rule_task');
const entry = findEntry('extension_CalledDecisionId', getPropertiesPanel());
const selectList = findSelect(entry);
expect(selectList.value, "initial value is wrong").to.equal('test_decision');
// THEN - the script tag in the BPMN Business object / XML is updated as well.
const businessObject = getBusinessObject(businessRuleTask);
expect(businessObject.extensionElements).to.exist;
const element = businessObject.extensionElements.values[0];
expect(element.value).to.equal('test_decision');
});
});