From ec32346c71f6fcbb966653959ab31acbff3db399 Mon Sep 17 00:00:00 2001 From: justinzeus Date: Fri, 6 Nov 2026 01:32:59 +0100 Subject: [PATCH] Isolate the artwork test singleton lifecycle --- .../org/justinvisser/wolfskin/tv/WolfskinArtworkTest.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/test/java/org/justinvisser/wolfskin/tv/WolfskinArtworkTest.kt b/app/src/test/java/org/justinvisser/wolfskin/tv/WolfskinArtworkTest.kt index 2e248969..9e4d1118 100644 --- a/app/src/test/java/org/justinvisser/wolfskin/tv/WolfskinArtworkTest.kt +++ b/app/src/test/java/org/justinvisser/wolfskin/tv/WolfskinArtworkTest.kt @@ -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() + @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() + 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() }