Skip to content

Commit

Permalink
fix(cloud-element-templates): correctly initialize input/output
Browse files Browse the repository at this point in the history
  • Loading branch information
smbea committed Dec 1, 2022
1 parent 2a77249 commit fee8ac4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,9 @@ export default class ChangeElementTemplateHandler {
}
}

// (3) add new inputs and outputs (unless optional)
else if (shouldUpdate(newPropertyValue, newProperty)) {
// (3) add new inputs and outputs (unless optional or undefined value)
else if (newPropertyValue && shouldUpdate(newPropertyValue, newProperty)) {

if (newBindingType === 'zeebe:input') {
propertyName = 'inputParameters';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ describe('provider/cloud-element-templates - ElementTemplatesConditionChecker',
});

// then
expectOutputTarget(businessObject, '');
expectOutputTarget(businessObject, 'nameProp=foo');

// when
modeling.updateProperties(element, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1982,7 +1982,7 @@ describe('cloud-element-templates - ChangeElementTemplateHandler', function() {
beforeEach(bootstrap(require('./task.bpmn').default));


it('should create - optional -> non optional', inject(function(elementRegistry) {
it('should create - optional -> non optional (value)', inject(function(elementRegistry) {

// given
const task = elementRegistry.get('Task_1');
Expand All @@ -2006,12 +2006,14 @@ describe('cloud-element-templates - ChangeElementTemplateHandler', function() {

const newTemplate = createTemplate([
{
value: 'input-1-new-value',
binding: {
type: 'zeebe:input',
name: 'input-1-target'
}
},
{
value: 'output-1-new-value',
binding: {
type: 'zeebe:output',
source: 'output-1-source'
Expand Down Expand Up @@ -2040,7 +2042,7 @@ describe('cloud-element-templates - ChangeElementTemplateHandler', function() {
expect(ioMapping.get('zeebe:inputParameters')).to.jsonEqual([
{
$type: 'zeebe:Input',
source: undefined,
source: 'input-1-new-value',
target: 'input-1-target',
}
]);
Expand All @@ -2055,6 +2057,63 @@ describe('cloud-element-templates - ChangeElementTemplateHandler', function() {
}));


it('should create - optional -> non optional (no value)', inject(function(elementRegistry) {

// given
const task = elementRegistry.get('Task_1');

const oldTemplate = createTemplate([
{
optional: true,
binding: {
type: 'zeebe:input',
name: 'input-1-target'
}
},
{
optional: true,
binding: {
type: 'zeebe:output',
source: 'output-1-source'
}
}
]);

const newTemplate = createTemplate([
{
binding: {
type: 'zeebe:input',
name: 'input-1-target'
}
},
{
binding: {
type: 'zeebe:output',
source: 'output-1-source'
}
}
]);

changeTemplate('Task_1', oldTemplate);

let ioMapping = findExtension(task, 'zeebe:IoMapping');

// assume
expect(ioMapping.get('zeebe:inputParameters')).to.be.empty;
expect(ioMapping.get('zeebe:outputParameters')).to.be.empty;

// when
changeTemplate(task, newTemplate, oldTemplate);

// then
ioMapping = findExtension(task, 'zeebe:IoMapping');

expect(ioMapping).to.exist;
expect(ioMapping.get('zeebe:inputParameters')).to.have.length(0);
expect(ioMapping.get('zeebe:outputParameters')).to.have.length(0);
}));


it('should remove - non optional -> optional (empty value)', inject(function(elementRegistry) {

// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
},
{
"label": "zeebe:input",
"value": "",
"value": "nameProp=foo",
"type": "String",
"binding": {
"type": "zeebe:input",
Expand All @@ -94,7 +94,7 @@
},
{
"label": "zeebe:output",
"value": "",
"value": "nameProp=foo",
"type": "String",
"binding": {
"type": "zeebe:output",
Expand Down

0 comments on commit fee8ac4

Please sign in to comment.