share the artist song ordering and pin it with a test

This commit is contained in:
austinried
2026-10-04 00:30:05 +00:00
parent 336ff1a1d1
commit 77c3959c48
2 changed files with 15 additions and 2 deletions
@@ -191,8 +191,8 @@ interface QueueDao {
@Query(
"SELECT songs.id FROM songs " +
"JOIN albums ON albums.sourceId = songs.sourceId AND albums.id = songs.albumId " +
"WHERE songs.sourceId = :sourceId AND albums.artistId = :artistId " +
"ORDER BY albums.year DESC, albums.name COLLATE NOCASE, albums.id, songs.disc, songs.track, songs.id",
"WHERE songs.sourceId = :sourceId AND albums.artistId = :artistId" +
ARTIST_SONGS_ORDER,
)
suspend fun artistSongIds(
sourceId: Long,
@@ -2282,6 +2282,19 @@ class PlaybackControllerTest {
assertEquals(setOf("a1", "a2", "a3", "b1", "b2"), handle.items.map { it.id }.toSet())
}
@Test
fun artistQueueRowsFollowTheFlatShuffleIdOrder() {
seedArtist()
runBlocking { queues.replace(listOf(queues.artistEntry(1, "ar1"))) }
val snapshot = runBlocking { queues.snapshot() }
val paged = (0 until snapshot.size).map { runBlocking { queues.itemAt(snapshot, it)?.song?.id } }
val flat = runBlocking { db.queueDao().artistSongIds(1, "ar1") }
assertEquals(listOf("b1", "b2", "a1", "a2", "a3"), flat)
assertEquals(flat, paged)
}
@Test
fun restoringResumesFromTheSavedPosition() {
seedAlbum(3, sourceId = 1)