Skip to content

Instantly share code, notes, and snippets.

@rubenquadros
Created August 28, 2021 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenquadros/1941b642fe1dd52fe89291cb516b994d to your computer and use it in GitHub Desktop.
Save rubenquadros/1941b642fe1dd52fe89291cb516b994d to your computer and use it in GitHub Desktop.
Game details test
class GameDetailsTest {
@get:Rule val composeTestRule = createComposeRule()
@Test
fun game_details_should_be_shown() {
composeTestRule.setContent {
EpicWorldTheme {
GameDetails(
gameDetails =
FakeGamesData.getFakeGameDetails(),
openGameTrailer = {}
)
}
}
// Game image should be shown
composeTestRule
.onNodeWithContentDescription("Game Image")
.assertIsDisplayed()
// Trailer play button should be shown and clickable
composeTestRule
.onNodeWithContentDescription("Play Trailer")
.assertIsDisplayed()
.assertHasClickAction()
// Game title should be shown
composeTestRule
.onNodeWithText("Grand Theft Auto V")
.assertIsDisplayed()
// Game genres should be shown
composeTestRule
.onNodeWithText("Action Adventure")
.assertIsDisplayed()
// Game description should be shown
composeTestRule
.onNodeWithText("About")
.assertIsDisplayed()
composeTestRule
.onNodeWithText("Show More")
.assertIsDisplayed()
composeTestRule
.onNodeWithTag("Description")
.assertIsDisplayed()
// Game platforms should be shown
composeTestRule
.onNodeWithText("Platforms")
.assertIsDisplayed()
composeTestRule
.onNodeWithTag("Game Platforms")
.assertIsDisplayed()
// Scroll to desired view
composeTestRule
.onNodeWithText("Stores")
.performScrollTo()
composeTestRule
.onNodeWithTag("Game Stores")
.performScrollTo()
// Game stores should be shown
composeTestRule
.onNodeWithText("Stores")
.assertIsDisplayed()
composeTestRule
.onNodeWithTag("Game Stores")
.assertIsDisplayed()
// Scroll to desired view
composeTestRule
.onNodeWithText("Developer")
.performScrollTo()
composeTestRule
.onNodeWithText("Rockstar North")
.performScrollTo()
// Game developers should be shown
composeTestRule
.onNodeWithText("Developer")
.assertIsDisplayed()
composeTestRule
.onNodeWithText("Rockstar North")
.assertIsDisplayed()
// Scroll to desired view
composeTestRule
.onNodeWithText("Publisher")
.performScrollTo()
composeTestRule
.onNodeWithText("Rockstar Games")
.performScrollTo()
// Game publishers should be shown
composeTestRule
.onNodeWithText("Publisher")
.assertIsDisplayed()
composeTestRule
.onNodeWithText("Rockstar Games")
.assertIsDisplayed()
}
}
object FakeGamesData {
fun getFakeGameDetails(): GameDetailsEntity {
// provide fake game details data
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment