Skip to content

Commit

Permalink
test: add generated forms integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Apr 20, 2022
1 parent 5610267 commit d9fc892
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 8 deletions.
23 changes: 18 additions & 5 deletions test/spec/provider/camunda-platform/FormDataProps.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_01ii2ms" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.9.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_01ii2ms" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
<bpmn:process id="myProcess" isExecutable="true">
<bpmn:startEvent id="StartEvent_1" name="StartEvent_1">
<bpmn:extensionElements>
Expand All @@ -11,10 +11,9 @@
<bpmn:subProcess id="Activity_0j3tvw2">
<bpmn:startEvent id="StartEvent_2" name="StartEvent_2" />
</bpmn:subProcess>
<bpmn:userTask id="UserTask_1" name="UserTask_1" >
<bpmn:extensionElements>
<camunda:formData>
</camunda:formData>
<bpmn:userTask id="UserTask_1" name="UserTask_1">
<bpmn:extensionElements>
<camunda:formData />
</bpmn:extensionElements>
</bpmn:userTask>
<bpmn:userTask id="UserTask_2" name="UserTask_2">
Expand All @@ -35,6 +34,14 @@
</camunda:properties>
</bpmn:extensionElements>
</bpmn:userTask>
<bpmn:startEvent id="StartEvent_3" name="StartEvent_3">
<bpmn:extensionElements>
<camunda:formData businessKey="foo">
<camunda:formField id="foo" />
<camunda:formField id="bar" />
</camunda:formData>
</bpmn:extensionElements>
</bpmn:startEvent>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="myProcess">
Expand All @@ -44,6 +51,12 @@
<dc:Bounds x="165" y="122" width="64" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0svgu3u_di" bpmnElement="StartEvent_3">
<dc:Bounds x="622" y="272" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="608" y="315" width="64" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0j3tvw2_di" bpmnElement="Activity_0j3tvw2" isExpanded="true">
<dc:Bounds x="140" y="190" width="350" height="200" />
</bpmndi:BPMNShape>
Expand Down
33 changes: 32 additions & 1 deletion test/spec/provider/camunda-platform/FormDataProps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import CoreModule from 'bpmn-js/lib/core';
import SelectionModule from 'diagram-js/lib/features/selection';
import ModelingModule from 'bpmn-js/lib/features/modeling';

import BehaviorsModule from 'camunda-bpmn-js-behaviors/lib/camunda-platform';

import BpmnPropertiesPanel from 'src/render';

import BpmnPropertiesProvider from 'src/provider/bpmn';
Expand All @@ -42,7 +44,8 @@ describe('provider/camunda-platform - FormDataProps', function() {
CamundaPlatformPropertiesProvider,
CoreModule,
ModelingModule,
SelectionModule
SelectionModule,
BehaviorsModule
];

const moddleExtensions = {
Expand Down Expand Up @@ -247,6 +250,34 @@ describe('provider/camunda-platform - FormDataProps', function() {
expect(getFormFieldsList(task)).to.have.length(1);
}));


describe('integration', function() {

it('should remove business key', inject(async function(elementRegistry, selection) {

// given
const startEvent = elementRegistry.get('StartEvent_3');

await act(() => {
selection.select(startEvent);
});

// assume
expect(getFormData(startEvent).get('camunda:businessKey')).to.equal('foo');

// when
const formDataGroup = domQuery('div[data-group-id=group-CamundaPlatform__FormData]', container);

const formFieldRemoveButton = domQueryAll('.bio-properties-panel-remove-entry', formDataGroup)[ 0 ];

clickInput(formFieldRemoveButton);

// then
expect(getFormData(startEvent).get('camunda:businessKey')).not.to.exist;
}));

});

});


Expand Down
15 changes: 14 additions & 1 deletion test/spec/provider/camunda-platform/FormField.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_11oxn67" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.10.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_11oxn67" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
<bpmn:process id="Process_0a4i933" isExecutable="true">
<bpmn:startEvent id="StartEvent_1" name="StartEvent_1">
<bpmn:extensionElements>
Expand Down Expand Up @@ -62,6 +62,13 @@
</camunda:formData>
</bpmn:extensionElements>
</bpmn:userTask>
<bpmn:startEvent id="StartEvent_2" name="StartEvent_2">
<bpmn:extensionElements>
<camunda:formData businessKey="foo">
<camunda:formField id="foo" />
</camunda:formData>
</bpmn:extensionElements>
</bpmn:startEvent>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0a4i933">
Expand All @@ -80,6 +87,12 @@
<bpmndi:BPMNShape id="Activity_16ffca6_di" bpmnElement="UserTask_4">
<dc:Bounds x="640" y="57" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0zd65c8_di" bpmnElement="StartEvent_2">
<dc:Bounds x="179" y="172" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="165" y="215" width="64" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
51 changes: 50 additions & 1 deletion test/spec/provider/camunda-platform/FormField.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import CoreModule from 'bpmn-js/lib/core';
import SelectionModule from 'diagram-js/lib/features/selection';
import ModelingModule from 'bpmn-js/lib/features/modeling';

import BehaviorsModule from 'camunda-bpmn-js-behaviors/lib/camunda-platform';

import BpmnPropertiesPanel from 'src/render';

import BpmnPropertiesProvider from 'src/provider/bpmn';
Expand All @@ -43,7 +45,8 @@ describe('provider/camunda-platform - FormField', function() {
CamundaPlatformPropertiesProvider,
CoreModule,
ModelingModule,
SelectionModule
SelectionModule,
BehaviorsModule
];

const moddleExtensions = {
Expand Down Expand Up @@ -126,6 +129,29 @@ describe('provider/camunda-platform - FormField', function() {
expect(idInput.value).to.eql(originalValue);
}));


describe('integration', function() {

it('should update', inject(async function(elementRegistry, selection) {

// given
const event = elementRegistry.get('StartEvent_2');

await act(() => {
selection.select(event);
});

const idInput = domQuery('input[name=StartEvent_2-formField-0-formFieldID]', container);

// when
changeInput(idInput, 'bar');

// then
expect(getFormData(event).get('camunda:businessKey')).to.equal('bar');
}));

});

});


Expand Down Expand Up @@ -421,6 +447,29 @@ describe('provider/camunda-platform - FormField', function() {

});


describe('integration', function() {

it('should remove values when type set to boolean', inject(async function(elementRegistry, selection) {

// given
const userTask = elementRegistry.get('UserTask_2');

await act(() => {
selection.select(userTask);
});

const typeSelect = domQuery('select[name=UserTask_2-formField-0-formFieldType]', container);

// when
changeInput(typeSelect, 'boolean');

// then
expect(getFormFieldValues(userTask, 0)).to.be.empty;
}));

});

});


Expand Down

0 comments on commit d9fc892

Please sign in to comment.