Add test for activity

This commit is contained in:
Philipp Lang 2022-11-16 16:30:23 +01:00
parent 388115556d
commit 14bd07d4a8
3 changed files with 43 additions and 0 deletions
database/factories
tests/Feature/Member

View File

@ -29,4 +29,9 @@ class ActivityFactory extends Factory
{
return $this->state(['nami_id' => $namiId]);
}
public function name(string $name): self
{
return $this->state(['name' => $name]);
}
}

View File

@ -34,4 +34,14 @@ class SubactivityFactory extends Factory
{
return $this->state(['is_age_group' => true]);
}
public function name(string $name): self
{
return $this->state(['name' => $name]);
}
public function filterable(): self
{
return $this->state(['is_filterable' => true]);
}
}

View File

@ -72,4 +72,32 @@ class IndexTest extends TestCase
$this->assertInertiaHas(false, $response, 'data.data.1.is_leader');
$this->assertInertiaHas(false, $response, 'data.data.2.is_leader');
}
public function testItShowsAgeGroupIcon(): void
{
$this->withoutExceptionHandling();
$this->login()->loginNami();
$member = Member::factory()
->defaults()
->has(Membership::factory()->for(Subactivity::factory()->ageGroup()->name('Wölfling'))->for(Activity::factory()->state(['has_efz' => false])))
->create();
$response = $this->get('/member');
$this->assertInertiaHas('woelfling', $response, 'data.data.0.age_group_icon');
}
public function testItShowsActivitiesAndSubactivities(): void
{
$this->withoutExceptionHandling();
$this->login()->loginNami();
$activity = Activity::factory()->hasAttached(Subactivity::factory()->name('SG Nahost')->ageGroup()->filterable())->name('Mitglied')->create();
$subactivity = $activity->subactivities->first();
$response = $this->get('/member');
$this->assertInertiaHas('SG Nahost', $response, "subactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('SG Nahost', $response, "filterSubactivities.{$subactivity->id}");
$this->assertInertiaHas('Mitglied', $response, "activities.{$activity->id}");
}
}