Select last topic by name instead of a random one

pull/862/head
Simon Marquis 1 year ago
parent 0a1f333fc6
commit 57f3700980

@ -36,6 +36,7 @@ import androidx.test.espresso.NoActivityResumedException
import com.google.samples.apps.nowinandroid.MainActivity import com.google.samples.apps.nowinandroid.MainActivity
import com.google.samples.apps.nowinandroid.R import com.google.samples.apps.nowinandroid.R
import com.google.samples.apps.nowinandroid.core.network.NiaNetworkDataSource import com.google.samples.apps.nowinandroid.core.network.NiaNetworkDataSource
import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic
import com.google.samples.apps.nowinandroid.core.rules.GrantPostNotificationsPermissionRule import com.google.samples.apps.nowinandroid.core.rules.GrantPostNotificationsPermissionRule
import dagger.hilt.android.testing.BindValue import dagger.hilt.android.testing.BindValue
import dagger.hilt.android.testing.HiltAndroidRule import dagger.hilt.android.testing.HiltAndroidRule
@ -267,8 +268,8 @@ class NavigationTest {
composeTestRule.apply { composeTestRule.apply {
onNodeWithText(interests).performClick() onNodeWithText(interests).performClick()
// Select a random topic // Select the last topic
val topic = datasource.getTopics().random().name val topic = datasource.getTopics().sortedBy(NetworkTopic::name).last().name
onNodeWithTag("interests:topics").performScrollToNode(hasText(topic)) onNodeWithTag("interests:topics").performScrollToNode(hasText(topic))
onNodeWithText(topic).performClick() onNodeWithText(topic).performClick()

Loading…
Cancel
Save