From 646b292249c1924facbf3b416f81de8831ff61ac Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 20 Jun 2024 23:25:14 +0200 Subject: [PATCH] Add has_nami to participant api index --- app/Form/Resources/ParticipantResource.php | 1 + tests/Feature/Form/ParticipantIndexActionTest.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/Form/Resources/ParticipantResource.php b/app/Form/Resources/ParticipantResource.php index b200242f..68235b37 100644 --- a/app/Form/Resources/ParticipantResource.php +++ b/app/Form/Resources/ParticipantResource.php @@ -57,6 +57,7 @@ class ParticipantResource extends JsonResource 'default_filter_value' => ParticipantFilterScope::$nan, 'filters' => $filterData, 'form_meta' => $form->meta, + 'has_nami_field' => $form->getFields()->hasNamiField(), 'links' => [ 'update_form_meta' => route('form.update-meta', ['form' => $form]), ], diff --git a/tests/Feature/Form/ParticipantIndexActionTest.php b/tests/Feature/Form/ParticipantIndexActionTest.php index 650cd91a..773825e5 100644 --- a/tests/Feature/Form/ParticipantIndexActionTest.php +++ b/tests/Feature/Form/ParticipantIndexActionTest.php @@ -51,6 +51,7 @@ class ParticipantIndexActionTest extends FormTestCase ->assertJsonPath('meta.columns.6.display_attribute', 'birthday_display') ->assertJsonPath('meta.columns.0.display_attribute', 'vorname_display') ->assertJsonPath('meta.form_meta.active_columns', ['vorname', 'select', 'stufe', 'test1']) + ->assertJsonPath('meta.has_nami_field', false) ->assertJsonPath('meta.links.update_form_meta', route('form.update-meta', ['form' => $form])) ->assertJsonPath('meta.form_meta.sorting', ['vorname', 'asc']); } @@ -72,6 +73,13 @@ class ParticipantIndexActionTest extends FormTestCase $this->callFilter('form.participant.index', ['data' => []], ['form' => $form])->assertJsonPath('meta.filter.data.check', ParticipantFilterScope::$nan); } + public function testItDisplaysHasNamiField(): void + { + $this->login()->loginNami()->withoutExceptionHandling(); + $form = Form::factory()->fields([$this->namiField('mitglieder')])->create(); + $this->callFilter('form.participant.index', [], ['form' => $form])->assertJsonPath('meta.has_nami_field', true); + } + public function testItFiltersParticipantsByCheckboxValue(): void { $this->login()->loginNami()->withoutExceptionHandling();