Handle Broken Test 4

This commit is contained in:
theaubmov 2023-12-02 18:40:49 +01:00
parent 80dcc92d2f
commit 7aa03cd39c
3 changed files with 28 additions and 19 deletions

View File

@ -87,7 +87,7 @@ export default class DataObjectInterceptor extends CommandInterceptor {
dataObject = existingDataObjects[0];
} else {
dataObject = bpmnFactory.create('bpmn:DataObject');
dataObject.name = 'DataObject Name';
dataObject.name = idToHumanReadableName(dataObject.id);
}
// set the reference to the DataObject
shape.businessObject.dataObjectRef = dataObject;
@ -108,7 +108,7 @@ export default class DataObjectInterceptor extends CommandInterceptor {
element: shape,
moddleElement: shape.businessObject,
properties: {
name: idToHumanReadableName(shape.businessObject.dataObjectRef.name),
name: shape.businessObject.dataObjectRef.name,
},
});
}

View File

@ -9,6 +9,7 @@ import {
findDataObjects,
findDataObjectReferenceShapes,
updateDataObjectReferencesName,
idToHumanReadableName,
} from '../DataObjectHelpers';
/**
@ -57,7 +58,7 @@ export function DataObjectArray(props) {
const newDataObject = moddle.create('bpmn:DataObject');
const newElements = process.get('flowElements');
newDataObject.id = moddle.ids.nextPrefixed('DataObject_');
newDataObject.name = 'DataObject Name';
newDataObject.name = idToHumanReadableName(newDataObject.id);
newDataObject.$parent = process;
newElements.push(newDataObject);
commandStack.execute('element.updateModdleProperties', {
@ -120,13 +121,21 @@ function DataObjectTextField(props) {
const debounce = useService('debounceInput');
const setValue = (value) => {
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: dataObject,
properties: {
id: value,
},
});
try {
// let doName = idToHumanReadableName(value);
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: dataObject,
properties: {
id: value,
// name: doName
},
});
// Update references name
// updateDataObjectReferencesName(element, doName, value, commandStack);
} catch (error) {
console.log('Set Value Error : ', error);
}
};
const getValue = () => {

View File

@ -89,17 +89,17 @@ describe('DataObject Interceptor', function() {
expect(dataObjects.length).to.equal(0);
}));
// it('Creating a new Reference will update the name to match the DataObject', inject(function(canvas, modeling) {
it('Creating a new Reference will update the name to match the DataObject', inject(function(canvas, modeling) {
// // IF - a Data Reference Exists
// let rootShape = canvas.getRootElement();
// const dataObjectRefShape1 = modeling.createShape({ type: 'bpmn:DataObjectReference' },
// { x: 220, y: 220 }, rootShape);
// IF - a Data Reference Exists
let rootShape = canvas.getRootElement();
const dataObjectRefShape1 = modeling.createShape({ type: 'bpmn:DataObjectReference' },
{ x: 220, y: 220 }, rootShape);
// const dataObjects = findDataObjects(rootShape.businessObject);
// const human_readable_name = idToHumanReadableName(dataObjects[0].id)
// expect(dataObjectRefShape1.businessObject.name).to.equal(human_readable_name);
// }));
const dataObjects = findDataObjects(rootShape.businessObject);
const human_readable_name = idToHumanReadableName(dataObjects[0].id)
expect(dataObjectRefShape1.businessObject.name).to.equal(human_readable_name);
}));
it('should allow you to add a data object to a subprocess', inject(function(canvas, modeling, elementRegistry) {