2022-06-30 18:02:38 +00:00
|
|
|
import {
|
2022-07-01 17:01:52 +00:00
|
|
|
bootstrapPropertiesPanel, changeInput,
|
2022-06-30 18:02:38 +00:00
|
|
|
expectSelected,
|
2022-08-04 19:57:15 +00:00
|
|
|
findEntry, findInput, findSelect,
|
2022-06-30 18:02:38 +00:00
|
|
|
} from './helpers';
|
|
|
|
import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel';
|
|
|
|
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
2022-07-01 17:01:52 +00:00
|
|
|
import TestContainer from 'mocha-test-container-support';
|
2022-08-04 19:57:15 +00:00
|
|
|
import DataObject from '../../app/spiffworkflow/DataObject';
|
2022-06-30 18:02:38 +00:00
|
|
|
|
2022-07-06 17:25:53 +00:00
|
|
|
describe('Properties Panel for Data Objects', function() {
|
2022-07-11 15:00:19 +00:00
|
|
|
let xml = require('./bpmn/diagram.bpmn').default;
|
2022-07-01 17:01:52 +00:00
|
|
|
let container;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
container = TestContainer.get(this);
|
|
|
|
});
|
2022-06-30 18:02:38 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapPropertiesPanel(xml, {
|
2022-07-01 17:01:52 +00:00
|
|
|
container,
|
2022-06-30 18:02:38 +00:00
|
|
|
debounceInput: false,
|
|
|
|
additionalModules: [
|
2022-08-04 19:57:15 +00:00
|
|
|
DataObject,
|
2022-06-30 18:02:38 +00:00
|
|
|
BpmnPropertiesPanelModule,
|
|
|
|
BpmnPropertiesProviderModule,
|
|
|
|
],
|
|
|
|
moddleExtensions: {
|
|
|
|
spiffworkflow: spiffModdleExtension
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
2022-07-01 17:01:52 +00:00
|
|
|
it('should allow you to see a list of data objects', async function() {
|
2022-06-30 18:02:38 +00:00
|
|
|
|
2022-07-01 17:01:52 +00:00
|
|
|
// IF - a data object reference is selected
|
2022-06-30 18:02:38 +00:00
|
|
|
let my_data_ref_1 = await expectSelected('my_data_ref_1');
|
|
|
|
expect(my_data_ref_1).to.exist;
|
|
|
|
|
2022-07-01 17:01:52 +00:00
|
|
|
// THEN - a select Data Object section should appear in the properties panel
|
|
|
|
let entry = findEntry('selectDataObject', container);
|
2022-06-30 18:02:38 +00:00
|
|
|
expect(entry).to.exist;
|
|
|
|
|
2022-07-01 17:01:52 +00:00
|
|
|
// AND - That that properties' pane selection should contain a dropdown with a value in it.
|
|
|
|
let selector = findSelect(entry);
|
|
|
|
expect(selector).to.exist;
|
|
|
|
expect(selector.length).to.equal(3);
|
|
|
|
});
|
2022-06-30 18:02:38 +00:00
|
|
|
|
2022-07-11 21:29:41 +00:00
|
|
|
|
|
|
|
it('selecting a different data object should change the data model.', async function() {
|
2022-06-30 18:02:38 +00:00
|
|
|
|
2022-07-01 17:01:52 +00:00
|
|
|
// IF - a data object reference is selected
|
|
|
|
let my_data_ref_1 = await expectSelected('my_data_ref_1');
|
2022-06-30 18:02:38 +00:00
|
|
|
|
2022-07-01 17:01:52 +00:00
|
|
|
let entry = findEntry('selectDataObject', container);
|
|
|
|
let selector = findSelect(entry);
|
|
|
|
let businessObject = my_data_ref_1.businessObject;
|
2022-06-30 18:02:38 +00:00
|
|
|
|
2022-07-01 17:01:52 +00:00
|
|
|
// AND we select a dataObjectReference (we know it has this value, because we created the bpmn file)
|
|
|
|
changeInput(selector, 'my_third_data_object');
|
2022-06-30 18:02:38 +00:00
|
|
|
|
2022-07-01 17:01:52 +00:00
|
|
|
// then this data reference object now references that data object.
|
|
|
|
expect(businessObject.get('dataObjectRef').id).to.equal('my_third_data_object');
|
2022-06-30 18:02:38 +00:00
|
|
|
});
|
2022-07-01 17:01:52 +00:00
|
|
|
|
2022-07-11 21:29:41 +00:00
|
|
|
it('renaming a data object, changes to the label of references', async function() {
|
|
|
|
|
|
|
|
// IF - a process is selected, and the name of a data object is changed.
|
|
|
|
let entry = findEntry('ProcessTest-dataObj-2-id', container);
|
|
|
|
let textInput = findInput('text', entry);
|
|
|
|
changeInput(textInput, 'my_nifty_new_name');
|
|
|
|
let my_data_ref_1 = await expectSelected('my_data_ref_1');
|
|
|
|
|
|
|
|
// THEN - both the data object itself, and the label of any references are updated.
|
|
|
|
expect(my_data_ref_1.businessObject.dataObjectRef.id).to.equal('my_nifty_new_name');
|
2022-11-17 19:58:28 +00:00
|
|
|
expect(my_data_ref_1.businessObject.name).to.equal('My Nifty New Name');
|
2022-07-11 21:29:41 +00:00
|
|
|
});
|
2022-07-01 17:01:52 +00:00
|
|
|
|
2023-06-28 19:43:16 +00:00
|
|
|
it('renaming a data object creates a lable without losing the numbers', async function() {
|
|
|
|
|
|
|
|
// IF - a process is selected, and the name of a data object is changed.
|
|
|
|
let entry = findEntry('ProcessTest-dataObj-2-id', container);
|
|
|
|
let textInput = findInput('text', entry);
|
|
|
|
changeInput(textInput, 'MyObject1');
|
|
|
|
let my_data_ref_1 = await expectSelected('my_data_ref_1');
|
|
|
|
|
|
|
|
// THEN - both the data object itself, and the label of any references are updated.
|
|
|
|
expect(my_data_ref_1.businessObject.dataObjectRef.id).to.equal('MyObject1');
|
|
|
|
expect(my_data_ref_1.businessObject.name).to.equal('My Object 1');
|
|
|
|
});
|
|
|
|
|
2022-06-30 18:02:38 +00:00
|
|
|
});
|