I'm having a super weird bug again with integrated...
# compose
v
I'm having a super weird bug again with integrated tests,
onClick
is sometimes not called on a node, (seemingly) because the node is not displayed yet. However the test tag still exists. 🧵
log looks like this
Copy code
W  clicking...
 W  interaction: androidx.compose.foundation.interaction.PressInteraction$Press@b0db5ac
 W  interaction: androidx.compose.foundation.interaction.PressInteraction$Release@e1bea7b
    [missing an onClick log here]
 W  ...clicked
and the code just looks like this
Copy code
.clickable(
    indication = null,
    interactionSource = interactionSource,
    onClick = {
        logger.warn("onClick")
        // other stuff
    }
)
what could be the cause of this? if I add an aritificial delay of say 500ms before clicking, it works normally
t
whats ur compose version ?
v
1.6.0-alpha07
Another flaky test I have doesn't seem to sometimes even get an interaction event.
t
tried with 1.6.0-beta01 ? i usually bump to latest version as a first step of debugging 😄
v
no, there's another issue preventing upgrading at this point 😐
I guess I could still try
t
there’s another issue preventing upgrading at this point
ooops.. which one ?
And it's quite hard to be sure of when it's working, as said this is flaky and not failing every time. It fails about 10% of test runs
t
ohh 😮
v
hm, I think I know why it's happening
the component doesn't seem to be displayed yet when it's trying to click it
it's weird because I even try calling
composeTestRule.waitForIdle()
before trying to click, I would assume it would only continue after everything in the current recomposition is displayed etc
t
aah.. wait till full-draw should work then
v
so when it fails to click,
assertIsDisplayed()
also fails the assert
t
hmm.. wait until displayed is needed here i guess
.
Copy code
device.wait(
    Until.hasObject(findBy()),
    timeout.inWholeMilliseconds
)
should do the magic
v
uhh, what test apis are these?
I wonder what the fundamental reason here is that 1. The component isn't displayed yet even though the test tag is in the tree 2. The click event doesn't go through when it's not displayed. Does the test runner try to actually "click" some coordinates on the screen instead of somehow delivering the event directly?
Copy code
isPlaced=true,
isAttached=true,
boundsInWindow=Rect.fromLTRB(0.0, 0.0, 0.0, 0.0)
🤔
z
There are a few places where zero-size nodes are treated as non-existent, since they are effectively hidden from the users perspective. Seems like you might be hitting that?
v
Do you have any idea why any elements would be zero-sized? I had the impression the test framework waits for the UI to be idle? I'm seeing this on nodes which definitely have a non-zero size defined
Reviewing some other flaky tests, it also seems like
waitUntilNodeCount
also sometimes returns when the node isn't even attached yet 😅
z
Sounds like a bug on our end