@@ -20,11 +20,12 @@ import androidx.compose.ui.semantics.SemanticsProperties
20
20
import androidx.compose.ui.state.ToggleableState
21
21
import androidx.compose.ui.test.SemanticsNodeInteraction
22
22
import androidx.compose.ui.test.assertIsDisplayed
23
+ import androidx.compose.ui.test.assertIsSelected
23
24
import androidx.compose.ui.test.assertTextContains
24
- import androidx.compose.ui.test.hasScrollAction
25
25
import androidx.compose.ui.test.hasText
26
26
import androidx.compose.ui.test.junit4.createComposeRule
27
27
import androidx.compose.ui.test.onChildren
28
+ import androidx.compose.ui.test.onNodeWithContentDescription
28
29
import androidx.compose.ui.test.onNodeWithText
29
30
import androidx.compose.ui.test.onParent
30
31
import androidx.compose.ui.test.performClick
@@ -105,7 +106,7 @@ class GroupElementTests {
105
106
val groupElementToTest =
106
107
getGroupElementWithLabel(" Group with children that are visible dependent" )
107
108
// find the scrollable container
108
- val lazyColumn = composeTestRule.onNode(hasScrollAction() )
109
+ val lazyColumn = composeTestRule.onNodeWithContentDescription( " lazy column " )
109
110
// scroll until the group is visible
110
111
lazyColumn.performScrollToNode(hasText(groupElementToTest.label))
111
112
// find the group and check if displayed
@@ -115,8 +116,15 @@ class GroupElementTests {
115
116
groupElement.assertTextContains(groupElementToTest.description)
116
117
// assert only the header is visible and other field elements are not
117
118
assert (groupElement.onParent().onChildren().fetchSemanticsNodes().count() == 1 )
118
- // find and click on the radio button option
119
- composeTestRule.onNodeWithText(" show invisible form element" ).performClick()
119
+ // find the radio button option that enables the group element's children visibility
120
+ val radioButtonLabel = " show invisible form element"
121
+ val radioButton = composeTestRule.onNodeWithText(radioButtonLabel)
122
+ // scroll to the radio button and click it
123
+ lazyColumn.performScrollToNode(hasText(radioButtonLabel))
124
+ radioButton.performClick()
125
+ radioButton.assertIsSelected()
126
+ // scroll back to the group element
127
+ lazyColumn.performScrollToNode(hasText(groupElementToTest.label))
120
128
// assert the and other field elements are visible
121
129
assert (groupElement.onParent().onChildren().fetchSemanticsNodes().count() > 1 )
122
130
}
0 commit comments