Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing UI tests #294

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.yasinkacmaz.jetflix.filter

import androidx.compose.foundation.layout.Column
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.test.ComposeUiTest
import androidx.compose.ui.test.ExperimentalTestApi
Expand All @@ -16,7 +15,9 @@ import androidx.compose.ui.test.isSelected
import androidx.compose.ui.test.isToggleable
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.runComposeUiTest
import androidx.compose.ui.test.swipeUp
import com.yasinkacmaz.jetflix.R
import com.yasinkacmaz.jetflix.data.remote.Genre
import com.yasinkacmaz.jetflix.ui.filter.FilterBottomSheet
Expand All @@ -41,12 +42,10 @@ class FilterBottomSheetTest {
FilterState(sortOrder = SortOrder.ASCENDING, sortBy = SortBy.REVENUE, includeAdult = true, genres = genres)

setTestContent {
Column {
FilterBottomSheet(filterState = filterState, onDismiss = {}, onFilterStateChanged = {})
}
FilterBottomSheet(filterState = filterState, onDismiss = {}, onFilterStateChanged = {})
}

verifySortOrderSelected(filterState.sortOrder)
ensureBottomSheetFullyVisible()
verifySortBySelected(filterState.sortBy)
verifyIncludeAdult(filterState.includeAdult)
onNodeWithText(getString(SortOrder.DESCENDING.titleResId)).performClick()
Expand All @@ -64,6 +63,10 @@ class FilterBottomSheetTest {
onNodeWithText(genreNames.first()).assertIsSelected()
}

private fun ComposeUiTest.ensureBottomSheetFullyVisible() {
includeAdultNode().performTouchInput { swipeUp() }
}

private fun ComposeUiTest.verifySortOrderSelected(sortOrder: SortOrder) {
val sortOrderTitle = getString(sortOrder.titleResId)
onNode(withRole(Role.RadioButton).and(isSelected()).and(hasText(sortOrderTitle))).assertIsDisplayed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class MovieDetailScreenTest {
)
renderMovieDetail(movieDetail, credits)

onNodeWithText(movieDetail.releaseDate).performScrollTo()
onNodeWithText(movieDetail.releaseDate, useUnmergedTree = false).assertIsDisplayed()
onNodeWithText("${movieDetail.duration} min", useUnmergedTree = false).assertIsDisplayed()
onNodeWithText(movieDetail.voteAverage.toString(), useUnmergedTree = false).assertIsDisplayed()
Expand Down