Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Change-Id: I1ef215ba8ebfb717d8541d1d48a516cc049e8d6a
  • Loading branch information
mmoczkowski committed May 15, 2023
1 parent e2ab6e9 commit 718d137
Showing 1 changed file with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
package com.google.samples.apps.nowinandroid.feature.search

import androidx.activity.ComponentActivity
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsFocused
import androidx.compose.ui.test.hasScrollToNodeAction
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onAllNodesWithContentDescription
import androidx.compose.ui.test.onFirst
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performScrollToIndex
import com.google.samples.apps.nowinandroid.core.data.model.RecentSearchQuery
import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig.DARK
import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.ANDROID
Expand Down Expand Up @@ -139,22 +140,18 @@ class SearchScreenTest {
composeTestRule
.onNodeWithText(topicsString)
.assertIsDisplayed()
composeTestRule
.onNodeWithText(followableTopicTestData[0].topic.name)
.assertIsDisplayed()
composeTestRule
.onNodeWithText(followableTopicTestData[1].topic.name)
.assertIsDisplayed()
composeTestRule
.onNodeWithText(followableTopicTestData[2].topic.name)
.assertIsDisplayed()

composeTestRule
.onAllNodesWithContentDescription(followButtonContentDesc)
.assertCountEquals(2)
composeTestRule
.onAllNodesWithContentDescription(unfollowButtonContentDesc)
.assertCountEquals(1)
val scrollableNode = composeTestRule
.onAllNodes(hasScrollToNodeAction())
.onFirst()

followableTopicTestData.forEachIndexed { index, followableTopic ->
scrollableNode.performScrollToIndex(index)

composeTestRule
.onNodeWithText(followableTopic.topic.name)
.assertIsDisplayed()
}
}

@Test
Expand Down

0 comments on commit 718d137

Please sign in to comment.