address shuffle review findings

This commit is contained in:
austinried
2026-10-04 00:29:55 +00:00
parent 4cad4bc481
commit 2c333195ef
4 changed files with 76 additions and 26 deletions
@@ -320,6 +320,20 @@ class QueueRepositoryTest {
private suspend fun resolveAll(snapshot: QueueSnapshot): List<String> =
(0 until snapshot.size).mapNotNull { repository.itemAt(snapshot, it)?.song?.id }
@Test
fun aStaleShuffleOrderIsDroppedWhenTheQueueLengthChanges() =
runTest {
seedLibrary()
repository.replace(listOf(repository.albumEntry(1, "al1")))
repository.setShuffle(true, longArrayOf(2, 0, 1))
assertTrue(repository.snapshot().shuffled)
db.libraryDao().upsertSongs(listOf(song("s6", "al1", track = 4, album = "First Album")))
assertFalse(repository.snapshot().shuffled)
assertFalse(repository.modes().shuffle)
}
private suspend fun seedLibrary() {
db.sourcesDao().upsertSource(
Source(id = 1, name = "test", address = "http://localhost", isActive = true, createdAt = 0),
@@ -795,6 +795,30 @@ class PlaybackControllerTest {
)
}
@Test
fun repeatAllLoopsASingleTrackQueue() {
seedAlbum(1, sourceId = 1)
controller.playAlbum(1, "al1", 0)
await {
controller.state.value.item
?.id == "s1" && controller.state.value.isPlaying
}
controller.cycleRepeat()
assertEquals(RepeatMode.All, controller.state.value.repeat)
handle.finish()
handle.emitEvents()
await { controller.state.value.isPlaying }
assertEquals(
"s1",
controller.state.value.item
?.id,
)
}
private fun seedAlbum(
count: Int,
sourceId: Long,