Skip to content

Commit 0a1f333

Browse files
authored
Update NavigationTest.kt
1 parent bf5fdb4 commit 0a1f333

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ import androidx.compose.ui.test.junit4.AndroidComposeTestRule
2727
import androidx.compose.ui.test.junit4.createAndroidComposeRule
2828
import androidx.compose.ui.test.onAllNodesWithText
2929
import androidx.compose.ui.test.onNodeWithContentDescription
30+
import androidx.compose.ui.test.onNodeWithTag
3031
import androidx.compose.ui.test.onNodeWithText
3132
import androidx.compose.ui.test.performClick
33+
import androidx.compose.ui.test.performScrollToNode
3234
import androidx.test.espresso.Espresso
3335
import androidx.test.espresso.NoActivityResumedException
3436
import com.google.samples.apps.nowinandroid.MainActivity
@@ -262,10 +264,13 @@ class NavigationTest {
262264

263265
@Test
264266
fun navigationBar_multipleBackStackInterests() = runTest {
265-
val topics = datasource.getTopics(ids = null)
266267
composeTestRule.apply {
267268
onNodeWithText(interests).performClick()
268-
onNodeWithText(topics.random().name).performClick()
269+
270+
// Select a random topic
271+
val topic = datasource.getTopics().random().name
272+
onNodeWithTag("interests:topics").performScrollToNode(hasText(topic))
273+
onNodeWithText(topic).performClick()
269274

270275
// Switch tab
271276
onNodeWithText(forYou).performClick()
@@ -274,7 +279,7 @@ class NavigationTest {
274279
onNodeWithText(interests).performClick()
275280

276281
// Verify we're not in the list of interests
277-
onNodeWithText(topics.random().name).assertDoesNotExist()
282+
onNodeWithTag("interests:topics").assertDoesNotExist()
278283
}
279284
}
280285
}

0 commit comments

Comments
 (0)