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 = SongGroup::factory()->create([ 'song_id' => $song->id, 'name' => 'Strophe 1', 'color' => '#3B82F6', 'order' => 1, ]); $chorus = SongGroup::factory()->create([ 'song_id' => $song->id, 'name' => 'Refrain', 'color' => '#10B981', 'order' => 2, ]); $normal = SongArrangement::factory()->create([ 'song_id' => $song->id, 'name' => 'Normal', 'is_default' => true, ]); SongArrangementGroup::factory()->create([ 'song_arrangement_id' => $normal->id, 'song_group_id' => $verse->id, 'order' => 1, ]); SongArrangementGroup::factory()->create([ 'song_arrangement_id' => $normal->id, 'song_group_id' => $chorus->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) ); } }