Isolate the artwork test singleton lifecycle
All checks were successful
review/code-claude B1 (artwork credential scoped to the exact Jellyfin scheme/host/port by a network interceptor, fresh ImageLoader, redirect-safe, 2-host test) and B2 (audiences null keeps the name rule, foreground recovery, test) verified by firstmate reading the 9-file delta; final gates green

This commit is contained in:
justinzeus 2026-11-06 01:32:59 +01:00
parent 34ea983a51
commit ec32346c71

View file

@ -8,6 +8,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import coil3.request.SuccessResult
import coil3.imageLoader
import coil3.SingletonImageLoader
import coil3.request.CachePolicy
import coil3.request.ImageRequest
import com.github.damontecres.wholphin.data.ServerRepository
@ -38,6 +39,7 @@ import org.robolectric.annotation.GraphicsMode
class WolfskinArtworkTest {
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
@OptIn(coil3.annotation.DelicateCoilApi::class)
@Test fun inheritedAuthenticatedFetcherCannotSendTheJellyfinTokenToAnotherArtworkHost() {
MockWebServer().use { jellyfin ->
MockWebServer().use { artwork ->
@ -60,7 +62,10 @@ class WolfskinArtworkTest {
artwork.url("/public.png").newBuilder().host("127.0.0.1").build(),
artwork.url("/another-port.png"))
val results = CopyOnWriteArrayList<coil3.request.ImageResult>()
val previousParent = context.applicationContext.imageLoader
try {
// Other screen tests may already have created Coil's process singleton.
SingletonImageLoader.reset()
rule.setContent {
CoilConfig(1024 * 1024L, authenticated, debugLogging = false, enableCache = false)
LaunchedEffect(network) {
@ -82,6 +87,9 @@ class WolfskinArtworkTest {
assertNull(artwork.takeRequest().headers["Authorization"])
} finally {
WolfskinImages.loader(context).shutdown()
val testParent = context.applicationContext.imageLoader
SingletonImageLoader.setUnsafe(previousParent)
testParent.shutdown()
authenticated.dispatcher.executorService.shutdown()
authenticated.connectionPool.evictAll()
}