downloads: address review on the cancel/progress rows

Name the cancel and delete buttons after the row so screen readers can
tell them apart, show an indeterminate bar when a running track has no
known total, and drop the no-op media refresh on cancel. Trim the dead
size alias and a redundant guard, and cover a queued row with no engine
id plus a failed track in the progress denominator.
This commit is contained in:
austinried
2026-10-04 00:30:07 +00:00
parent 196733f9a7
commit 4ddbefe7cd
6 changed files with 43 additions and 16 deletions
@@ -58,6 +58,20 @@ class DownloadTreeTest {
assertNull(nodeProgress(listOf(song("s3", "Three", "ar1", "Artist", "al1", "Album", size = 1))))
}
@Test
fun nodeProgressCountsAFailedTrackInTheDenominator() {
val songs =
listOf(
song("s1", "One", "ar1", "Artist", "al1", "Album", size = 100),
song("s2", "Two", "ar1", "Artist", "al1", "Album", size = 100)
.copy(status = DownloadStatus.Failed),
song("s3", "Three", "ar1", "Artist", "al1", "Album", size = 100)
.copy(status = DownloadStatus.Running, bytes = 50, total = 100),
)
assertEquals(0.5f, nodeProgress(songs)!!, 0.0001f)
}
private fun song(
id: String,
title: String,
@@ -53,10 +53,10 @@ class DownloadsScreenTest {
onCancel = { cancelled = it },
)
composeRule.onAllNodesWithContentDescription("Cancel download").assertCountEquals(1)
composeRule.onAllNodesWithContentDescription("Delete downloads").assertCountEquals(1)
composeRule.onAllNodesWithContentDescription("Cancel download", substring = true).assertCountEquals(1)
composeRule.onAllNodesWithContentDescription("Delete downloads", substring = true).assertCountEquals(1)
composeRule.onNodeWithContentDescription("Cancel download").performClick()
composeRule.onNodeWithContentDescription("Cancel download of Active").performClick()
assertEquals(listOf("s1"), cancelled)
}
@@ -66,8 +66,8 @@ class DownloadsScreenTest {
expandArtistAndAlbum()
composeRule.onAllNodesWithContentDescription("Cancel download").assertCountEquals(3)
composeRule.onAllNodesWithContentDescription("Delete download").assertCountEquals(1)
composeRule.onAllNodesWithContentDescription("Cancel download", substring = true).assertCountEquals(3)
composeRule.onAllNodesWithContentDescription("Delete download of Done").assertCountEquals(1)
}
private fun artist(
@@ -150,6 +150,17 @@ class DownloadsViewModelTest {
assertNotNull("a completed download should survive a cancel", row("s2"))
}
@Test
fun cancelSongsRemovesAQueuedDownloadWithoutAnEngineId() {
seedDownloads()
runBlocking { db.downloadDao().upsert(SongDownload(sourceId, "s1", DownloadStatus.Queued, engineId = null)) }
viewModel.cancelSongs(listOf("s1"))
await { row("s1") == null }
assertNull(row("s1"))
}
private fun seedDownloads() {
sourceId =
runBlocking {