Fix logic for multi select (#6)

* Fix logic for multi select

* test case for multi select logic
This commit is contained in:
Chirag
2022-10-03 00:10:10 +05:30
committed by GitHub
parent ef70be9d14
commit 610c71cb69
6 changed files with 124 additions and 28 deletions

View File

@@ -56,3 +56,63 @@ it('create form with logic', function () {
'message' => 'Form submission saved.'
]);
});
it('create form with multi select logic', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace, [
'properties' => [
[
'id' => "title",
'name' => "Name",
'type' => 'title',
'hidden' => false,
'required' => false,
'logic' => [
"conditions" => [
"operatorIdentifier"=> "and",
"children"=> [
[
"identifier"=> "multi_select",
"value"=> [
"operator"=> "contains",
"property_meta"=> [
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee124",
"type"=> "multi_select",
],
"value"=> 'One'
]
]
]
],
"actions" => ['require-answer']
]
]
],
]);
$this->getJson(route('forms.show', $form->slug))
->assertSuccessful()
->assertJson(function (AssertableJson $json) use ($form) {
return $json->where('id', $form->id)
->where('properties', function($values){
return (count($values[0]['logic']) > 0);
})
->etc();
});
// Should submit form
$forData = ['93ea3198-353f-440b-8dc9-2ac9a7bee124' => ["One"]];
$this->postJson(route('forms.answer', $form->slug), $forData)
->assertStatus(422)
->assertJson([
'message' => 'The Name field is required.',
'errors' => [
'title' => [
'The Name field is required.',
],
],
]);
});