Update NavigationTest.kt

pull/1837/head
Simon Marquis 2 years ago committed by GitHub
parent 4f7874874d
commit 09441774f5

@ -27,8 +27,10 @@ import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollToNode
import androidx.test.espresso.Espresso import androidx.test.espresso.Espresso
import androidx.test.espresso.NoActivityResumedException import androidx.test.espresso.NoActivityResumedException
import com.google.samples.apps.nowinandroid.MainActivity import com.google.samples.apps.nowinandroid.MainActivity
@ -262,10 +264,13 @@ class NavigationTest {
@Test @Test
fun navigationBar_multipleBackStackInterests() = runTest { fun navigationBar_multipleBackStackInterests() = runTest {
val topics = datasource.getTopics(ids = null)
composeTestRule.apply { composeTestRule.apply {
onNodeWithText(interests).performClick() onNodeWithText(interests).performClick()
onNodeWithText(topics.random().name).performClick()
// Select a random topic
val topic = datasource.getTopics().random().name
onNodeWithTag("interests:topics").performScrollToNode(hasText(topic))
onNodeWithText(topic).performClick()
// Switch tab // Switch tab
onNodeWithText(forYou).performClick() onNodeWithText(forYou).performClick()
@ -274,7 +279,7 @@ class NavigationTest {
onNodeWithText(interests).performClick() onNodeWithText(interests).performClick()
// Verify we're not in the list of interests // Verify we're not in the list of interests
onNodeWithText(topics.random().name).assertDoesNotExist() onNodeWithTag("interests:topics").assertDoesNotExist()
} }
} }
} }

Loading…
Cancel
Save