mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
home: drop On repeat, restore starred, give artist lists the detail column
This commit is contained in:
@@ -335,24 +335,6 @@ class LibraryHomeDaoTest {
|
||||
assertEquals(displayed, dao.starredSongIds(sourceId))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onRepeatKeepsSongsPlayedThisWeekAndOrdersByPlayCount() =
|
||||
runTest {
|
||||
val sourceId = source()
|
||||
val dao = db.libraryDao()
|
||||
dao.upsertSongs(
|
||||
listOf(
|
||||
song(sourceId, "s1", "One", playCount = 3, played = 900),
|
||||
song(sourceId, "s2", "Two", playCount = 9, played = 950),
|
||||
song(sourceId, "s3", "Three", playCount = 100, played = 100),
|
||||
),
|
||||
)
|
||||
|
||||
val onRepeat = dao.onRepeatSongs(sourceId, cutoff = 500, limit = 5).first()
|
||||
assertEquals(listOf("s2", "s1"), onRepeat.map { it.song.id })
|
||||
assertEquals(listOf("s2", "s1"), dao.onRepeatSongIds(sourceId, cutoff = 500))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun songsByGenrePagingFiltersAndJoinsAlbumCoverArt() =
|
||||
runTest {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.subtracks.ui.home
|
||||
|
||||
import com.subtracks.data.model.Album
|
||||
import com.subtracks.data.model.Artist
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
@@ -49,6 +50,15 @@ class HomeListInfoTest {
|
||||
assertEquals("1999", albumListInfo(HomeListRequest(title = "1990s", decade = 1990), album, now))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun artistInfoMatchesTheSection() {
|
||||
val artist = artist(played = secondsAgo(3), playCount = 7)
|
||||
|
||||
assertEquals("3 days ago", artistListInfo(request(HomeSection.RecentlyPlayedArtists), artist, now))
|
||||
assertEquals("7 plays", artistListInfo(request(HomeSection.MostPlayedArtists), artist, now))
|
||||
assertNull(artistListInfo(request(HomeSection.MostPlayedArtists), artist.copy(playCount = 0, played = null), now))
|
||||
}
|
||||
|
||||
private fun secondsAgo(days: Long): Long = (now - days * 86_400_000L) / 1000L
|
||||
|
||||
private fun request(section: HomeSection) = HomeListRequest(title = section.title, section = section)
|
||||
@@ -73,4 +83,18 @@ class HomeListInfoTest {
|
||||
playCount = playCount,
|
||||
played = played,
|
||||
)
|
||||
|
||||
private fun artist(
|
||||
played: Long?,
|
||||
playCount: Long,
|
||||
) = Artist(
|
||||
sourceId = 1,
|
||||
id = "ar",
|
||||
name = "Artist",
|
||||
albumCount = 1,
|
||||
starred = null,
|
||||
coverArt = null,
|
||||
playCount = playCount,
|
||||
played = played,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -105,6 +105,44 @@ class HomeScreenshotTest {
|
||||
composeRule.onRoot().captureRoboImage("src/test/screenshots/home_album_list.png")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun homeRecentlyPlayedArtistsList() {
|
||||
val now = System.currentTimeMillis()
|
||||
val artists =
|
||||
listOf(
|
||||
listArtist("Artist Yesterday", (now - 86_400_000L) / 1000L),
|
||||
listArtist("Artist This Week", (now - 3 * 86_400_000L) / 1000L),
|
||||
)
|
||||
composeRule.setContent {
|
||||
SubtracksTheme {
|
||||
HomeListScreen(
|
||||
request = HomeListRequest(title = "Recently played artists", section = HomeSection.RecentlyPlayedArtists),
|
||||
albums = remember { flowOf(PagingData.empty<Album>()) }.collectAsLazyPagingItems(),
|
||||
artists = remember { flowOf(PagingData.from(artists)) }.collectAsLazyPagingItems(),
|
||||
songs = remember { flowOf(PagingData.empty<AlbumSongItem>()) }.collectAsLazyPagingItems(),
|
||||
coverArt = { _, _ -> null },
|
||||
)
|
||||
}
|
||||
}
|
||||
composeRule.waitUntil(timeoutMillis = 5_000) {
|
||||
composeRule.onAllNodesWithText("Artist Yesterday").fetchSemanticsNodes().isNotEmpty()
|
||||
}
|
||||
composeRule.onRoot().captureRoboImage("src/test/screenshots/home_artist_list.png")
|
||||
}
|
||||
|
||||
private fun listArtist(
|
||||
name: String,
|
||||
played: Long,
|
||||
) = Artist(
|
||||
sourceId = 1,
|
||||
id = name,
|
||||
name = name,
|
||||
albumCount = 4,
|
||||
starred = null,
|
||||
coverArt = null,
|
||||
played = played,
|
||||
)
|
||||
|
||||
private fun listAlbum(
|
||||
name: String,
|
||||
created: Long,
|
||||
@@ -131,7 +169,6 @@ class HomeScreenshotTest {
|
||||
genres = listOf("Rock", "Jazz", "Classical", "Electronic", "Pop", "Folk", "Blues"),
|
||||
decades = listOf(1960L, 1970L, 1980L, 1990L, 2000L, 2010L),
|
||||
recentlyStarredSongs = songs(),
|
||||
onRepeatSongs = songs(),
|
||||
recentlyAddedAlbums = albums("Added"),
|
||||
rediscoverAlbums = albums("Repeat"),
|
||||
)
|
||||
|
||||
@@ -26,7 +26,6 @@ class HomeViewModelTest {
|
||||
addedAlbums = listOf(album("c")),
|
||||
rediscover = listOf(album("d")),
|
||||
hasPlayData = true,
|
||||
onRepeatSongs = listOf(starred("repeat")),
|
||||
)
|
||||
|
||||
assertEquals(listOf("a"), feed.recentlyPlayedAlbums.map { it.id })
|
||||
@@ -36,7 +35,6 @@ class HomeViewModelTest {
|
||||
assertEquals(listOf("Rock"), feed.genres)
|
||||
assertEquals(listOf(1970L), feed.decades)
|
||||
assertEquals(listOf("song"), feed.recentlyStarredSongs.map { it.song.id })
|
||||
assertEquals(listOf("repeat"), feed.onRepeatSongs.map { it.song.id })
|
||||
assertEquals(listOf("c"), feed.recentlyAddedAlbums.map { it.id })
|
||||
assertEquals(listOf("d"), feed.rediscoverAlbums.map { it.id })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user