Hey Folks! Big thanks for all the great answers on...
# compose-android
s
Hey Folks! Big thanks for all the great answers on my previous question 🙌 I have another one today... I'm not able to find any solid guidance on how to write Compose UI tests for
AnnotatedString
clickable link Text composables. Some guidance would be much appreciated. Example inside the thread 🧵
As an example, I've written this test case (which is NOT working):
Copy code
@Test
fun bottomSheet_resendEmailClick_updatesText() {
    composeTestRule.setContent {
        SHTheme {
            LoginScreen()
        }
    }

    composeTestRule
        .onNodeWithText("name@email.com") // Placeholder
        .performTextInput("test@example.com")

    composeTestRule
        .onNodeWithText("CONTINUE")
        .performClick()

    // Click on the "Resend Now" part of the text.
    composeTestRule
        .onNodeWithText("Resend Now", substring = true)
        .performClick()

    // Verify the text changes
    composeTestRule
        .onNodeWithText(
            "Still not seeing your verification email?",
            substring = true
        )
        .assertIsDisplayed()

    composeTestRule
        .onNodeWithText(
            "Resend Again",
            substring = true
        )
        .assertIsDisplayed()
}
And it's giving me an error like:
Copy code
java.lang.AssertionError: Failed to inject touch input.
Reason: Expected exactly '1' node but could not find any node that satisfies: (Text + InputText + EditableText contains 'Resend Now' (ignoreCase: false) as substring)

at androidx.compose.ui.test.SemanticsNodeInteraction.fetchOneOrThrow(SemanticsNodeInteraction.kt:178)
at androidx.compose.ui.test.SemanticsNodeInteraction.fetchOneOrThrow$default(SemanticsNodeInteraction.kt:150)
at androidx.compose.ui.test.SemanticsNodeInteraction.fetchSemanticsNode(SemanticsNodeInteraction.kt:84)
at androidx.compose.ui.test.ActionsKt.performTouchInput(Actions.kt:384)
at androidx.compose.ui.test.AndroidActions.performClickImpl(Actions.android.kt:23)
at androidx.compose.ui.test.ActionsKt.performClick(Actions.kt:60)