How can I provide `UIKitInteropContainer` for Comp...
# compose-ios
j
How can I provide
UIKitInteropContainer
for Compose UI tests?
Copy code
Failed tests
shoppingScreenTest[iosSimulatorArm64]

kotlin.IllegalStateException: UIKitInteropContainer not provided
	at kotlin.Throwable#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:28)
	at kotlin.Exception#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23)
	at kotlin.RuntimeException#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:34)
	at kotlin.IllegalStateException#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:70)
	at androidx.compose.ui.interop.LocalUIKitInteropContainer$lambda$0#internal(/opt/buildAgent/work/8a20760945d0aeba/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/interop/UIKitInteropContainer.uikit.kt:37)
	at androidx.compose.ui.interop.$LocalUIKitInteropContainer$lambda$0$FUNCTION_REFERENCE$0.invoke#internal(/opt/buildAgent/work/8a20760945d0aeba/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/interop/UIKitInteropContainer.uikit.kt:37)
	at kotlin.Function0#invoke(/Users/teamcity/.gradle/daemon/8.2.1/[K][Suspend]Functions:1)
And why is
UIKitINteropContainer
required to run a simple view for this composable?
Copy code
@Composable
fun ShoppingScreen(nav: ScreenNav)
{
    Column(
      modifier = Modifier.fillMaxWidth().fillMaxHeight(1f),
      horizontalAlignment = Alignment.Start,
      verticalArrangement = Arrangement.SpaceEvenly)
    {
        WallyBoldText(S.ShoppingWarning)
        WallyDivider()

        LazyColumn(modifier = Modifier.fillMaxWidth().fillMaxHeight(1f)) {
            itemsIndexed(initialShopping) { index, it ->
                // padding here adds a small gap between each entry that is not filled with the row color
                Spacer(Modifier.fillMaxWidth().padding(0.dp, 1.dp))
                // This padding adds a little margin between the content and the background color
                Box(Modifier.fillMaxWidth().background(WallyShoppingRowColors[index % WallyShoppingRowColors.size]).padding(2.dp, 2.dp)) {
                    it.compose()
                    //Text(it.explain, Modifier.fillMaxWidth())
                }
            }
        }
    }

}
The test:
Copy code
import androidx.compose.ui.test.*
import info.bitcoinunlimited.www.wally.S
import info.bitcoinunlimited.www.wally.i18n
import info.bitcoinunlimited.www.wally.ui.ScreenNav
import info.bitcoinunlimited.www.wally.ui.ShoppingScreen
import kotlin.test.Test

@OptIn(ExperimentalTestApi::class)
class ShoppingScreenTest
{
    @Test
    fun shoppingScreenTest() = runComposeUiTest {
        val nav = ScreenNav()
        setContent {
            ShoppingScreen(nav)
        }

        onNodeWithText(i18n(S.ShoppingWarning)).isDisplayed()
        onNodeWithText(i18n(S.NFTs)).isDisplayed()
        onNodeWithText(i18n(S.ExplainBitmart)).isDisplayed()
        onNodeWithText(i18n(S.ExplainMexc)).isDisplayed()
        onNodeWithText(i18n(S.NFTs)).isDisplayed()
    }
}
Full stack trace: https://wallywallet.gitlab.io/-/wallet/-/jobs/6960895143/artifacts/src/build/reports/tests/iosSimulatorArm64Test/classes/ui.ShoppingScreenTest.html
🧵 1
i
You cannot provide it - it's internal. It should be fixed in Compose (or
runComposeUiTest
test runner). Please file an issue
j
Where do you want me to file it?
And why is
UIKitINteropContainer
required to run a simple view for this composable?
It looks like it's not so "simple" and contains native view inside (interop). So the problem here is with interop view usage from tests
l
Is there any update on this issue?
j
AFAIK no, this part of Compose iOS is still untestable…
i
Compose iOS is still untestable
This case is only about interop views. Not Compose in general.
Is there any update on this issue?
Could you please add a link to filed issue, so I'll bump this internally?
j
Don't have time for that right now…