Skip to content

Commit

Permalink
add more goal detailed statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
Razeeman committed Dec 22, 2024
1 parent 9d40001 commit ba4f8eb
Show file tree
Hide file tree
Showing 16 changed files with 250 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class AddRecordTest : BaseUiTest() {

// Set comment
clickOnViewWithText(coreR.string.change_record_comment_field)
typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment)
closeSoftKeyboard()
tryAction { checkPreviewUpdated(hasDescendant(withText(comment))) }
clickOnViewWithText(coreR.string.change_record_comment_field)
Expand Down Expand Up @@ -289,7 +289,7 @@ class AddRecordTest : BaseUiTest() {
// Select last comment
clickOnViewWithText(comment1)
tryAction { checkPreviewUpdated(hasDescendant(withText(comment1))) }
typeTextIntoView(changeRecordR.id.etChangeRecordComment, "")
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, "")
clickOnViewWithText(coreR.string.change_record_comment_field)

// Select activity with many previous comments
Expand Down Expand Up @@ -334,15 +334,15 @@ class AddRecordTest : BaseUiTest() {
checkViewIsNotDisplayed(withId(changeRecordR.id.btnChangeRecordFavouriteComment))

// Add favourite
typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment1)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment1)
tryAction { checkPreviewUpdated(hasDescendant(withText(comment1))) }
checkViewIsDisplayed(withId(changeRecordR.id.btnChangeRecordFavouriteComment))
clickOnViewWithId(changeRecordR.id.btnChangeRecordFavouriteComment)
checkViewIsDisplayed(withText(coreR.string.change_record_favourite_comments_hint))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment1)))

// Add another
typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment2)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment2)
tryAction { checkPreviewUpdated(hasDescendant(withText(comment2))) }
checkViewIsDisplayed(withId(changeRecordR.id.btnChangeRecordFavouriteComment))
clickOnViewWithId(changeRecordR.id.btnChangeRecordFavouriteComment)
Expand All @@ -361,7 +361,7 @@ class AddRecordTest : BaseUiTest() {
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment2)))

// Favourites and last
typeTextIntoView(changeRecordR.id.etChangeRecordComment, "")
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, "")
clickOnViewWithText(coreR.string.change_record_comment_field)
clickOnViewWithText(coreR.string.change_record_type_field)
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name))
Expand Down Expand Up @@ -390,10 +390,6 @@ class AddRecordTest : BaseUiTest() {
clickOnViewWithText(coreR.string.change_record_comment_field)
closeSoftKeyboard()

checkViewIsDisplayed(withId(changeRecordR.id.etChangeRecordComment))
checkViewDoesNotExist(withId(changeRecordR.id.etChangeRecordCommentField))
clickOnViewWithId(changeRecordR.id.btnChangeRecordSearchComment)
checkViewIsNotDisplayed(withId(changeRecordR.id.etChangeRecordComment))
checkViewIsDisplayed(withId(changeRecordR.id.etChangeRecordCommentField))

typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, "comment")
Expand All @@ -411,11 +407,6 @@ class AddRecordTest : BaseUiTest() {
// Click on search result
clickOnView(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment2)))
tryAction { checkPreviewUpdated(hasDescendant(withText(comment2))) }

// Go back
clickOnViewWithId(changeRecordR.id.btnChangeRecordSearchCommentField)
checkViewIsDisplayed(withId(changeRecordR.id.etChangeRecordComment))
checkViewIsNotDisplayed(withId(changeRecordR.id.etChangeRecordCommentField))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ChangeRecordTest : BaseUiTest() {
.let { timeMapper.formatInterval(interval = it, forceSeconds = false, useProportionalMinutes = false) }

clickOnViewWithText(coreR.string.change_record_comment_field)
typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment)
clickOnViewWithText(coreR.string.change_record_comment_field)
clickOnViewWithText(coreR.string.change_record_type_field)
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name))
Expand All @@ -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.etChangeRecordComment), withText(comment)))
checkViewIsNotDisplayed(allOf(withId(changeRecordR.id.etChangeRecordCommentField), withText(comment)))
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 Expand Up @@ -179,7 +179,7 @@ class ChangeRecordTest : BaseUiTest() {
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeEndedTime), withText(timeEnded.time)))

clickOnViewWithText(coreR.string.change_record_comment_field)
typeTextIntoView(changeRecordR.id.etChangeRecordComment, newComment)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, newComment)
clickOnViewWithText(coreR.string.change_record_comment_field)

// Preview is updated
Expand Down Expand Up @@ -303,7 +303,7 @@ class ChangeRecordTest : BaseUiTest() {

// From quick actions
longClickOnView(allOf(withText(name), isCompletelyDisplayed()))
clickOnViewWithId(dialogsR.id.btnRecordQuickActionsStatistics)
clickOnViewWithText(R.string.shortcut_navigation_statistics)
checkViewIsDisplayed(
allOf(
withId(statisticsDetailR.id.viewStatisticsDetailItem),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ChangeRunningRecordTest : BaseUiTest() {
idData = RecordTypeGoal.IdData.Type(0),
range = RecordTypeGoal.Range.Session,
type = RecordTypeGoal.Type.Duration(firstGoalTime),
subtype = RecordTypeGoal.Subtype.Goal,
daysOfWeek = emptyList(),
),
),
Expand Down Expand Up @@ -106,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.etChangeRecordComment), withText("")))
checkViewIsNotDisplayed(allOf(withId(changeRecordR.id.etChangeRecordCommentField), withText("")))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeStartedDate), withText(timeStarted.date)))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeStartedTime), withText(timeStarted.time)))

Expand Down Expand Up @@ -156,7 +157,7 @@ class ChangeRunningRecordTest : BaseUiTest() {
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeStartedDate), withText(timeStarted.date)))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordTimeStartedTime), withText(timeStarted.time)))
clickOnViewWithText(coreR.string.change_record_comment_field)
typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment)
clickOnViewWithText(coreR.string.change_record_comment_field)

// Preview is updated
Expand Down Expand Up @@ -434,7 +435,7 @@ class ChangeRunningRecordTest : BaseUiTest() {
// Select last comment
clickOnViewWithText(comment1)
tryAction { checkPreviewUpdated(hasDescendant(withText(comment1))) }
typeTextIntoView(changeRecordR.id.etChangeRecordComment, "")
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, "")
clickOnViewWithText(coreR.string.change_record_comment_field)

// Select activity with many previous comments
Expand All @@ -454,7 +455,7 @@ class ChangeRunningRecordTest : BaseUiTest() {
tryAction { checkPreviewUpdated(hasDescendant(withText(comment2))) }
clickOnViewWithText(comment3)
tryAction { checkPreviewUpdated(hasDescendant(withText(comment3))) }
typeTextIntoView(changeRecordR.id.etChangeRecordComment, "")
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, "")
clickOnViewWithText(coreR.string.change_record_comment_field)

// Select activity with no previous comments
Expand Down Expand Up @@ -550,7 +551,7 @@ class ChangeRunningRecordTest : BaseUiTest() {
// From quick actions
NavUtils.openRecordsScreen()
longClickOnView(allOf(withText(name), isCompletelyDisplayed()))
clickOnViewWithId(dialogsR.id.btnRecordQuickActionsStatistics)
clickOnViewWithText(R.string.shortcut_navigation_statistics)
checkViewIsDisplayed(
allOf(
withId(statisticsDetailR.id.viewStatisticsDetailItem),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import java.util.concurrent.TimeUnit
import com.example.util.simpletimetracker.core.R as coreR
import com.example.util.simpletimetracker.feature_base_adapter.R as baseR
import com.example.util.simpletimetracker.feature_change_record.R as changeRecordR
import com.example.util.simpletimetracker.feature_dialogs.R as dialogsR
import com.example.util.simpletimetracker.feature_statistics_detail.R as statisticsDetailR
import com.example.util.simpletimetracker.feature_views.R as viewsR

Expand Down Expand Up @@ -118,7 +117,7 @@ class ChangeUntrackedTest : BaseUiTest() {

// From quick actions
longClickOnView(allOf(withText(coreR.string.untracked_time_name), isCompletelyDisplayed()))
clickOnViewWithId(dialogsR.id.btnRecordQuickActionsStatistics)
clickOnViewWithText(R.string.shortcut_navigation_statistics)
checkViewIsDisplayed(
allOf(
withId(statisticsDetailR.id.viewStatisticsDetailItem),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.junit.runner.RunWith
import com.example.util.simpletimetracker.core.R as coreR
import com.example.util.simpletimetracker.feature_base_adapter.R as baseR
import com.example.util.simpletimetracker.feature_change_record.R as changeRecordR
import com.example.util.simpletimetracker.feature_dialogs.R as dialogsR

@HiltAndroidTest
@RunWith(AndroidJUnit4::class)
Expand Down Expand Up @@ -88,8 +87,8 @@ class DeleteRecordTest : BaseUiTest() {
// Delete item
NavUtils.openRecordsScreen()
longClickOnView(allOf(withText(name), isCompletelyDisplayed()))
checkViewIsDisplayed(withId(dialogsR.id.btnRecordQuickActionsDelete))
clickOnViewWithId(dialogsR.id.btnRecordQuickActionsDelete)
checkViewIsDisplayed(withText(R.string.archive_dialog_delete))
clickOnViewWithText(R.string.archive_dialog_delete)

// Check message
checkViewIsDisplayed(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.junit.Test
import org.junit.runner.RunWith
import com.example.util.simpletimetracker.feature_base_adapter.R as baseR
import com.example.util.simpletimetracker.feature_change_record.R as changeRecordR
import com.example.util.simpletimetracker.feature_dialogs.R as dialogsR

@HiltAndroidTest
@RunWith(AndroidJUnit4::class)
Expand Down Expand Up @@ -99,8 +98,8 @@ class DeleteRunningRecordTest : BaseUiTest() {
longClickOnView(
allOf(isDescendantOfA(withId(baseR.id.viewRunningRecordItem)), withText(name), isCompletelyDisplayed()),
)
checkViewIsDisplayed(withId(dialogsR.id.btnRecordQuickActionsDelete))
clickOnViewWithId(dialogsR.id.btnRecordQuickActionsDelete)
checkViewIsDisplayed(withText(R.string.archive_dialog_delete))
clickOnViewWithText(R.string.archive_dialog_delete)

// Record is deleted
tryAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ object GoalsTestUtils {
idData = RecordTypeGoal.IdData.Type(0),
range = range,
type = RecordTypeGoal.Type.Duration(duration),
daysOfWeek = DayOfWeek.values().toList(),
subtype = RecordTypeGoal.Subtype.Goal,
daysOfWeek = DayOfWeek.entries,
)
}

Expand All @@ -238,7 +239,8 @@ object GoalsTestUtils {
idData = RecordTypeGoal.IdData.Type(0),
range = range,
type = RecordTypeGoal.Type.Count(count),
daysOfWeek = DayOfWeek.values().toList(),
subtype = RecordTypeGoal.Subtype.Goal,
daysOfWeek = DayOfWeek.entries,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class RecordActionsDuplicateTest : BaseUiTest() {
clickOnViewWithText(coreR.string.change_record_type_field)
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name))
clickOnViewWithText(coreR.string.change_record_comment_field)
typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment)
closeSoftKeyboard()
clickOnViewWithText(coreR.string.change_record_comment_field)

Expand Down Expand Up @@ -246,7 +246,7 @@ class RecordActionsDuplicateTest : BaseUiTest() {
clickOnViewWithText(coreR.string.change_record_type_field)
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name))
clickOnViewWithText(coreR.string.change_record_comment_field)
typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment)
closeSoftKeyboard()
clickOnViewWithText(coreR.string.change_record_comment_field)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class StartRecordTest : BaseUiTest() {
idData = RecordTypeGoal.IdData.Type(0),
range = RecordTypeGoal.Range.Session,
type = RecordTypeGoal.Type.Duration(firstGoalTime),
subtype = RecordTypeGoal.Subtype.Goal,
daysOfWeek = emptyList(),
),
),
Expand Down Expand Up @@ -151,7 +152,7 @@ class StartRecordTest : BaseUiTest() {
// Add comment
longClickOnView(allOf(isDescendantOfA(withId(baseR.id.viewRunningRecordItem)), withText(name)))
clickOnViewWithText(coreR.string.change_record_comment_field)
typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment)
clickOnViewWithText(coreR.string.change_record_comment_field)
clickOnViewWithText(coreR.string.change_record_save)

Expand All @@ -170,7 +171,7 @@ class StartRecordTest : BaseUiTest() {
)
clickOnView(allOf(withText(name), isCompletelyDisplayed()))
clickOnViewWithText(coreR.string.change_record_comment_field)
checkViewIsDisplayed(allOf(withId(changeRecordR.id.etChangeRecordComment), withText(comment)))
checkViewIsDisplayed(allOf(withId(changeRecordR.id.etChangeRecordCommentField), withText(comment)))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ object NavUtils {
goal: RecordTypeGoal,
) {
val newGoal = goal.copy(
type = when (val type = goal.type) {
type = when (goal.type) {
is RecordTypeGoal.Type.Duration -> RecordTypeGoal.Type.Duration(0)
is RecordTypeGoal.Type.Count -> RecordTypeGoal.Type.Count(0)
},
Expand Down Expand Up @@ -324,7 +324,7 @@ object NavUtils {
// Comment
if (!comment.isNullOrEmpty()) {
clickOnViewWithText(coreR.string.change_record_comment_field)
typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment)
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment)
clickOnViewWithText(coreR.string.change_record_comment_field)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun createChangeRecordCommentFieldAdapterDelegate(
binding.ivChangeRecordFavouriteComment,
ColorStateList.valueOf(item.iconColor),
)
btnChangeRecordCommentField.setOnClick { onFavouriteClick() }
btnChangeRecordFavouriteComment.setOnClick { onFavouriteClick() }

etChangeRecordCommentField.removeTextChangedListener(textWatcher)
textWatcher = etChangeRecordCommentField.doAfterTextChanged { afterTextChange(it.toString()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
app:layout_constraintEnd_toStartOf="@id/btnChangeRecordCommentField"
app:layout_constraintEnd_toStartOf="@id/btnChangeRecordFavouriteComment"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

Expand All @@ -25,7 +25,7 @@
</com.google.android.material.textfield.TextInputLayout>

<androidx.cardview.widget.CardView
android:id="@+id/btnChangeRecordCommentField"
android:id="@+id/btnChangeRecordFavouriteComment"
style="@style/InputFieldCard"
android:layout_width="36dp"
android:layout_height="0dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum class StatisticsDetailBlock {
DurationSplitChart,
DurationSplitChartComparison,
NextActivities,
GoalStats,
GoalExcessDeficitHint,
GoalChartData,
GoalChartGrouping,
Expand Down
Loading

0 comments on commit ba4f8eb

Please sign in to comment.