From 733a4d294177f3c7fcf52281943f89848f4db9ca Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Mon, 19 Oct 2026 03:18:16 +0000 Subject: [PATCH] ui: pin the downloaded artist album visibility rules Distinguish the album-credit rule (any downloaded song on the album) from the track-credit rule (the credited track itself must be downloaded) in the repository test, so a swap of those clauses fails. --- .../data/repo/LibraryRepositoryTest.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/test/kotlin/com/subtracks/data/repo/LibraryRepositoryTest.kt b/app/src/test/kotlin/com/subtracks/data/repo/LibraryRepositoryTest.kt index 3e6a7a59..0e7315d7 100644 --- a/app/src/test/kotlin/com/subtracks/data/repo/LibraryRepositoryTest.kt +++ b/app/src/test/kotlin/com/subtracks/data/repo/LibraryRepositoryTest.kt @@ -250,18 +250,25 @@ class LibraryRepositoryTest { listOf( seedSong(sourceId).copy(albumId = "al-0001"), seedSong(sourceId).copy(id = "s2", albumId = "al-0002"), + seedSong(sourceId).copy(id = "s3", albumId = "al-0002", artistId = "ar2"), + seedSong(sourceId).copy(id = "s4", albumId = "al-0001", artistId = "ar2"), ), ) - db.downloadDao().upsert(SongDownload(sourceId, "s1", DownloadStatus.Completed)) - val before = repository.artistAlbums(sourceId, "ar1", downloaded = true).first() - assertEquals(listOf("al-0001"), before.albumCredits.map { it.id }) - assertEquals(emptyList(), before.appearances.map { it.id }) + db.downloadDao().upsert(SongDownload(sourceId, "s4", DownloadStatus.Completed)) + val otherOnAlbumCredit = repository.artistAlbums(sourceId, "ar1", downloaded = true).first() + assertEquals(listOf("al-0001"), otherOnAlbumCredit.albumCredits.map { it.id }) + assertEquals(emptyList(), otherOnAlbumCredit.appearances.map { it.id }) + + db.downloadDao().upsert(SongDownload(sourceId, "s3", DownloadStatus.Completed)) + val otherOnTrackCredit = repository.artistAlbums(sourceId, "ar1", downloaded = true).first() + assertEquals(listOf("al-0001"), otherOnTrackCredit.albumCredits.map { it.id }) + assertEquals(emptyList(), otherOnTrackCredit.appearances.map { it.id }) db.downloadDao().upsert(SongDownload(sourceId, "s2", DownloadStatus.Completed)) - val after = repository.artistAlbums(sourceId, "ar1", downloaded = true).first() - assertEquals(listOf("al-0001"), after.albumCredits.map { it.id }) - assertEquals(listOf("al-0002"), after.appearances.map { it.id }) + val creditedTrack = repository.artistAlbums(sourceId, "ar1", downloaded = true).first() + assertEquals(listOf("al-0001"), creditedTrack.albumCredits.map { it.id }) + assertEquals(listOf("al-0002"), creditedTrack.appearances.map { it.id }) } private suspend fun awaitRefreshes(