T20: Song DB Page - Songs/Index.vue with search, action buttons, pagination - Upload area for .pro files (calls T23 placeholder) - Song-Datenbank nav link added to AuthenticatedLayout - Tests: 9 new (44 assertions) T21: Song DB Edit Popup - SongEditModal.vue with metadata + ArrangementConfigurator - Auto-save with fetch (500ms debounce for text, immediate on blur) - Tests: 11 new (53 assertions) T22: Song DB Translate Page - Songs/Translate.vue with two-column editor - URL fetch or manual paste, line-count constraints - Group headers with colors, save marks has_translation=true - Tests: 1 new (12 assertions) T23: .pro File Placeholders - ProParserNotImplementedException with HTTP 501 - ProFileController with importPro/downloadPro placeholders - German error messages - Tests: 5 new (7 assertions) T24: Service Finalization + Status - Two-step finalization with warnings (unmatched songs, missing slides) - Download placeholder toast - isReadyToFinalize accessor on Service model - Tests: 11 new (30 assertions) All tests passing: 174/174 (905 assertions) Build: ✓ Vite production build successful German UI: All user-facing text in German with 'Du' form
84 lines
3 KiB
PHP
84 lines
3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Http\Controllers\TranslationController;
|
|
use App\Models\Song;
|
|
use App\Models\SongGroup;
|
|
use App\Models\SongSlide;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Tests\TestCase;
|
|
|
|
final class TranslatePageTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_translate_page_response_contains_ordered_groups_and_slides(): void
|
|
{
|
|
$song = Song::factory()->create([
|
|
'title' => 'Grosser Gott',
|
|
]);
|
|
|
|
$groupLater = SongGroup::factory()->create([
|
|
'song_id' => $song->id,
|
|
'name' => 'Refrain',
|
|
'color' => '#22c55e',
|
|
'order' => 2,
|
|
]);
|
|
|
|
$groupFirst = SongGroup::factory()->create([
|
|
'song_id' => $song->id,
|
|
'name' => 'Strophe 1',
|
|
'color' => '#0ea5e9',
|
|
'order' => 1,
|
|
]);
|
|
|
|
SongSlide::factory()->create([
|
|
'song_group_id' => $groupFirst->id,
|
|
'order' => 2,
|
|
'text_content' => "Zeile A\nZeile B",
|
|
'text_content_translated' => "Line A\nLine B",
|
|
]);
|
|
|
|
SongSlide::factory()->create([
|
|
'song_group_id' => $groupFirst->id,
|
|
'order' => 1,
|
|
'text_content' => "Zeile C\nZeile D\nZeile E",
|
|
'text_content_translated' => null,
|
|
]);
|
|
|
|
SongSlide::factory()->create([
|
|
'song_group_id' => $groupLater->id,
|
|
'order' => 1,
|
|
'text_content' => 'Refrain',
|
|
'text_content_translated' => 'Chorus',
|
|
]);
|
|
|
|
$controller = app(TranslationController::class);
|
|
$inertiaResponse = $controller->page($song);
|
|
|
|
$request = Request::create('/songs/'.$song->id.'/translate', 'GET');
|
|
$request->headers->set('X-Inertia', 'true');
|
|
|
|
$response = $inertiaResponse->toResponse($request);
|
|
|
|
$this->assertInstanceOf(JsonResponse::class, $response);
|
|
|
|
$payload = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
|
|
|
$this->assertSame('Songs/Translate', $payload['component']);
|
|
$this->assertSame($song->id, $payload['props']['song']['id']);
|
|
$this->assertSame('Grosser Gott', $payload['props']['song']['title']);
|
|
$this->assertCount(2, $payload['props']['song']['groups']);
|
|
$this->assertSame('Strophe 1', $payload['props']['song']['groups'][0]['name']);
|
|
$this->assertSame(1, $payload['props']['song']['groups'][0]['slides'][0]['order']);
|
|
$this->assertSame("Zeile C\nZeile D\nZeile E", $payload['props']['song']['groups'][0]['slides'][0]['text_content']);
|
|
$this->assertSame(2, $payload['props']['song']['groups'][0]['slides'][1]['order']);
|
|
$this->assertSame("Zeile A\nZeile B", $payload['props']['song']['groups'][0]['slides'][1]['text_content']);
|
|
$this->assertSame('Refrain', $payload['props']['song']['groups'][1]['name']);
|
|
$this->assertSame('Chorus', $payload['props']['song']['groups'][1]['slides'][0]['text_content_translated']);
|
|
}
|
|
}
|