0.2.59 - Settings save fixes
This commit is contained in:
@@ -5,6 +5,7 @@ import com.ponzischeme89.memby.data.localEpochDay
|
||||
import com.ponzischeme89.memby.data.millisUntilNextLocalDay
|
||||
import com.ponzischeme89.memby.data.model.BaseItem
|
||||
import com.ponzischeme89.memby.data.model.HomeRow
|
||||
import com.ponzischeme89.memby.data.model.UserItemData
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
@@ -259,6 +260,58 @@ class HomeMovieHeroTest {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Watched films -------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The hero is four cards answering "watch this tonight". A film already finished is
|
||||
* not an answer to that, however new it is or however well it was reviewed.
|
||||
*/
|
||||
@Test
|
||||
fun `a film already watched never leads the launcher`() {
|
||||
val rows = listOf(
|
||||
HomeBrowseRow(
|
||||
id = "latest-movies",
|
||||
title = "Recently Added Movies",
|
||||
items = listOf(
|
||||
movie("seen", watched = true),
|
||||
movie("partway", positionTicks = 6_000_000_000L),
|
||||
movie("unseen"),
|
||||
),
|
||||
kind = MediaRowKind.MOVIES,
|
||||
emptyMessage = "",
|
||||
),
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
listOf("partway", "unseen"),
|
||||
selectHomeHeroMovies(rows).map { it.item.id },
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The gateway applies the same rule, so this is the launcher a television draws from
|
||||
* its cache before the first refresh — and any gateway older than the rule.
|
||||
*/
|
||||
@Test
|
||||
fun `a watched film is dropped from the row the gateway sent`() {
|
||||
val row = heroRow(
|
||||
movie("seen", watched = true).copy(membyHeroLabel = "NEW RELEASE"),
|
||||
movie("unseen").copy(membyHeroLabel = "NEW RELEASE"),
|
||||
)
|
||||
|
||||
assertEquals(listOf("unseen"), serverHeroPicks(listOf(row)).map { it.item.id })
|
||||
}
|
||||
|
||||
/** A show marked watched is somebody up to date — exactly who a new season is for. */
|
||||
@Test
|
||||
fun `a watched series still leads`() {
|
||||
val row = heroRow(
|
||||
movie("show", watched = true).copy(type = "Series", membyHeroLabel = "NEW SEASON"),
|
||||
)
|
||||
|
||||
assertEquals(listOf("show"), serverHeroPicks(listOf(row)).map { it.item.id })
|
||||
}
|
||||
|
||||
// --- Midnight ----------------------------------------------------------------
|
||||
|
||||
/** Local, not UTC: the day must turn over at the viewer's midnight. */
|
||||
@@ -308,6 +361,17 @@ class HomeMovieHeroTest {
|
||||
const val DAY_MS = 24L * HOUR_MS
|
||||
}
|
||||
|
||||
private fun movie(
|
||||
id: String,
|
||||
watched: Boolean = false,
|
||||
positionTicks: Long = 0L,
|
||||
) = BaseItem(
|
||||
id = id,
|
||||
name = id,
|
||||
type = "Movie",
|
||||
userData = UserItemData(played = watched, playbackPositionTicks = positionTicks),
|
||||
)
|
||||
|
||||
private fun heroItem(id: String, label: String?, reason: String?) = BaseItem(
|
||||
id = id,
|
||||
name = id,
|
||||
|
||||
@@ -95,9 +95,10 @@ class RequestPresentationTest {
|
||||
fun `the lookup threshold is stricter than the library search's`() {
|
||||
// Every keystroke here reaches Radarr and Sonarr rather than a local index.
|
||||
assertFalse(shouldLookup("du"))
|
||||
assertTrue(shouldLookup("dun"))
|
||||
assertFalse(shouldLookup("dune"))
|
||||
assertTrue(shouldLookup("dunes"))
|
||||
assertFalse(shouldLookup(" a "))
|
||||
assertTrue(shouldLookup(" dune "))
|
||||
assertTrue(shouldLookup(" dune part two "))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user