Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Razeeman committed Jan 19, 2025
1 parent 67b8dbe commit edf5ad7
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class AddCategoryTest : BaseUiTest() {
clickOnViewWithText(coreR.string.change_category_types_hint)

// Selecting goal time
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()
clickOnView(
allOf(
isDescendantOfA(withId(R.id.layoutChangeRecordTypeGoalSession)),
Expand All @@ -141,7 +141,7 @@ class AddCategoryTest : BaseUiTest() {
clickOnViewWithId(dialogsR.id.tvNumberKeyboard0)
clickOnViewWithText(coreR.string.duration_dialog_save)
checkViewIsDisplayed(withText("10$minuteString"))
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()

// Adding note
onView(withId(changeCategoryR.id.etChangeRecordCategoryNote)).perform(nestedScrollTo())
Expand All @@ -164,9 +164,9 @@ class AddCategoryTest : BaseUiTest() {

// Check goals saved
Thread.sleep(1000)
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()
checkViewIsDisplayed(withText("10$minuteString"))
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()

// Check note saved
onView(withId(changeCategoryR.id.etChangeRecordCategoryNote)).perform(nestedScrollTo())
Expand All @@ -180,15 +180,15 @@ class AddCategoryTest : BaseUiTest() {
clickOnViewWithText(coreR.string.categories_add_category)

// Goal time is disabled
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()
checkViewIsDisplayed(
allOf(
isDescendantOfA(withId(R.id.layoutChangeRecordTypeGoalSession)),
withId(R.id.tvChangeRecordTypeGoalDurationValue),
withText(coreR.string.change_record_type_goal_time_disabled),
),
)
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()

// Open activity chooser
clickOnViewWithText(coreR.string.change_category_types_hint)
Expand Down Expand Up @@ -264,4 +264,13 @@ class AddCategoryTest : BaseUiTest() {

private fun checkPreviewUpdated(matcher: Matcher<View>) =
checkViewIsDisplayed(allOf(withId(changeCategoryR.id.previewChangeCategory), matcher))

private fun openGoals() {
clickOnView(
allOf(
withId(changeCategoryR.id.tvChangeCategoryGoalHint),
withText(coreR.string.change_record_type_goal_time_hint),
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class AddRecordTest : BaseUiTest() {
closeSoftKeyboard()
checkViewDoesNotExist(withText(coreR.string.change_record_last_comments_hint))
checkViewDoesNotExist(withText(coreR.string.change_record_favourite_comments_hint))
checkViewIsNotDisplayed(withId(changeRecordR.id.btnChangeRecordFavouriteComment))
checkViewIsDisplayed(withId(changeRecordR.id.btnChangeRecordFavouriteComment))

// Add favourite
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment1)
Expand Down Expand Up @@ -392,7 +392,7 @@ class AddRecordTest : BaseUiTest() {

checkViewIsDisplayed(withId(changeRecordR.id.etChangeRecordCommentField))

typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, "comment")
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, "comm")
tryAction {
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment1)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class AddRecordTypeTest : BaseUiTest() {
clickOnViewWithText(coreR.string.category_hint)

// Selecting goal time
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()
clickOnView(
allOf(
isDescendantOfA(withId(changeRecordTypeR.id.layoutChangeRecordTypeGoalSession)),
Expand All @@ -158,7 +158,7 @@ class AddRecordTypeTest : BaseUiTest() {
clickOnViewWithId(dialogsR.id.tvNumberKeyboard0)
clickOnViewWithText(coreR.string.duration_dialog_save)
checkViewIsDisplayed(withText("10$minuteString"))
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()

// Adding note
onView(withId(changeRecordTypeR.id.etChangeRecordTypeNote)).perform(nestedScrollTo())
Expand Down Expand Up @@ -189,15 +189,15 @@ class AddRecordTypeTest : BaseUiTest() {
closeSoftKeyboard()

// Goal time is disabled
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()
checkViewIsDisplayed(
allOf(
isDescendantOfA(withId(changeRecordTypeR.id.layoutChangeRecordTypeGoalSession)),
withId(changeRecordTypeR.id.tvChangeRecordTypeGoalDurationValue),
withText(coreR.string.change_record_type_goal_time_disabled),
),
)
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()

// Open category chooser
clickOnViewWithText(coreR.string.category_hint)
Expand Down Expand Up @@ -229,4 +229,13 @@ class AddRecordTypeTest : BaseUiTest() {

private fun checkPreviewUpdated(matcher: Matcher<View>) =
checkViewIsDisplayed(allOf(withId(changeRecordTypeR.id.previewChangeRecordType), matcher))

private fun openGoals() {
clickOnView(
allOf(
withId(changeRecordTypeR.id.tvChangeRecordTypeGoalHint),
withText(coreR.string.change_record_type_goal_time_hint),
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ChangeRecordTest : BaseUiTest() {
checkViewIsDisplayed(withId(changeRecordR.id.btnChangeRecordStatistics))
checkViewIsNotDisplayed(withId(changeRecordR.id.rvChangeRecordType))
checkViewIsNotDisplayed(withId(changeRecordR.id.rvChangeRecordCategories))
checkViewIsNotDisplayed(allOf(withId(changeRecordR.id.etChangeRecordCommentField), withText(comment)))
checkViewIsNotDisplayed(withId(changeRecordR.id.rvChangeRecordComments))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeStartedDate), withText(timeStarted.date)))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeStartedTime), withText(timeStarted.time)))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeEndedDate), withText(timeEnded.date)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class ChangeRecordTypeTest : BaseUiTest() {
clickOnRecyclerItem(changeRecordTypeR.id.rvIconSelection, withTag(lastIcon))
clickOnViewWithId(changeRecordTypeR.id.fieldChangeRecordTypeIcon)

clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()
clickOnView(
allOf(
isDescendantOfA(withId(changeRecordTypeR.id.layoutChangeRecordTypeGoalSession)),
Expand All @@ -176,7 +176,7 @@ class ChangeRecordTypeTest : BaseUiTest() {
clickOnViewWithId(dialogsR.id.tvNumberKeyboard0)
clickOnViewWithText(coreR.string.duration_dialog_save)
tryAction { checkViewIsDisplayed(withText("10$minuteString")) }
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
openGoals()

clickOnViewWithText(coreR.string.change_record_type_save)

Expand Down Expand Up @@ -269,4 +269,13 @@ class ChangeRecordTypeTest : BaseUiTest() {

private fun checkPreviewUpdated(matcher: Matcher<View>) =
checkViewIsDisplayed(allOf(withId(changeRecordTypeR.id.previewChangeRecordType), matcher))

private fun openGoals() {
clickOnView(
allOf(
withId(changeRecordTypeR.id.tvChangeRecordTypeGoalHint),
withText(coreR.string.change_record_type_goal_time_hint),
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ChangeRunningRecordTest : BaseUiTest() {
checkViewIsNotDisplayed(withId(changeRecordR.id.rvChangeRecordCategories))
checkViewIsDisplayed(withId(changeRecordR.id.containerChangeRecordTimeStartedAdjust))
checkViewIsNotDisplayed(withId(changeRecordR.id.containerChangeRecordTimeEndedAdjust))
checkViewIsNotDisplayed(allOf(withId(changeRecordR.id.etChangeRecordCommentField), withText("")))
checkViewIsNotDisplayed(withId(changeRecordR.id.rvChangeRecordComments))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeStartedDate), withText(timeStarted.date)))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeStartedTime), withText(timeStarted.time)))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.example.util.simpletimetracker.utils.BaseUiTest
import com.example.util.simpletimetracker.utils.NavUtils
import com.example.util.simpletimetracker.utils.checkViewIsDisplayed
import com.example.util.simpletimetracker.utils.clickOnView
import com.example.util.simpletimetracker.utils.clickOnViewWithId
import com.example.util.simpletimetracker.utils.clickOnViewWithText
import com.example.util.simpletimetracker.utils.longClickOnView
import com.example.util.simpletimetracker.utils.nestedScrollTo
Expand Down Expand Up @@ -113,6 +114,7 @@ class GoalsTabTest : BaseUiTest() {
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
goalsToAdd.forEach { goal ->
NavUtils.addGoalToActivity(goal)
runCatching { clickOnViewWithId(com.google.android.material.R.id.snackbar_text) }
checkGoal(goal)
}
clickOnViewWithText(coreR.string.change_record_type_save)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ class RecordActionsAdjustTest : BaseUiTest() {
adjust(isStart = false, buttonText = "+30")
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_adjust))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_adjust)),
)
clickOnViewWithText(coreR.string.change_record_adjust)

// Check records
Expand Down Expand Up @@ -180,7 +183,10 @@ class RecordActionsAdjustTest : BaseUiTest() {
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name2))
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_adjust))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_adjust)),
)
clickOnViewWithText(coreR.string.change_record_adjust)

// Check records
Expand Down Expand Up @@ -245,7 +251,10 @@ class RecordActionsAdjustTest : BaseUiTest() {
clickOnViewWithText("-5")
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_adjust))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_adjust)),
)
clickOnViewWithText(coreR.string.change_record_adjust)

// Check records
Expand Down Expand Up @@ -298,7 +307,10 @@ class RecordActionsAdjustTest : BaseUiTest() {
adjust(isStart = false, buttonText = "+30")
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_adjust))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_adjust)),
)
clickOnViewWithText(coreR.string.change_record_adjust)

// Check records
Expand Down Expand Up @@ -415,7 +427,10 @@ class RecordActionsAdjustTest : BaseUiTest() {
onPreviewCheck(name1).perform(click())
onPreviewCheck(name1).check(matches(isNotChecked()))

scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_adjust))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_adjust)),
)
clickOnViewWithText(coreR.string.change_record_adjust)

// Check records
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ class RecordActionsContinueTest : BaseUiTest() {
clickOnViewWithText(fullName)
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)

// Check no record
Expand Down Expand Up @@ -124,7 +127,10 @@ class RecordActionsContinueTest : BaseUiTest() {
// Continue untracked doesn't work
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)
clickOnViewWithId(com.google.android.material.R.id.snackbar_text)
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
Expand All @@ -137,7 +143,10 @@ class RecordActionsContinueTest : BaseUiTest() {
// Continue
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)

checkViewIsDisplayed(
Expand Down Expand Up @@ -185,7 +194,10 @@ class RecordActionsContinueTest : BaseUiTest() {
// Continue untracked doesn't work
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)
clickOnViewWithId(com.google.android.material.R.id.snackbar_text)
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
Expand All @@ -198,7 +210,10 @@ class RecordActionsContinueTest : BaseUiTest() {
// Continue
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)

checkViewDoesNotExist(
Expand Down Expand Up @@ -251,7 +266,10 @@ class RecordActionsContinueTest : BaseUiTest() {
clickOnView(allOf(withText(name), isCompletelyDisplayed()))
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)
// Snackbar is in the way of Add button
clickOnViewWithId(com.google.android.material.R.id.snackbar_text)
Expand All @@ -272,7 +290,10 @@ class RecordActionsContinueTest : BaseUiTest() {
adjust("+5")
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)

// Still on edit screen
Expand Down Expand Up @@ -318,7 +339,10 @@ class RecordActionsContinueTest : BaseUiTest() {
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name))
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)

// Running record stopped
Expand Down Expand Up @@ -351,7 +375,10 @@ class RecordActionsContinueTest : BaseUiTest() {
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name2))
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)

// Running record stopped
Expand Down Expand Up @@ -391,7 +418,10 @@ class RecordActionsContinueTest : BaseUiTest() {
NavUtils.openRecordsScreen()
clickOnView(allOf(withText(name), isCompletelyDisplayed()))
clickOnViewWithText(coreR.string.change_record_actions_hint)
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
scrollRecyclerToView(
changeRecordR.id.rvChangeRecordAction,
hasDescendant(withText(coreR.string.change_record_continue)),
)
clickOnViewWithText(coreR.string.change_record_continue)

// New running record
Expand Down
Loading

0 comments on commit edf5ad7

Please sign in to comment.