add a few tests on data object visibility

This commit is contained in:
Elizabeth Esswein 2023-03-03 13:06:58 -05:00
parent 627e771d4f
commit ada919e59d
2 changed files with 53 additions and 2 deletions

View File

@ -7,7 +7,6 @@ import { without } from 'min-dash';
import { is } from 'bpmn-js/lib/util/ModelUtil';
import {
findDataObjects,
findDataObjectReferences,
findDataObjectReferenceShapes,
idToHumanReadableName,
} from '../DataObjectHelpers';

View File

@ -4,7 +4,11 @@ import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js
import {
inject,
} from 'bpmn-js/test/helper';
import {findDataObjects, idToHumanReadableName} from '../../app/spiffworkflow/DataObject/DataObjectHelpers';
import {
findDataObjects,
findDataObjectReferenceShapes,
idToHumanReadableName,
} from '../../app/spiffworkflow/DataObject/DataObjectHelpers';
describe('DataObject Interceptor', function() {
@ -113,4 +117,52 @@ describe('DataObject Interceptor', function() {
expect(dataObjects.length).to.equal(1);
}));
it('Data objects in a process should be visible in a subprocess', inject(function(canvas, modeling, elementRegistry) {
let subProcessShape = elementRegistry.get('my_subprocess');
let subProcess = subProcessShape.businessObject;
let dataObjects = findDataObjects(subProcess);
expect(dataObjects.length).to.equal(0);
let rootShape = canvas.getRootElement();
const dataObjectRefShape = modeling.createShape({ type: 'bpmn:DataObjectReference' },
{ x: 220, y: 220 }, rootShape);
dataObjects = findDataObjects(subProcess);
expect(dataObjects.length).to.equal(1);
}));
it('Data objects in a subprocess should not be visible in a process', inject(function(canvas, modeling, elementRegistry) {
let subProcessShape = elementRegistry.get('my_subprocess');
let subProcess = subProcessShape.businessObject;
const dataObjectRefShape = modeling.createShape({ type: 'bpmn:DataObjectReference' },
{ x: 220, y: 220 }, subProcessShape);
let dataObjects = findDataObjects(subProcess);
expect(dataObjects.length).to.equal(1);
let rootShape = canvas.getRootElement();
dataObjects = findDataObjects(rootShape);
expect(dataObjects.length).to.equal(0);
}));
it('References inside subprocesses should be visible in a process', inject(function(canvas, modeling, elementRegistry) {
let rootShape = canvas.getRootElement();
const refOne = modeling.createShape({ type: 'bpmn:DataObjectReference' },
{ x: 220, y: 220 }, rootShape);
let subProcessShape = elementRegistry.get('my_subprocess');
let subProcess = subProcessShape.businessObject;
const refTwo = modeling.createShape({ type: 'bpmn:DataObjectReference' },
{ x: 320, y: 220 }, subProcessShape);
let dataObjects = findDataObjects(subProcess);
expect(dataObjects.length).to.equal(1);
let references = findDataObjectReferenceShapes(rootShape.children, dataObjects[0].id);
expect(references.length).to.equal(2);
}));
});