Last
This commit is contained in:
parent
a368d0cec7
commit
2778c764f3
|
@ -62,7 +62,8 @@ export default class DataStoreInterceptor extends CommandInterceptor {
|
||||||
this.executed(['shape.delete'], HIGH_PRIORITY, function (event) {
|
this.executed(['shape.delete'], HIGH_PRIORITY, function (event) {
|
||||||
const { context } = event;
|
const { context } = event;
|
||||||
const { shape } = context;
|
const { shape } = context;
|
||||||
if (is(shape, 'bpmn:DataStoreReference') && shape.type !== 'label') {
|
|
||||||
|
if (is(shape, 'bpmn:DataStoreReference') && shape.type !== 'label') {
|
||||||
const definitions = context.oldParent.businessObject.$parent;
|
const definitions = context.oldParent.businessObject.$parent;
|
||||||
const dataStore = shape.businessObject.dataStoreRef;
|
const dataStore = shape.businessObject.dataStoreRef;
|
||||||
if (dataStore && !isDataStoreReferenced(definitions, dataStore.id)) {
|
if (dataStore && !isDataStoreReferenced(definitions, dataStore.id)) {
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import RulesModule from 'diagram-js/lib/features/rules';
|
import RulesModule from 'diagram-js/lib/features/rules';
|
||||||
import DataStorePropertiesProvider from './propertiesPanel/DataStorePropertiesProvider';
|
import DataStorePropertiesProvider from './propertiesPanel/DataStorePropertiesProvider';
|
||||||
|
import DataStoreInterceptor from './DataStoreInterceptor';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
__depends__: [
|
__depends__: [
|
||||||
RulesModule
|
RulesModule
|
||||||
],
|
],
|
||||||
__init__: [ 'dataStorePropertiesProvider' ],
|
__init__: [ 'dataStoreInterceptor', 'dataStorePropertiesProvider' ],
|
||||||
|
dataStoreInterceptor: [ 'type', DataStoreInterceptor ],
|
||||||
dataStorePropertiesProvider: [ 'type', DataStorePropertiesProvider ]
|
dataStorePropertiesProvider: [ 'type', DataStorePropertiesProvider ]
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
import { bootstrapPropertiesPanel, expectSelected } from './helpers';
|
||||||
|
import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel';
|
||||||
|
import {
|
||||||
|
getBpmnJS,
|
||||||
|
inject
|
||||||
|
} from 'bpmn-js/test/helper';
|
||||||
|
import dataStoreInterceptor from '../../app/spiffworkflow/DataStoreReference';
|
||||||
|
|
||||||
|
describe('DataStore Interceptor', function () {
|
||||||
|
|
||||||
|
let xml = require('./bpmn/data_store.bpmn').default;
|
||||||
|
|
||||||
|
beforeEach(bootstrapPropertiesPanel(xml, {
|
||||||
|
debounceInput: false,
|
||||||
|
additionalModules: [
|
||||||
|
dataStoreInterceptor,
|
||||||
|
BpmnPropertiesPanelModule,
|
||||||
|
BpmnPropertiesProviderModule,
|
||||||
|
]
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should delete dataStore in case dataStoreRef is deleted - DataStoreReference element', inject(async function (modeling) {
|
||||||
|
|
||||||
|
const modeler = getBpmnJS();
|
||||||
|
|
||||||
|
// We Select a DataStoreReference element
|
||||||
|
const shapeElement = await expectSelected('DataStoreReference_0eqeh4p');
|
||||||
|
expect(shapeElement, "I can't find DataStoreReference element").to.exist;
|
||||||
|
|
||||||
|
let definitions = await modeler.getDefinitions();
|
||||||
|
let dataStoreExists = definitions.get('rootElements').some(element =>
|
||||||
|
element.$type === 'bpmn:DataStore' && element.id === 'countries'
|
||||||
|
);
|
||||||
|
expect(dataStoreExists, "DataStore 'countries' should be added at the root level").to.be.true;
|
||||||
|
|
||||||
|
// Remove dataStoreReference
|
||||||
|
await modeler.get('modeling').removeShape(shapeElement);
|
||||||
|
const nwshapeElement = await expectSelected('DataStoreReference_0eqeh4p');
|
||||||
|
expect(nwshapeElement, "I can't find DataStoreReference element").not.to.exist;
|
||||||
|
|
||||||
|
// Check that DataStore foods is removed from the root of the process
|
||||||
|
definitions = await modeler.getDefinitions();
|
||||||
|
dataStoreExists = definitions.get('rootElements').some(element =>
|
||||||
|
element.$type === 'bpmn:DataStore' && element.id === 'countries'
|
||||||
|
);
|
||||||
|
expect(dataStoreExists, "DataStore 'countries' should be removed from the root level").not.to.be.true;
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
|
@ -14,10 +14,11 @@ import {
|
||||||
getPropertiesPanel
|
getPropertiesPanel
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
import { getBpmnJS } from 'bpmn-js/test/helper';
|
import { getBpmnJS, inject } from 'bpmn-js/test/helper';
|
||||||
|
|
||||||
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
||||||
import DataStoreReference from '../../app/spiffworkflow/DataStoreReference';
|
import DataStoreReference from '../../app/spiffworkflow/DataStoreReference';
|
||||||
|
import DataStoreInterceptor from '../../app/spiffworkflow/DataStoreReference/DataStoreInterceptor';
|
||||||
|
|
||||||
const return_datastores = (event) => {
|
const return_datastores = (event) => {
|
||||||
event.eventBus.fire('spiff.data_stores.returned', {
|
event.eventBus.fire('spiff.data_stores.returned', {
|
||||||
|
@ -28,7 +29,6 @@ const return_datastores = (event) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
describe('Data Source Reference Test cases', function () {
|
describe('Data Source Reference Test cases', function () {
|
||||||
const xml = require('./bpmn/data_store.bpmn').default;
|
const xml = require('./bpmn/data_store.bpmn').default;
|
||||||
let container;
|
let container;
|
||||||
|
@ -43,6 +43,7 @@ describe('Data Source Reference Test cases', function () {
|
||||||
debounceInput: false,
|
debounceInput: false,
|
||||||
additionalModules: [
|
additionalModules: [
|
||||||
DataStoreReference,
|
DataStoreReference,
|
||||||
|
DataStoreInterceptor,
|
||||||
BpmnPropertiesPanelModule,
|
BpmnPropertiesPanelModule,
|
||||||
BpmnPropertiesProviderModule,
|
BpmnPropertiesProviderModule,
|
||||||
],
|
],
|
||||||
|
@ -116,4 +117,42 @@ describe('Data Source Reference Test cases', function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should delete dataStore if dataStorRef is updated - DataStoreReference element', async function () {
|
||||||
|
const modeler = getBpmnJS();
|
||||||
|
modeler.get('eventBus').once('spiff.data_stores.requested', return_datastores);
|
||||||
|
|
||||||
|
// We Select a DataStoreReference element
|
||||||
|
const shapeElement = await expectSelected('DataStoreReference_0eqeh4p');
|
||||||
|
expect(shapeElement, "I can't find DataStoreReference element").to.exist;
|
||||||
|
|
||||||
|
// Interact with the DataStoreSelect component
|
||||||
|
const selectGroup = findGroupEntry('custom-datastore-properties', container)
|
||||||
|
expect(selectGroup).to.exist;
|
||||||
|
|
||||||
|
const entry = findEntry('selectDataStore', getPropertiesPanel());
|
||||||
|
expect(entry).to.exist;
|
||||||
|
|
||||||
|
// Verification if the dataStoreRef attribute is updated
|
||||||
|
let selector = findSelect(entry);
|
||||||
|
changeInput(selector, 'foods');
|
||||||
|
let nwbusinessObject = getBusinessObject(shapeElement);
|
||||||
|
expect(nwbusinessObject.get('dataStoreRef').id).to.equal('foods');
|
||||||
|
// Then choose new dataStore
|
||||||
|
changeInput(selector, 'countries');
|
||||||
|
nwbusinessObject = getBusinessObject(shapeElement);
|
||||||
|
expect(nwbusinessObject.get('dataStoreRef').id).to.equal('countries');
|
||||||
|
|
||||||
|
// Check if the DataStore is added at the root level with the updated dataStore
|
||||||
|
const definitions = modeler.getDefinitions();
|
||||||
|
const countriesDataStoreExists = definitions.get('rootElements').some(element =>
|
||||||
|
element.$type === 'bpmn:DataStore' && element.id === 'countries'
|
||||||
|
);
|
||||||
|
expect(countriesDataStoreExists, "DataStore 'countries' should be added at the root level").to.be.true;
|
||||||
|
const foodsDataStoreExists = definitions.get('rootElements').some(element =>
|
||||||
|
element.$type === 'bpmn:DataStore' && element.id === 'foods'
|
||||||
|
);
|
||||||
|
expect(foodsDataStoreExists, "DataStore 'countries' should be removed from the root level").not.to.be.true;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
</bpmn:userTask>
|
</bpmn:userTask>
|
||||||
<bpmn:dataStoreReference id="DataStoreReference_0eqeh4p" dataStoreRef="countries" />
|
<bpmn:dataStoreReference id="DataStoreReference_0eqeh4p" dataStoreRef="countries" />
|
||||||
</bpmn:process>
|
</bpmn:process>
|
||||||
|
<bpmn:dataStore id="countries" name="DataStore_countries" />
|
||||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_16xfaqc">
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_16xfaqc">
|
||||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||||
|
|
Loading…
Reference in New Issue