Refactor test workflow_value_expression
the backend shouldn't try to set a dynamic default value. Instead, the frontend will initialize it to an empty string, then evaluate a default value, then choose to set it. (Basically, move this function from the backend and put the burden on formly)
This commit is contained in:
parent
08c1571803
commit
218429f196
|
@ -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:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0l37fag" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.3">
|
||||
<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:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0l37fag" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0">
|
||||
<bpmn:process id="Process_TestValueExpression" name="Test Value Expression" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>Flow_1nc3qi5</bpmn:outgoing>
|
||||
|
@ -16,10 +16,7 @@
|
|||
<bpmn:userTask id="Activity_Data" name="Data" camunda:formKey="DataForm">
|
||||
<bpmn:extensionElements>
|
||||
<camunda:formData>
|
||||
<camunda:formField id="color" label="Select" type="enum">
|
||||
<camunda:properties>
|
||||
<camunda:property id="value_expression" value="value_expression_value" />
|
||||
</camunda:properties>
|
||||
<camunda:formField id="color" label="Select" type="enum" defaultValue="value_expression_value">
|
||||
<camunda:value id="black" name="Black" />
|
||||
<camunda:value id="white" name="White" />
|
||||
</camunda:formField>
|
||||
|
|
|
@ -4,7 +4,7 @@ from tests.base_test import BaseTest
|
|||
class TestValueExpression(BaseTest):
|
||||
|
||||
# If there is no default value, a value of 'None' should be given.
|
||||
def test_value_expression_no_default(self):
|
||||
def test_no_default(self):
|
||||
|
||||
workflow = self.create_workflow('test_value_expression')
|
||||
|
||||
|
@ -18,9 +18,8 @@ class TestValueExpression(BaseTest):
|
|||
self.assertNotIn('color', second_task.data)
|
||||
|
||||
|
||||
|
||||
def test_value_expression_with_default(self):
|
||||
|
||||
# If there is dynamic default value, it should be added in to the task data at runtime.
|
||||
def test_with_dynamic_default(self):
|
||||
workflow = self.create_workflow('test_value_expression')
|
||||
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
|
@ -30,15 +29,5 @@ class TestValueExpression(BaseTest):
|
|||
workflow_api = self.get_workflow_api(workflow)
|
||||
second_task = workflow_api.next_task
|
||||
self.assertEqual('black', second_task.data['value_expression_value'])
|
||||
self.assertIn('color', second_task.data)
|
||||
self.assertEqual('black', second_task.data['color'])
|
||||
|
||||
def test_validate_task_with_both_default_and_expression(self):
|
||||
# This actually fails validation.
|
||||
# We are testing the error message is correct.
|
||||
self.load_test_spec('empty_workflow', master_spec=True)
|
||||
self.create_reference_document()
|
||||
spec_model = self.load_test_spec('default_value_expression')
|
||||
rv = self.app.get('/v1.0/workflow-specification/%s/validate' % spec_model.id, headers=self.logged_in_headers())
|
||||
self.assertEqual('default value and value_expression', rv.json[0]['code'])
|
||||
self.assertIn('Task_GetName', rv.json[0]['message'])
|
||||
self.assertEqual('value_expression_value', second_task.form['fields'][0]['default_value'])
|
||||
self.assertNotIn('color', second_task.data)
|
Loading…
Reference in New Issue