search: list playlists before artists, albums and songs

Order the result sections smallest-first and apply the review fixes: pad
the filter bar for the navigation bar, keep at least one filter enabled,
hide the clear button on an empty field, drop the unused autoFocus and
bar-modifier parameters, and test the filter mask and section order.
This commit is contained in:
austinried
2026-10-04 00:30:08 +00:00
parent 5d81c2dc41
commit f6e087b6ab
3 changed files with 78 additions and 16 deletions
@@ -14,6 +14,7 @@ import com.subtracks.data.model.Playlist
import com.subtracks.data.model.Song
import com.subtracks.ui.theme.SubtracksTheme
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -147,6 +148,59 @@ class SearchScreenTest {
assertEquals(SearchFilter.Playlists, toggled)
}
@Test
fun smallerGroupsAreListedFirst() {
composeRule.setContent {
SubtracksTheme {
SearchScreen(
query = "road",
onQueryChange = {},
results =
SearchResults(
albums = listOf(album("al-1", "Road Album")),
artists = listOf(artist("ar-1", "Road Artist")),
playlists = listOf(playlist("pl-1", "Road Trip")),
songs = listOf(AlbumSongItem(song("s1", "Road Song"), coverArt = null)),
),
)
}
}
val playlistTop =
composeRule
.onNodeWithText("Road Trip")
.fetchSemanticsNode()
.boundsInRoot.top
val artistTop =
composeRule
.onNodeWithText("Road Artist")
.fetchSemanticsNode()
.boundsInRoot.top
val albumTop =
composeRule
.onNodeWithText("Road Album")
.fetchSemanticsNode()
.boundsInRoot.top
val songTop =
composeRule
.onNodeWithText("Road Song")
.fetchSemanticsNode()
.boundsInRoot.top
assertTrue("playlists should come first", playlistTop < artistTop)
assertTrue("artists should come before albums", artistTop < albumTop)
assertTrue("albums should come before songs", albumTop < songTop)
}
@Test
fun filterMaskRoundTrips() {
assertEquals(SearchFilter.entries.toSet(), maskToFilters(allFilterMask()))
val withoutSongs = allFilterMask() and (1 shl SearchFilter.Songs.ordinal).inv()
assertEquals(SearchFilter.entries.toSet() - SearchFilter.Songs, maskToFilters(withoutSongs))
}
private fun album(
id: String,
name: String,