0.2.55 - Remote config/Request fixes

This commit is contained in:
ponzischeme89
2026-08-12 09:57:56 +12:00
parent 4b31946635
commit 9777eb0952
35 changed files with 1086 additions and 78 deletions
@@ -0,0 +1,91 @@
package com.ponzischeme89.memby.data.remoteconfig
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Test
class MembyRemoteConfigTest {
@Test
fun bundledDefaultsAreCompleteButNotARemoteRevision() {
val bundled = BundledRemoteConfig.value
assertEquals(0, bundled.configVersion)
assertEquals("Favourites", bundled.navigation.labels.favourites)
assertEquals(184, bundled.navigation.expandedWidthDp)
}
@Test
fun validCompatibleDocumentDecodes() {
val document = decodeRemoteConfig(validDocument)!!
assertNull(validateRemoteConfig(document, "0.2.54"))
assertEquals("Discover", document.navigation.labels.search)
assertEquals(false, document.navigation.showVersion)
}
@Test
fun incompatibleSchemaAndAppVersionsAreRejected() {
val document = decodeRemoteConfig(validDocument)!!
assertNotNull(validateRemoteConfig(document.copy(schemaVersion = 2), "0.2.54"))
assertNotNull(validateRemoteConfig(document, "0.2.53"))
assertNotNull(
validateRemoteConfig(
document.copy(minimumAppVersion = "", maximumAppVersion = "0.2.53"),
"0.2.54",
),
)
}
@Test
fun malformedCopyAndUnsafePresentationAreRejected() {
val document = decodeRemoteConfig(validDocument)!!
assertNotNull(
validateRemoteConfig(
document.copy(copy = document.copy.copy(tagline = "\nNot safe")),
"0.2.54",
),
)
assertNotNull(
validateRemoteConfig(
document.copy(
presentation = document.presentation.copy(
navigationRailExpandedWidthDp = 500,
),
),
"0.2.54",
),
)
}
private companion object {
val validDocument = """
{
"schemaVersion": 1,
"configVersion": 7,
"minimumAppVersion": "0.2.54",
"copy": {
"navigation": {
"home": "Home",
"forYou": "For You",
"search": "Discover",
"movies": "Films",
"tvShows": "TV Shows",
"tvCalendar": "TV Calendar",
"favourites": "Favourites",
"user": "User",
"settings": "Settings"
},
"tagline": "Your library, made personal"
},
"features": { "showNavigationVersion": false },
"presentation": {
"navigationRailExpandedWidthDp": 196,
"navigationContentShiftDp": 120
}
}
""".trimIndent()
}
}