T8: Service List Page - ServiceController with index, finalize, reopen actions - Services/Index.vue with status indicators (songs mapped/arranged, slides uploaded) - German UI with finalize/reopen toggle buttons - Status aggregation via SQL subqueries for efficiency - Tests: 3 passing (46 assertions) T9: Song CRUD Backend - SongController with full REST API (index, store, show, update, destroy) - SongService for default groups/arrangements creation - SongRequest validation (title required, ccli_id unique) - Search by title and CCLI ID - last_used_in_service accessor via service_songs join - Tests: 20 passing (85 assertions) T10: Slide Upload Component - SlideController with store, destroy, updateExpireDate - SlideUploader.vue with vue3-dropzone drag-and-drop - SlideGrid.vue with thumbnail grid and inline expire date editing - Multi-format support: images (sync), PPT (async job), ZIP (extract) - Type validation: information (global), moderation/sermon (service-specific) - Tests: 15 passing (37 assertions) T11: Arrangement Configurator - ArrangementController with store, clone, update, destroy - ArrangementConfigurator.vue with vue-draggable-plus - Drag-and-drop arrangement editor with colored group pills - Clone from default or existing arrangement - Color picker for group customization - Prevent deletion of last arrangement - Tests: 4 passing (17 assertions) T12: Song Matching Service - SongMatchingService with autoMatch, manualAssign, requestCreation, unassign - ServiceSongController API endpoints for song assignment - Auto-match by CCLI ID during CTS sync - Manual assignment with searchable song select - Email request for missing songs (MissingSongRequest mailable) - Tests: 14 passing (33 assertions) T13: Translation Service - TranslationService with fetchFromUrl, importTranslation, removeTranslation - TranslationController API endpoints - URL scraping (best-effort HTTP fetch with strip_tags) - Line-count distribution algorithm (match original slide line counts) - Mark song as translated, remove translation - Tests: 18 passing (18 assertions) All tests passing: 103/103 (488 assertions) Build: ✓ Vite production build successful German UI: All user-facing text in German with 'Du' form
180 lines
5.7 KiB
PHP
180 lines
5.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Service;
|
|
use App\Models\ServiceSong;
|
|
use App\Models\Slide;
|
|
use App\Models\Song;
|
|
use App\Models\SongArrangement;
|
|
use App\Models\User;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
final class ServiceControllerTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_services_index_zeigt_nur_heutige_und_kuenftige_services_mit_statusdaten(): void
|
|
{
|
|
Carbon::setTestNow('2026-03-01 10:00:00');
|
|
$this->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);
|
|
}
|
|
}
|