mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
artists: show a credited track artist's name and type on their page
A track artist without an artists row had no name on the artist page, so the header and the placeholder letter were blank. Derive the name from the songs that credit them, and label the page 'Album artist' when they lead an album or 'Artist' when they are only credited on tracks. The hero art keeps the letter placeholder when there is no artist image.
This commit is contained in:
@@ -558,6 +558,20 @@ class LibraryDaoTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aCreditedTrackArtistsNameComesFromItsSongs() =
|
||||
runTest {
|
||||
val sourceId = source()
|
||||
val dao = db.libraryDao()
|
||||
dao.upsertSongs(
|
||||
listOf(
|
||||
song(sourceId, "s1", "One", starred = null).copy(artistId = "ar-guest", artist = "Guest"),
|
||||
),
|
||||
)
|
||||
|
||||
assertEquals("Guest", dao.artistName(sourceId, "ar-guest").first())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun downloadedFilterReportsTheDownloadedAlbumCount() =
|
||||
runTest {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.subtracks.ui.library
|
||||
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
|
||||
import androidx.compose.ui.test.onAllNodesWithText
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.subtracks.data.model.Artist
|
||||
import com.subtracks.ui.theme.SubtracksTheme
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class ArtistDetailScreenTest {
|
||||
@get:Rule
|
||||
val composeRule = createAndroidComposeRule<ComponentActivity>()
|
||||
|
||||
private fun render(
|
||||
artist: Artist?,
|
||||
artistName: String,
|
||||
isAlbumArtist: Boolean,
|
||||
) {
|
||||
composeRule.setContent {
|
||||
SubtracksTheme {
|
||||
ArtistDetailScreen(
|
||||
artist = artist,
|
||||
artistName = artistName,
|
||||
isAlbumArtist = isAlbumArtist,
|
||||
albums = emptyList(),
|
||||
art = null,
|
||||
coverArt = { _, _ -> null },
|
||||
onBack = {},
|
||||
onAlbumClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aCreditedTrackArtistShowsItsDerivedNameAndIsLabelledArtist() {
|
||||
render(artist = null, artistName = "Guest", isAlbumArtist = false)
|
||||
|
||||
composeRule.onAllNodesWithText("Guest")[0].assertExists()
|
||||
composeRule.onNodeWithText("Artist").assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anAlbumArtistIsLabelledAlbumArtist() {
|
||||
render(
|
||||
artist = Artist(sourceId = 1, id = "ar-1", name = "Radiohead", albumCount = 1, starred = null),
|
||||
artistName = "Radiohead",
|
||||
isAlbumArtist = true,
|
||||
)
|
||||
|
||||
composeRule.onNodeWithText("Album artist").assertExists()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user