fix drag drop target, serialize queue edits, guard empty ranges

This commit is contained in:
austinried
2026-10-04 00:29:52 +00:00
parent bab303ef91
commit e76976dfdf
3 changed files with 102 additions and 31 deletions
@@ -437,6 +437,49 @@ class PlaybackControllerTest {
)
}
@Test
fun movingTracksFarFromThePlayingOneDoesNotReloadTheWindow() {
seedAlbum(100, sourceId = 1)
controller.playAlbum(1, "al1", 50)
await {
controller.state.value.item
?.id == "s51"
}
handle.operations.clear()
runBlocking { controller.move(80, 90) }
assertEquals(
"s51",
controller.state.value.item
?.id,
)
assertEquals(50L, controller.state.value.position)
assertFalse(handle.operations.any { it.startsWith("setWindow") })
}
@Test
fun movingATrackAcrossTheWindowKeepsPlaying() {
seedAlbum(100, sourceId = 1)
controller.playAlbum(1, "al1", 50)
await {
controller.state.value.item
?.id == "s51"
}
handle.operations.clear()
runBlocking { controller.move(10, 90) }
assertEquals(
"s51",
controller.state.value.item
?.id,
)
assertFalse(handle.operations.any { it.startsWith("setWindow") })
}
@Test
fun undoRestoresARemovedTrack() {
seedAlbum(5, sourceId = 1)
@@ -82,6 +82,22 @@ class QueueViewModelTest {
assertEquals((40L..199L).toList(), viewModel.rows.map { it.position })
}
@Test
fun openingAtTheEndLoadsASingleRowAndExtendsOlder() {
runBlocking { seedSongs(200) }
controller.playSongs(1, 199)
await { controller.state.value.position == 199L }
viewModel.open()
await { viewModel.ready }
assertEquals(listOf(199L), viewModel.rows.map { it.position })
viewModel.loadOlder()
await { viewModel.rows.firstOrNull()?.position == 139L }
assertEquals((139L..199L).toList(), viewModel.rows.map { it.position })
}
@Test
fun reorderingMovesTheRowLocally() {
runBlocking { seedSongs(200) }