withoutVite(); $user = User::factory()->create(); Service::factory()->create([ 'date' => Carbon::today()->subDay(), 'finalized_at' => null, ]); $todayService = Service::factory()->create([ 'title' => 'Gottesdienst Heute', 'date' => Carbon::today(), 'finalized_at' => null, ]); $futureService = Service::factory()->create([ 'title' => 'Gottesdienst Zukunft', 'date' => Carbon::today()->addDays(3), 'finalized_at' => null, ]); $song = Song::factory()->create(); $arrangement = SongArrangement::factory()->create([ 'song_id' => $song->id, ]); ServiceSong::create([ 'service_id' => $todayService->id, 'song_id' => $song->id, 'song_arrangement_id' => $arrangement->id, 'use_translation' => false, 'order' => 1, 'cts_song_name' => 'Song 1', 'cts_ccli_id' => '100001', ]); ServiceSong::create([ 'service_id' => $todayService->id, 'song_id' => $song->id, 'song_arrangement_id' => null, 'use_translation' => false, 'order' => 2, 'cts_song_name' => 'Song 2', 'cts_ccli_id' => '100002', ]); ServiceSong::create([ 'service_id' => $todayService->id, 'song_id' => null, 'song_arrangement_id' => null, 'use_translation' => false, 'order' => 3, 'cts_song_name' => 'Song 3', 'cts_ccli_id' => '100003', ]); ServiceSong::create([ 'service_id' => $futureService->id, 'song_id' => $song->id, 'song_arrangement_id' => $arrangement->id, 'use_translation' => false, 'order' => 1, 'cts_song_name' => 'Song 4', 'cts_ccli_id' => '100004', ]); ServiceSong::create([ 'service_id' => $futureService->id, 'song_id' => null, 'song_arrangement_id' => null, 'use_translation' => false, 'order' => 2, 'cts_song_name' => 'Song 5', 'cts_ccli_id' => '100005', ]); Slide::factory()->create([ 'service_id' => $todayService->id, 'type' => 'sermon', 'expire_date' => null, ]); Slide::factory()->create([ 'service_id' => null, 'type' => 'information', 'expire_date' => Carbon::today()->addDay(), ]); Slide::factory()->create([ 'service_id' => null, 'type' => 'information', 'expire_date' => Carbon::today()->addDays(5), ]); Slide::factory()->create([ 'service_id' => $todayService->id, 'type' => 'information', 'expire_date' => Carbon::today()->addDays(10), ]); Slide::factory()->create([ 'service_id' => null, 'type' => 'information', 'expire_date' => Carbon::today()->subDay(), ]); $response = $this->actingAs($user)->get(route('services.index')); $response->assertOk(); $response->assertInertia( fn ($page) => $page ->component('Services/Index') ->has('services', 2) ->where('services.0.id', $todayService->id) ->where('services.0.title', 'Gottesdienst Heute') ->where('services.0.songs_total_count', 3) ->where('services.0.songs_mapped_count', 2) ->where('services.0.songs_arranged_count', 1) ->where('services.0.has_sermon_slides', true) ->where('services.0.info_slides_count', 3) ->where('services.1.id', $futureService->id) ->where('services.1.title', 'Gottesdienst Zukunft') ->where('services.1.songs_total_count', 2) ->where('services.1.songs_mapped_count', 1) ->where('services.1.songs_arranged_count', 1) ->where('services.1.has_sermon_slides', false) ->where('services.1.info_slides_count', 1) ); } public function test_service_kann_abgeschlossen_werden(): void { Carbon::setTestNow('2026-03-01 10:00:00'); $user = User::factory()->create(); $service = Service::factory()->create([ 'finalized_at' => null, ]); $response = $this->actingAs($user)->post(route('services.finalize', $service)); $response->assertRedirect(route('services.index')); $this->assertSame(now()->toDateTimeString(), $service->fresh()->finalized_at?->toDateTimeString()); } public function test_service_kann_wieder_geoeffnet_werden(): void { $user = User::factory()->create(); $service = Service::factory()->create([ 'finalized_at' => now(), ]); $response = $this->actingAs($user)->post(route('services.reopen', $service)); $response->assertRedirect(route('services.index')); $this->assertNull($service->fresh()->finalized_at); } }