KakaoCup / Compose

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

Problem with LazyColumn and clickable modifier #79

Closed Majostik closed 6 months ago

Majostik commented 7 months ago

Hi There is a problem with LazyColumnand clickablemodifier, if I add clickable to item of LazyColumn then KLazyListItemNode can't find child. For example I modified your sample and tried to run

@Composable
private fun ListItemHeader(item: LazyListItem.Header, modifier: Modifier = Modifier) {
    Box(
        modifier = Modifier
            .padding(horizontal = 16.dp, vertical = 8.dp)
            .clickable {  }
            .clip(RoundedCornerShape(8.dp))
            .background(Color.Green)
            .then(modifier)
    ) {
        Text(
            item.title,
            Modifier
                .padding(8.dp)
                .testTag("LazyListHeaderTitle")
        )
    }
}

I got error

java.lang.AssertionError: Failed to assert the following: (Text + EditableText = [Items from 1 to 10])
Can't retrieve node at index '0' of '(hasAnyAncestorThat(Semantics node id = 18)) && (TestTag = 'LazyListHeaderTitle')'
There are no existing nodes for that selector.
EvgenyMeltsaykin commented 6 months ago

Hi! Check that your nodes use the flag useUnmergedTree = true

This issue contains examples of how it can be configured

Majostik commented 6 months ago

Yeah, it's working. Can you please explain why it's now working without this flag?

EvgenyMeltsaykin commented 6 months ago

You can read more about it here