Refactor lyric storage so each song owns its sections instead of sharing global labels. Adds song_sections (per song+label) owning song_slides; labels stay global ProPresenter group tags (name/color/macro). Arrangements now reference sections, so editing/importing one song no longer corrupts others that share a label name. - New: song_sections table + migration with safe backfill; SongSection, SongArrangementSection models; SongSectionController (edit/add/delete sections, immediate persistence) wired into SongEditModal. - Refactor writers/readers: CcliImport, ProImport, SongService, ArrangementController, SongController, ProExport, PDF, Translation (translation reset now section-scoped), CCLI pairing. - CCLI import fixes: parse SongSelect copy-icon format (German "Vers" abbrev + trailing author), fill empty CTS-synced songs instead of blocking as duplicate, distinct label colors per section kind, import&edit/existing-song open the edit modal (no 404/405), teleport paste dialog above assign dialog, preview shows section content, correct SongSelect search URL, copy-icon instructions. - Bookmarklet clicks #generalCopyLyricsButton and captures clipboard; serves correct host from request. - Export: embed key-visual/background under fixed bundle-relative names. - Tests updated for the section model; new section + isolation coverage.
139 lines
4.4 KiB
PHP
139 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Label;
|
|
use App\Models\Service;
|
|
use App\Models\ServiceSong;
|
|
use App\Models\Song;
|
|
use App\Models\SongArrangement;
|
|
use App\Models\SongArrangementLabel;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Tests\TestCase;
|
|
|
|
final class SongsBlockTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_songs_block_shows_unmatched_song_with_matching_options(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
$service = Service::factory()->create();
|
|
|
|
Song::factory()->create([
|
|
'title' => 'Amazing Grace',
|
|
'ccli_id' => '22025',
|
|
]);
|
|
|
|
Song::factory()->create([
|
|
'title' => 'How Great Is Our God',
|
|
'ccli_id' => '4348399',
|
|
]);
|
|
|
|
ServiceSong::factory()->create([
|
|
'service_id' => $service->id,
|
|
'order' => 2,
|
|
'song_id' => null,
|
|
'cts_song_name' => 'Unmatched Song',
|
|
'cts_ccli_id' => '123456',
|
|
]);
|
|
|
|
ServiceSong::factory()->create([
|
|
'service_id' => $service->id,
|
|
'order' => 1,
|
|
'song_id' => null,
|
|
'cts_song_name' => 'First Song',
|
|
'cts_ccli_id' => '654321',
|
|
]);
|
|
|
|
Auth::login($user);
|
|
|
|
$response = $this->get(route('services.edit', $service));
|
|
|
|
$response->assertOk();
|
|
$response->assertInertia(
|
|
fn ($page) => $page
|
|
->component('Services/Edit')
|
|
->has('serviceSongs', 2)
|
|
->where('serviceSongs.0.cts_song_name', 'First Song')
|
|
->where('serviceSongs.0.song_id', null)
|
|
->where('serviceSongs.1.cts_song_name', 'Unmatched Song')
|
|
->where('serviceSongs.1.song_id', null)
|
|
->has('songsCatalog')
|
|
->where('songsCatalog', fn ($songsCatalog) => collect($songsCatalog)->contains(
|
|
fn (array $song) => $song['title'] === 'Amazing Grace' && $song['ccli_id'] === '22025'
|
|
))
|
|
);
|
|
}
|
|
|
|
public function test_songs_block_provides_matched_song_data_for_arrangement_configurator_and_translation_toggle(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
$service = Service::factory()->create();
|
|
|
|
$song = Song::factory()->create([
|
|
'title' => 'Living Hope',
|
|
'ccli_id' => '7106807',
|
|
'has_translation' => true,
|
|
]);
|
|
|
|
$verse = Label::factory()->create([
|
|
'name' => 'Strophe 1',
|
|
'color' => '#3B82F6',
|
|
]);
|
|
|
|
$chorus = Label::factory()->create([
|
|
'name' => 'Refrain',
|
|
'color' => '#10B981',
|
|
]);
|
|
$verseSection = songSectionFor($song, $verse, 1);
|
|
$chorusSection = songSectionFor($song, $chorus, 2);
|
|
|
|
$normal = SongArrangement::factory()->create([
|
|
'song_id' => $song->id,
|
|
'name' => 'Normal',
|
|
'is_default' => true,
|
|
]);
|
|
|
|
SongArrangementLabel::factory()->create([
|
|
'song_arrangement_id' => $normal->id,
|
|
'song_section_id' => $verseSection->id,
|
|
'order' => 1,
|
|
]);
|
|
|
|
SongArrangementLabel::factory()->create([
|
|
'song_arrangement_id' => $normal->id,
|
|
'song_section_id' => $chorusSection->id,
|
|
'order' => 2,
|
|
]);
|
|
|
|
ServiceSong::factory()->create([
|
|
'service_id' => $service->id,
|
|
'order' => 1,
|
|
'song_id' => $song->id,
|
|
'song_arrangement_id' => $normal->id,
|
|
'use_translation' => true,
|
|
'cts_song_name' => 'Living Hope',
|
|
'cts_ccli_id' => '7106807',
|
|
]);
|
|
|
|
Auth::login($user);
|
|
|
|
$response = $this->get(route('services.edit', $service));
|
|
|
|
$response->assertOk();
|
|
$response->assertInertia(
|
|
fn ($page) => $page
|
|
->component('Services/Edit')
|
|
->where('serviceSongs.0.song_id', $song->id)
|
|
->where('serviceSongs.0.song.has_translation', true)
|
|
->where('serviceSongs.0.song.arrangements.0.name', 'Normal')
|
|
->where('serviceSongs.0.song.arrangements.0.groups.0.name', 'Strophe 1')
|
|
->where('serviceSongs.0.song.groups.0.name', 'Strophe 1')
|
|
->where('serviceSongs.0.song_arrangement_id', $normal->id)
|
|
);
|
|
}
|
|
}
|