From 1bc08244ae7ecfb355c5dd2f2011bea2237654bc Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 2 Dec 2026 17:30:15 -0500 Subject: [PATCH] test(android): merge repeated cases into tables, drop setter and action-name echoes (#8301) Repeated cases are parameterized: speaker-id forms, the idle timer, drag rounding, volume clamping and a playlist's cache verdict. Removed: tests that a one-line setter set its field, that a mocked null came back null, that three UPnP commands send the action name written beside them, and the update repository's copy of the versioning rule its own test holds. Sonos album play now checks only what its queue adds to GainMath's rule, which GainMathTest owns. Cover URLs are checked against the host the interceptors rewrite rather than a copied string. Web's drag table gets back the 56px case Android's mirrors. Co-Authored-By: Claude Opus 5.5 --- .../library/data/LibraryRepositoryTest.kt | 10 --- .../minstrel/models/CoverUrlsTest.kt | 23 +++---- .../minstrel/player/RemotePlayerStateTest.kt | 59 ++--------------- .../player/output/IdleRevertDecisionTest.kt | 64 +++++------------- .../player/output/SonosAlbumPlayTest.kt | 35 +++------- .../output/upnp/AVTransportClientTest.kt | 32 --------- .../player/output/upnp/BareUdnTest.kt | 54 +++++---------- .../output/upnp/RenderingControlClientTest.kt | 26 ++------ .../data/PlaylistsRepositoryCacheMergeTest.kt | 49 +++++--------- .../shared/widgets/ReorderDragMathTest.kt | 65 +++++++------------ .../update/data/UpdateRepositoryTest.kt | 5 -- web/src/lib/components/queue-row-math.test.ts | 1 + 12 files changed, 105 insertions(+), 318 deletions(-) diff --git a/android/app/src/test/java/com/fabledsword/minstrel/library/data/LibraryRepositoryTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/library/data/LibraryRepositoryTest.kt index aa0ebb73..93f64a93 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/library/data/LibraryRepositoryTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/library/data/LibraryRepositoryTest.kt @@ -103,14 +103,4 @@ class LibraryRepositoryTest { coVerify { artistDao.upsertAll(match { it.size == 1 && it[0].id == "a1" }) } coVerify { albumDao.upsertAll(match { it.size == 2 && it[0].id == "al1" && it[1].id == "al2" }) } } - - @Test - fun `getArtist returns null when DAO is empty`() = runTest { - coEvery { artistDao.getById("missing") } returns null - val repo = LibraryRepository(artistDao, albumDao, trackDao, retrofit) - - val result = repo.getArtist("missing") - - assertEquals(null, result) - } } diff --git a/android/app/src/test/java/com/fabledsword/minstrel/models/CoverUrlsTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/models/CoverUrlsTest.kt index a5595692..fd1e39fa 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/models/CoverUrlsTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/models/CoverUrlsTest.kt @@ -1,26 +1,19 @@ package com.fabledsword.minstrel.models +import com.fabledsword.minstrel.api.BaseUrlInterceptor +import okhttp3.HttpUrl.Companion.toHttpUrl import org.junit.jupiter.api.Test import kotlin.test.assertEquals class CoverUrlsTest { + // A cover is fetched through the placeholder host, which BaseUrlInterceptor + // rewrites to the live server and AuthCookieInterceptor signs; any other + // host would load without the session. A blank id has no picture. @Test - fun `albumCoverPath builds the placeholder cover URL`() { - assertEquals("http://placeholder.invalid/api/albums/a1/cover", albumCoverPath("a1")) - } - - @Test - fun `albumCoverPath is empty for a blank id`() { + fun `covers and artist images go through the host the interceptors rewrite`() { + assertEquals(BaseUrlInterceptor.PLACEHOLDER_HOST, albumCoverPath("a1").toHttpUrl().host) + assertEquals(BaseUrlInterceptor.PLACEHOLDER_HOST, artistImagePath("r1").toHttpUrl().host) assertEquals("", albumCoverPath("")) - } - - @Test - fun `artistImagePath builds the placeholder artist image URL`() { - assertEquals("http://placeholder.invalid/api/artists/r1/image", artistImagePath("r1")) - } - - @Test - fun `artistImagePath is empty for a blank id`() { assertEquals("", artistImagePath("")) } } diff --git a/android/app/src/test/java/com/fabledsword/minstrel/player/RemotePlayerStateTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/player/RemotePlayerStateTest.kt index e444e0b7..e3ff5e38 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/player/RemotePlayerStateTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/player/RemotePlayerStateTest.kt @@ -7,47 +7,18 @@ import kotlin.test.assertTrue class RemotePlayerStateTest { + // A renderer error stops playback and is kept to report, but what the + // listener asked for survives it, so a failed play can resume locally. @Test - fun `starts in idle state`() { - val state = RemotePlayerState() - assertFalse(state.isPlaying) - assertEquals(0L, state.positionMs) - assertEquals(0L, state.durationMs) - } - - @Test - fun `applyPositionInfo updates position, duration, and trackNumber`() { - val state = RemotePlayerState() - state.applyPositionInfo( - positionMs = 65_000L, durationMs = 210_000L, trackUri = "x", trackNumber = 3, - ) - assertEquals(65_000L, state.positionMs) - assertEquals(210_000L, state.durationMs) - assertEquals("x", state.currentTrackUri) - assertEquals(3, state.trackNumber) - } - - @Test - fun `applyTransportPlaying flips isPlaying true`() { + fun `an error stops playback and is recorded, and the play intent survives it`() { val state = RemotePlayerState() state.applyTransportPlaying() - assertTrue(state.isPlaying) - } - - @Test - fun `applyTransportPaused flips isPlaying false`() { - val state = RemotePlayerState().apply { applyTransportPlaying() } - state.applyTransportPaused() - assertFalse(state.isPlaying) - } - - @Test - fun `applyError resets to idle and records error`() { - val state = RemotePlayerState().apply { applyTransportPlaying() } - val ex = RuntimeException("disconnected") + state.setPlayIntent(true) + val ex = RuntimeException("connect timeout") state.applyError(ex) assertFalse(state.isPlaying) assertEquals(ex, state.lastError) + assertTrue(state.lastPlayIntent) } @Test @@ -69,24 +40,6 @@ class RemotePlayerStateTest { assertFalse(state.recordPollFailure()) } - @Test - fun `play intent survives a SOAP error so a failed play can resume locally`() { - val state = RemotePlayerState() - state.setPlayIntent(true) - state.applyError(RuntimeException("connect timeout")) - // isPlaying is cleared by the error, but the user's intent persists. - assertFalse(state.isPlaying) - assertTrue(state.lastPlayIntent) - } - - @Test - fun `pausing clears play intent`() { - val state = RemotePlayerState() - state.setPlayIntent(true) - state.setPlayIntent(false) - assertFalse(state.lastPlayIntent) - } - @Test fun `reset clears play intent`() { val state = RemotePlayerState() diff --git a/android/app/src/test/java/com/fabledsword/minstrel/player/output/IdleRevertDecisionTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/player/output/IdleRevertDecisionTest.kt index 8aa91a05..960f86b6 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/player/output/IdleRevertDecisionTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/player/output/IdleRevertDecisionTest.kt @@ -1,55 +1,25 @@ package com.fabledsword.minstrel.player.output -import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.CsvSource import kotlin.test.assertEquals +/** + * The idle timer arms when a speaker sits paused, and is cancelled by + * playing again or leaving the speaker; anything else leaves it as it is. + */ class IdleRevertDecisionTest { - @Test - fun `engaged and paused and not armed arms the timer`() { - assertEquals( - IdleRevertAction.ARM, - idleRevertAction(upnpEngaged = true, isPlaying = false, armed = false), - ) - } - - @Test - fun `engaged and paused and already armed is ignored`() { - assertEquals( - IdleRevertAction.IGNORE, - idleRevertAction(upnpEngaged = true, isPlaying = false, armed = true), - ) - } - - @Test - fun `resuming playback cancels an armed timer`() { - assertEquals( - IdleRevertAction.CANCEL, - idleRevertAction(upnpEngaged = true, isPlaying = true, armed = true), - ) - } - - @Test - fun `playing with no timer armed is ignored`() { - assertEquals( - IdleRevertAction.IGNORE, - idleRevertAction(upnpEngaged = true, isPlaying = true, armed = false), - ) - } - - @Test - fun `disengaging UPnP cancels an armed timer`() { - assertEquals( - IdleRevertAction.CANCEL, - idleRevertAction(upnpEngaged = false, isPlaying = false, armed = true), - ) - } - - @Test - fun `disengaged with no timer armed is ignored`() { - assertEquals( - IdleRevertAction.IGNORE, - idleRevertAction(upnpEngaged = false, isPlaying = true, armed = false), - ) + @ParameterizedTest(name = "engaged={0} playing={1} armed={2} -> {3}") + @CsvSource( + "true, false, false, ARM", + "true, false, true, IGNORE", + "true, true, true, CANCEL", + "true, true, false, IGNORE", + "false, false, true, CANCEL", + "false, true, false, IGNORE", + ) + fun `the idle timer`(engaged: Boolean, playing: Boolean, armed: Boolean, want: String) { + assertEquals(want, idleRevertAction(upnpEngaged = engaged, isPlaying = playing, armed = armed).name) } } diff --git a/android/app/src/test/java/com/fabledsword/minstrel/player/output/SonosAlbumPlayTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/player/output/SonosAlbumPlayTest.kt index 6d4e67e7..7a1892e7 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/player/output/SonosAlbumPlayTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/player/output/SonosAlbumPlayTest.kt @@ -6,38 +6,23 @@ import kotlin.test.assertEquals /** * The Sonos queue plays straight through, so a track's album play is judged - * from its neighbours in the list sent. + * from its neighbours in the list sent. The rule itself is GainMath's and is + * tested there; this checks the queue hands it each track's neighbours, and + * that a track with no album counts as none. */ class SonosAlbumPlayTest { - private fun t(album: String, n: Int?, disc: Int? = null) = - TrackRef(id = "$album-$disc-$n", title = "", albumId = album, artistId = "", trackNumber = n, discNumber = disc) + private fun t(album: String, n: Int?) = + TrackRef(id = "$album-$n", title = "", albumId = album, artistId = "", trackNumber = n) private fun asAlbum(queue: List) = queue.indices.map { SonosQueueLoader.playingAsAlbum(queue, it) } @Test - fun `an album in order plays as an album throughout`() { - assertEquals(listOf(true, true, true), asAlbum(listOf(t("a", 1), t("a", 2), t("a", 3)))) - } - - @Test - fun `a mix of albums plays as singles`() { - assertEquals(listOf(false, false, false), asAlbum(listOf(t("a", 1), t("b", 1), t("c", 4)))) - } - - @Test - fun `album order runs across discs`() { - assertEquals(listOf(true, true), asAlbum(listOf(t("a", 12, disc = 1), t("a", 1, disc = 2)))) - } - - @Test - fun `shuffled tracks of one album are not album play`() { - assertEquals(listOf(false, false), asAlbum(listOf(t("a", 3), t("a", 1)))) - } - - @Test - fun `unnumbered tracks and missing albums are never album play`() { - assertEquals(listOf(false, false), asAlbum(listOf(t("a", null), t("a", null)))) + fun `each track is judged by its own neighbours in the queue`() { + assertEquals( + listOf(true, true, false, false), + asAlbum(listOf(t("a", 1), t("a", 2), t("b", 7), t("c", 1))), + ) assertEquals(listOf(false, false), asAlbum(listOf(t("", 1), t("", 2)))) } } diff --git a/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/AVTransportClientTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/AVTransportClientTest.kt index 44fcd435..7996035e 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/AVTransportClientTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/AVTransportClientTest.kt @@ -104,18 +104,6 @@ class AVTransportClientTest { assertEquals(TransportState.UNKNOWN, info.state) } - @Test - fun `removeAllTracksFromQueue sends correct SOAP action`() = runTest { - server.enqueue(emptyResponse("RemoveAllTracksFromQueue")) - client.removeAllTracksFromQueue() - val request = server.takeRequest() - assertTrue(request.getHeader("SOAPACTION").orEmpty().contains("RemoveAllTracksFromQueue")) { - "SOAPACTION header missing action: ${request.getHeader("SOAPACTION")}" - } - val body = request.body.readUtf8() - assertTrue(body.contains("RemoveAllTracksFromQueue")) { "body: $body" } - } - @Test fun `addURIToQueue sends EnqueuedURI and DIDL-Lite metadata`() = runTest { server.enqueue(emptyResponse("AddURIToQueue")) @@ -137,26 +125,6 @@ class AVTransportClientTest { assertTrue(body.contains("audio/mpeg")) { "mime missing: $body" } } - @Test - fun `next sends Next SOAP action`() = runTest { - server.enqueue(emptyResponse("Next")) - client.next() - val request = server.takeRequest() - assertTrue(request.getHeader("SOAPACTION").orEmpty().endsWith("#Next\"")) { - "SOAPACTION: ${request.getHeader("SOAPACTION")}" - } - } - - @Test - fun `previous sends Previous SOAP action`() = runTest { - server.enqueue(emptyResponse("Previous")) - client.previous() - val request = server.takeRequest() - assertTrue(request.getHeader("SOAPACTION").orEmpty().endsWith("#Previous\"")) { - "SOAPACTION: ${request.getHeader("SOAPACTION")}" - } - } - @Test fun `seekToTrack sends TRACK_NR unit with 1-based target`() = runTest { server.enqueue(emptyResponse("Seek")) diff --git a/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/BareUdnTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/BareUdnTest.kt index 28187353..8de7e22b 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/BareUdnTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/BareUdnTest.kt @@ -1,44 +1,26 @@ package com.fabledsword.minstrel.player.output.upnp -import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.CsvSource import kotlin.test.assertEquals +/** + * A Sonos names one speaker several ways: the renderer's route id carries + * `uuid:` and an `_MR` suffix, a media server `_MS`, and the zone-group + * topology neither. Bare, they compare equal. + */ class BareUdnTest { - @Test - fun `strips uuid prefix`() { - assertEquals("RINCON_ABC", "uuid:RINCON_ABC".bareUdn()) - } - - @Test - fun `strips MR suffix`() { - assertEquals("RINCON_ABC", "RINCON_ABC_MR".bareUdn()) - } - - @Test - fun `strips MS suffix`() { - assertEquals("RINCON_ABC", "RINCON_ABC_MS".bareUdn()) - } - - @Test - fun `strips both uuid prefix and MR suffix`() { - assertEquals("RINCON_ABC", "uuid:RINCON_ABC_MR".bareUdn()) - } - - @Test - fun `strips both uuid prefix and MS suffix`() { - assertEquals("RINCON_ABC", "uuid:RINCON_ABC_MS".bareUdn()) - } - - @Test - fun `leaves already bare UDN unchanged`() { - assertEquals("RINCON_ABC", "RINCON_ABC".bareUdn()) - } - - @Test - fun `MR suffix comparison crosses MediaRenderer vs ZGT response`() { - val routeId = "uuid:RINCON_5CAAFD794B6401400_MR" - val zgtMemberUdn = "RINCON_5CAAFD794B6401400" - assertEquals(routeId.bareUdn(), zgtMemberUdn.bareUdn()) + @ParameterizedTest(name = "{0}") + @CsvSource( + "uuid:RINCON_ABC", + "RINCON_ABC_MR", + "RINCON_ABC_MS", + "uuid:RINCON_ABC_MR", + "uuid:RINCON_ABC_MS", + "RINCON_ABC", + ) + fun `every form of a speaker's id is the same bare id`(udn: String) { + assertEquals("RINCON_ABC", udn.bareUdn()) } } diff --git a/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/RenderingControlClientTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/RenderingControlClientTest.kt index 3fcdf6f8..4f65f5ef 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/RenderingControlClientTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/player/output/upnp/RenderingControlClientTest.kt @@ -7,6 +7,8 @@ import okhttp3.mockwebserver.MockWebServer import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.CsvSource import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue @@ -46,8 +48,9 @@ class RenderingControlClientTest { ) } - @Test - fun `setVolume clamps and sends DesiredVolume`() = runTest { + @ParameterizedTest(name = "{0} -> {1}") + @CsvSource("150, 100", "-5, 0", "40, 40") + fun `setVolume clamps to the renderer's range and sends DesiredVolume`(asked: Int, sent: Int) = runTest { server.enqueue(MockResponse().setBody( """ @@ -56,23 +59,8 @@ class RenderingControlClientTest { xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"/> """.trimIndent())) - client.setVolume(150) + client.setVolume(asked) val body = server.takeRequest().body.readUtf8() - assertTrue(body.contains("100")) { body } - } - - @Test - fun `setVolume clamps below VOLUME_MIN to zero`() = runTest { - server.enqueue(MockResponse().setBody( - """ - - - - - """.trimIndent())) - client.setVolume(-5) - val body = server.takeRequest().body.readUtf8() - assertTrue(body.contains("0")) { body } + assertTrue(body.contains("$sent")) { body } } } diff --git a/android/app/src/test/java/com/fabledsword/minstrel/playlists/data/PlaylistsRepositoryCacheMergeTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/playlists/data/PlaylistsRepositoryCacheMergeTest.kt index e39bc5d5..c30a3d65 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/playlists/data/PlaylistsRepositoryCacheMergeTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/playlists/data/PlaylistsRepositoryCacheMergeTest.kt @@ -3,49 +3,30 @@ package com.fabledsword.minstrel.playlists.data import com.fabledsword.minstrel.cache.db.dao.PlaylistCachedCount import com.fabledsword.minstrel.cache.db.entities.CachedPlaylistEntity import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.CsvSource import kotlin.test.assertEquals -import kotlin.test.assertFalse -import kotlin.test.assertTrue class PlaylistsRepositoryCacheMergeTest { private fun playlist(id: String, trackCount: Int) = CachedPlaylistEntity(id = id, userId = "u", name = id, trackCount = trackCount) - @Test - fun `fully cached when every member track is resident`() { + // Fully cached means every member track is resident; an empty playlist + // never is, and no count row means nothing is resident. + @ParameterizedTest(name = "{0} of {1} resident -> {2}") + @CsvSource( + "3, 3, true", + "2, 3, false", + ", 3, false", + "0, 0, false", + ) + fun `fully cached only when every track is resident`(cached: Int?, tracks: Int, want: Boolean) { val out = mergePlaylistsWithCache( - rows = listOf(playlist("p", trackCount = 3)), - counts = listOf(PlaylistCachedCount("p", cachedCount = 3)), + rows = listOf(playlist("p", trackCount = tracks)), + counts = listOfNotNull(cached?.let { PlaylistCachedCount("p", cachedCount = it) }), ) - assertTrue(out.single().fullyCached) - } - - @Test - fun `not fully cached when only some tracks are resident`() { - val out = mergePlaylistsWithCache( - rows = listOf(playlist("p", trackCount = 3)), - counts = listOf(PlaylistCachedCount("p", cachedCount = 2)), - ) - assertFalse(out.single().fullyCached) - } - - @Test - fun `not fully cached when no tracks are resident (missing count row)`() { - val out = mergePlaylistsWithCache( - rows = listOf(playlist("p", trackCount = 3)), - counts = emptyList(), - ) - assertFalse(out.single().fullyCached) - } - - @Test - fun `empty playlist is never fully cached`() { - val out = mergePlaylistsWithCache( - rows = listOf(playlist("p", trackCount = 0)), - counts = listOf(PlaylistCachedCount("p", cachedCount = 0)), - ) - assertFalse(out.single().fullyCached) + assertEquals(want, out.single().fullyCached) } @Test diff --git a/android/app/src/test/java/com/fabledsword/minstrel/shared/widgets/ReorderDragMathTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/shared/widgets/ReorderDragMathTest.kt index 6ac770bb..53561202 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/shared/widgets/ReorderDragMathTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/shared/widgets/ReorderDragMathTest.kt @@ -1,6 +1,8 @@ package com.fabledsword.minstrel.shared.widgets import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.CsvSource import kotlin.test.assertEquals /** @@ -11,48 +13,27 @@ import kotlin.test.assertEquals */ class ReorderDragMathTest { - @Test - fun `zero offset moves nothing`() { - assertEquals(0, reorderDragDelta(0f, 64)) - } - - @Test - fun `a full row down moves one`() { - assertEquals(1, reorderDragDelta(64f, 64)) - } - - @Test - fun `just under half a row rounds down`() { - assertEquals(0, reorderDragDelta(31f, 64)) - } - - @Test - fun `half a row or more rounds up`() { - assertEquals(1, reorderDragDelta(32f, 64)) - } - - @Test - fun `drag up is symmetric, with ties toward positive infinity as in JS`() { - assertEquals(-1, reorderDragDelta(-64f, 64)) - assertEquals(0, reorderDragDelta(-32f, 64)) - } - - @Test - fun `several rows`() { - assertEquals(3, reorderDragDelta(192f, 64)) - assertEquals(-2, reorderDragDelta(-128f, 64)) - } - - @Test - fun `a row not yet measured moves nothing`() { - assertEquals(0, reorderDragDelta(100f, 0)) - assertEquals(0, reorderDragDelta(100f, -1)) - } - - @Test - fun `the measured row height is what counts`() { - assertEquals(1, reorderDragDelta(56f, 56)) - assertEquals(1, reorderDragDelta(28f, 56)) + @ParameterizedTest(name = "{0}px on {1}px rows -> {2}") + @CsvSource( + "0, 64, 0", + "64, 64, 1", + "31, 64, 0", + "32, 64, 1", + "56, 56, 1", + "28, 56, 1", + "192, 64, 3", + "-64, 64, -1", + "-32, 64, 0", // ties toward positive infinity, as in JS + "-128, 64, -2", + "100, 0, 0", // a row not yet measured moves nothing + "100, -1, 0", + ) + fun `a drag moves by the whole rows it crosses, half a row counting as one`( + offset: Float, + rowHeight: Int, + want: Int, + ) { + assertEquals(want, reorderDragDelta(offset, rowHeight)) } @Test diff --git a/android/app/src/test/java/com/fabledsword/minstrel/update/data/UpdateRepositoryTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/update/data/UpdateRepositoryTest.kt index 09ff9fc6..5b783995 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/update/data/UpdateRepositoryTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/update/data/UpdateRepositoryTest.kt @@ -60,11 +60,6 @@ class UpdateRepositoryTest { assertIs(repo().check()) } - @Test - fun `the same app built again at a later minute is not offered`() = runTest { - assertEquals(Offer.Current, repo(version = { wire(version = "2026.10.20.0900") }).check()) - } - @Test fun `a server with no app to offer is not a problem`() = runTest { val none = repo(version = { throw HttpException(Response.error(404, "".toResponseBody())) }) diff --git a/web/src/lib/components/queue-row-math.test.ts b/web/src/lib/components/queue-row-math.test.ts index 7975d210..bae95812 100644 --- a/web/src/lib/components/queue-row-math.test.ts +++ b/web/src/lib/components/queue-row-math.test.ts @@ -9,6 +9,7 @@ describe('offsetToDelta', () => { [64, 64, 1], [31, 64, 0], [32, 64, 1], + [56, 56, 1], [28, 56, 1], [192, 64, 3], [-64, 64, -1],