fixed tests
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2023-05-03 00:25:04 +02:00
parent f523362b90
commit 1632da9b61
6 changed files with 20 additions and 20 deletions

View File

@ -114,7 +114,8 @@ class MemberResource extends JsonResource
*/
public static function meta(): array
{
$activities = Activity::remote()->with(['subactivities' => fn ($q) => $q->remote()])->get();
$activities = Activity::with('subactivities')->get();
$createActivities = Activity::remote()->with(['subactivities' => fn ($q) => $q->remote()])->get();
return [
'filterActivities' => Activity::where('is_filterable', true)->pluck('name', 'id'),
@ -123,6 +124,10 @@ class MemberResource extends JsonResource
'formSubactivities' => $activities->map(function (Activity $activity) {
return ['subactivities' => $activity->subactivities()->pluck('name', 'id'), 'id' => $activity->id];
})->pluck('subactivities', 'id'),
'formCreateActivities' => $createActivities->pluck('name', 'id'),
'formCreateSubactivities' => $createActivities->map(function (Activity $activity) {
return ['subactivities' => $activity->subactivities()->pluck('name', 'id'), 'id' => $activity->id];
})->pluck('subactivities', 'id'),
'groups' => NestedGroup::cacheForSelect(),
'filter' => FilterScope::fromRequest(request()->input('filter', '')),
'courses' => Course::pluck('name', 'id'),

View File

@ -100,11 +100,6 @@ parameters:
count: 1
path: app/Http/Controllers/Auth/RegisterController.php
-
message: "#^Method App\\\\Http\\\\Views\\\\MemberView\\:\\:index\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: app/Http/Views/MemberView.php
-
message: "#^Access to an undefined property Sabre\\\\VObject\\\\Document\\:\\:\\$ADR\\.$#"
count: 1

View File

@ -2,7 +2,7 @@
<page-layout>
<div class="flex" slot="toolbar">
<toolbar-button :href="meta.links.index" color="primary" icon="undo">zurück</toolbar-button>
<toolbar-button :href="data.links.show" color="primary" icon="eye">anschauen</toolbar-button>
<toolbar-button v-if="mode === 'edit'" :href="data.links.show" color="primary" icon="eye">anschauen</toolbar-button>
</div>
<form class="flex grow relative" id="memberedit" @submit.prevent="submit">
<save-button form="memberedit"></save-button>
@ -60,7 +60,7 @@
<f-textarea rows="3" id="comment" class="col-span-2" v-model="inner.comment" label="Kommentar" size="sm"></f-textarea>
<div class="contents" v-if="mode === 'create'">
<f-select
:options="meta.formActivities"
:options="meta.formCreateActivities"
id="first_activity_id"
v-model="inner.first_activity_id"
label="Erste Tätigkeit"
@ -70,7 +70,7 @@
></f-select>
<f-select
v-if="inner.first_activity_id"
:options="meta.formSubactivities[inner.first_activity_id]"
:options="meta.formCreateSubactivities[inner.first_activity_id]"
id="first_subactivity_id"
v-model="inner.first_subactivity_id"
label="Erste Untertätigkeit"

View File

@ -28,9 +28,9 @@ class CreateTest extends TestCase
$response = $this->get(route('member.create'));
$this->assertInertiaHas('Biber', $response, "subactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('€ Mitglied', $response, "activities.{$activity->id}");
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'billKinds.0');
$this->assertInertiaHas('Biber', $response, "meta.formSubactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('€ Mitglied', $response, "meta.formActivities.{$activity->id}");
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0');
$this->assertInertiaHas(['efz' => null, 'ps_at' => null, 'more_ps_at' => null, 'without_education_at' => null, 'without_efz_at' => null], $response, 'data');
}
@ -41,7 +41,7 @@ class CreateTest extends TestCase
$response = $this->get(route('member.create'));
$this->assertCount(0, $this->inertia($response, 'subactivities'));
$this->assertCount(0, $this->inertia($response, 'activities'));
$this->assertCount(0, $this->inertia($response, 'meta.formCreateSubactivities'));
$this->assertCount(0, $this->inertia($response, 'meta.formCreateActivities'));
}
}

View File

@ -22,14 +22,14 @@ class EditTest extends TestCase
$response = $this->get(route('member.edit', ['member' => $member]));
$this->assertInertiaHas('Biber', $response, "subactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('€ Mitglied', $response, "activities.{$activity->id}");
$this->assertInertiaHas('Biber', $response, "meta.formSubactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('€ Mitglied', $response, "meta.formActivities.{$activity->id}");
$this->assertInertiaHas('Max', $response, 'data.firstname');
$this->assertInertiaHas('Doktor', $response, 'data.salutation');
$this->assertInertiaHas('Lorem bla', $response, 'data.comment');
$this->assertInertiaHas('edit', $response, 'mode');
$this->assertInertiaHas(false, $response, 'conflict');
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'billKinds.0');
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0');
}
public function testItDisplaysEducation(): void

View File

@ -100,9 +100,9 @@ class IndexTest extends TestCase
$response = $this->get('/member');
$this->assertInertiaHas('Biber', $response, "subactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('Biber', $response, "filterSubactivities.{$subactivity->id}");
$this->assertInertiaHas('€ Mitglied', $response, "activities.{$activity->id}");
$this->assertInertiaHas('Biber', $response, "data.meta.formSubactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('Biber', $response, "data.meta.filterSubactivities.{$subactivity->id}");
$this->assertInertiaHas('€ Mitglied', $response, "data.meta.formActivities.{$activity->id}");
}
public function testItShowsActivityAndSubactivityNamesOfMember(): void