KakaoCup / Compose

Nice and simple DSL for Espresso Compose UI testing in Kotlin
https://kakaocup.github.io/Compose/
Apache License 2.0
146 stars 15 forks source link

viewBuilderAction doesn't see ancestor nodes #23

Open vrnvorona opened 2 years ago

vrnvorona commented 2 years ago

In my testing if I provide ComposeScreen with viewBuilderAction = { hasTestTag(C.Screen.main_screen) } it doesn't work. I tested a bit, and I suspect that it uses wrong hierarchy matchers. If I do

composeTestRule.onNode(
    hasTestTag(C.Tag.profile_auth_button).and(
        hasParent(
            hasTestTag(C.Screen.profile_screen)
        )
    )
).performClick()
``` then it also doesn't work, but if I change hasParent for hasAnyAncestors it does work.

Maybe I am doing something wrong? My initial attempt was like this

onComposeScreen(composeTestRule) { authButton { assertIsDisplayed() performClick() } }