ESC-575 If operator has no format and no expected_type, it means it doesn't n… (#767)
* If operator has no format and no expected_type, it means it doesn't need input * Add testcase for integration logic with checkbox --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
360b116062
commit
cac88e7a3c
|
|
@ -47,6 +47,14 @@ class IntegrationLogicRule implements DataAwareRule, ValidationRule
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$typeField = $condition['value']['property_meta']['type'];
|
||||||
|
$operator = $condition['value']['operator'];
|
||||||
|
|
||||||
|
// If operator has no format and no expected_type, it means it doesn't need input
|
||||||
|
if (!isset(FormPropertyLogicRule::getConditionMapping()[$typeField]['comparators'][$operator]['expected_type'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($condition['value']['value'])) {
|
if (!isset($condition['value']['value'])) {
|
||||||
$this->isConditionCorrect = false;
|
$this->isConditionCorrect = false;
|
||||||
$this->conditionErrors[] = 'missing condition value';
|
$this->conditionErrors[] = 'missing condition value';
|
||||||
|
|
@ -54,8 +62,6 @@ class IntegrationLogicRule implements DataAwareRule, ValidationRule
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$typeField = $condition['value']['property_meta']['type'];
|
|
||||||
$operator = $condition['value']['operator'];
|
|
||||||
$value = $condition['value']['value'];
|
$value = $condition['value']['value'];
|
||||||
|
|
||||||
if (!isset(FormPropertyLogicRule::getConditionMapping()[$typeField])) {
|
if (!isset(FormPropertyLogicRule::getConditionMapping()[$typeField])) {
|
||||||
|
|
|
||||||
|
|
@ -45,3 +45,58 @@ it('can CRUD form integration', function () {
|
||||||
'message' => 'Form Integration was deleted.'
|
'message' => 'Form Integration was deleted.'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can create form integration with checkbox logic', function () {
|
||||||
|
$user = $this->actingAsProUser();
|
||||||
|
$workspace = $this->createUserWorkspace($user);
|
||||||
|
$form = $this->createForm($user, $workspace, [
|
||||||
|
'properties' => [
|
||||||
|
[
|
||||||
|
'id' => 'checkbox_field',
|
||||||
|
'name' => 'Checkbox Field',
|
||||||
|
'type' => 'checkbox'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'text_field',
|
||||||
|
'name' => 'Text Field',
|
||||||
|
'type' => 'text',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'status' => true,
|
||||||
|
'integration_id' => 'email',
|
||||||
|
'logic' => [
|
||||||
|
'operatorIdentifier' => 'and',
|
||||||
|
'children' => [
|
||||||
|
[
|
||||||
|
'identifier' => 'checkbox_field',
|
||||||
|
'value' => [
|
||||||
|
'operator' => 'is_checked',
|
||||||
|
'property_meta' => [
|
||||||
|
'id' => 'checkbox_field',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'settings' => [
|
||||||
|
'send_to' => 'test@test.com',
|
||||||
|
'sender_name' => 'OpnForm',
|
||||||
|
'subject' => 'New form submission with checkbox logic',
|
||||||
|
'email_content' => 'Checkbox logic triggered.',
|
||||||
|
'include_submission_data' => true,
|
||||||
|
'include_hidden_fields_submission_data' => false,
|
||||||
|
'reply_to' => null
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->postJson(route('open.forms.integration.create', $form->id), $data)
|
||||||
|
->assertSuccessful()
|
||||||
|
->assertJson([
|
||||||
|
'type' => 'success',
|
||||||
|
'message' => 'Form Integration was created.'
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue