diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/interaction/ToDoListInteractionTest.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/interaction/ToDoListInteractionTest.kt index eecdb1790c..d1d357511b 100644 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/interaction/ToDoListInteractionTest.kt +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/interaction/ToDoListInteractionTest.kt @@ -261,6 +261,13 @@ abstract class ToDoListInteractionTest : CanvasComposeTest() { goToToDoList(data) + composeTestRule.waitForIdle() + + // Ensure the assignment is visible by setting future range to cover 3 days ahead + toDoListPage.clickFilterButton() + toDoFilterPage.selectFutureDateRange(R.string.todoFilterNextWeek) + toDoFilterPage.clickDone() + composeTestRule.waitForIdle() toDoListPage.assertItemDisplayed(assignment.name!!) toDoListPage.clickDateBadge(dayOfMonth) @@ -475,13 +482,13 @@ abstract class ToDoListInteractionTest : CanvasComposeTest() { val course = data.courses.values.first() val calendar = Calendar.getInstance() - // Create assignment 2 weeks ago - calendar.add(Calendar.WEEK_OF_YEAR, -2) - val twoWeeksAgo = calendar.time + // Create assignment 3 weeks ago + calendar.add(Calendar.WEEK_OF_YEAR, -3) + val threeWeeksAgo = calendar.time val oldAssignment = data.addAssignment( course.id, name = "Old Assignment", - dueAt = twoWeeksAgo.toApiString() + dueAt = threeWeeksAgo.toApiString() ) // Create assignment today @@ -496,18 +503,29 @@ abstract class ToDoListInteractionTest : CanvasComposeTest() { composeTestRule.waitForIdle() - // By default, past date range is "Last Week" so assignment from 2 weeks ago should be hidden + // By default, past date range is "4 Weeks Ago" so assignment from 3 weeks ago should be visible + toDoListPage.assertItemDisplayed(todayAssignment.name!!) + toDoListPage.assertItemDisplayed(oldAssignment.name!!) + + // Change past date range to "Last Week" to hide the older assignment + toDoListPage.clickFilterButton() + toDoFilterPage.selectPastDateRange(R.string.todoFilterLastWeek) + toDoFilterPage.clickDone() + + composeTestRule.waitForIdle() + + // Assignment from 3 weeks ago should now be hidden (outside 1-week range) toDoListPage.assertItemDisplayed(todayAssignment.name!!) toDoListPage.assertItemNotDisplayed(oldAssignment.name!!) - // Change past date range to "2 Weeks Ago" + // Change past date range to "4 Weeks Ago" to show the older assignment again toDoListPage.clickFilterButton() - toDoFilterPage.selectPastDateRange(R.string.todoFilterTwoWeeks) + toDoFilterPage.selectPastDateRange(R.string.todoFilterFourWeeks) toDoFilterPage.clickDone() composeTestRule.waitForIdle() - // Now both assignments should be visible + // Assignment from 3 weeks ago should now be visible again (within 4-week range) toDoListPage.assertItemDisplayed(todayAssignment.name!!) toDoListPage.assertItemDisplayed(oldAssignment.name!!) } diff --git a/libs/pandares/src/main/res/values/strings.xml b/libs/pandares/src/main/res/values/strings.xml index 590a0883f9..cafecc1c61 100644 --- a/libs/pandares/src/main/res/values/strings.xml +++ b/libs/pandares/src/main/res/values/strings.xml @@ -2104,7 +2104,7 @@ Oops! Something Went Wrong We\'re having trouble showing your tasks right now. Please try again in a bit or head to the app. You’re all done for now! - Looks like you\'re free for the next 4 weeks. Do you want to add some to-dos? + Looks like you are free, you have no upcoming tasks. Do you want to add some to-dos? Let\'s Get You Logged In! To see your to-dos, please log in to your account in the app. It\'ll just take a sec! Open To Do list screen diff --git a/libs/pandautils/src/androidTest/java/com/instructure/pandautils/room/appdatabase/daos/ToDoFilterDaoTest.kt b/libs/pandautils/src/androidTest/java/com/instructure/pandautils/room/appdatabase/daos/ToDoFilterDaoTest.kt index f2c481920f..779209a083 100644 --- a/libs/pandautils/src/androidTest/java/com/instructure/pandautils/room/appdatabase/daos/ToDoFilterDaoTest.kt +++ b/libs/pandautils/src/androidTest/java/com/instructure/pandautils/room/appdatabase/daos/ToDoFilterDaoTest.kt @@ -250,7 +250,7 @@ class ToDoFilterDaoTest { assertEquals(false, foundFilter?.calendarEvents) assertEquals(false, foundFilter?.showCompleted) assertEquals(false, foundFilter?.favoriteCourses) - assertEquals(DateRangeSelection.ONE_WEEK, foundFilter?.pastDateRange) - assertEquals(DateRangeSelection.ONE_WEEK, foundFilter?.futureDateRange) + assertEquals(DateRangeSelection.FOUR_WEEKS, foundFilter?.pastDateRange) + assertEquals(DateRangeSelection.THIS_WEEK, foundFilter?.futureDateRange) } } \ No newline at end of file diff --git a/libs/pandautils/src/main/java/com/instructure/pandautils/features/todolist/ToDoListViewModel.kt b/libs/pandautils/src/main/java/com/instructure/pandautils/features/todolist/ToDoListViewModel.kt index 077d7362bc..1130ea93d3 100644 --- a/libs/pandautils/src/main/java/com/instructure/pandautils/features/todolist/ToDoListViewModel.kt +++ b/libs/pandautils/src/main/java/com/instructure/pandautils/features/todolist/ToDoListViewModel.kt @@ -497,8 +497,8 @@ class ToDoListViewModel @Inject constructor( !filters.calendarEvents && !filters.showCompleted && !filters.favoriteCourses && - filters.pastDateRange == DateRangeSelection.ONE_WEEK && - filters.futureDateRange == DateRangeSelection.ONE_WEEK + filters.pastDateRange == DateRangeSelection.FOUR_WEEKS && + filters.futureDateRange == DateRangeSelection.THIS_WEEK if (isDefaultFilter) { analytics.logEvent(AnalyticsEventConstants.TODO_LIST_LOADED_DEFAULT_FILTER) @@ -517,6 +517,6 @@ class ToDoListViewModel @Inject constructor( private fun isFilterApplied(filters: ToDoFilterEntity): Boolean { return filters.personalTodos || filters.calendarEvents || filters.showCompleted || filters.favoriteCourses - || filters.pastDateRange != DateRangeSelection.ONE_WEEK || filters.futureDateRange != DateRangeSelection.ONE_WEEK + || filters.pastDateRange != DateRangeSelection.FOUR_WEEKS || filters.futureDateRange != DateRangeSelection.THIS_WEEK } } diff --git a/libs/pandautils/src/main/java/com/instructure/pandautils/features/todolist/filter/ToDoFilterViewModel.kt b/libs/pandautils/src/main/java/com/instructure/pandautils/features/todolist/filter/ToDoFilterViewModel.kt index 467e247dcf..fd2d672278 100644 --- a/libs/pandautils/src/main/java/com/instructure/pandautils/features/todolist/filter/ToDoFilterViewModel.kt +++ b/libs/pandautils/src/main/java/com/instructure/pandautils/features/todolist/filter/ToDoFilterViewModel.kt @@ -54,8 +54,8 @@ class ToDoFilterViewModel @Inject constructor( FILTER_FAVORITE_COURSES to false ) - private var selectedPastOption = DateRangeSelection.ONE_WEEK - private var selectedFutureOption = DateRangeSelection.ONE_WEEK + private var selectedPastOption = DateRangeSelection.FOUR_WEEKS + private var selectedFutureOption = DateRangeSelection.THIS_WEEK private val _uiState = MutableStateFlow(createInitialUiState()) val uiState = _uiState.asStateFlow() diff --git a/libs/pandautils/src/main/java/com/instructure/pandautils/room/appdatabase/entities/ToDoFilterEntity.kt b/libs/pandautils/src/main/java/com/instructure/pandautils/room/appdatabase/entities/ToDoFilterEntity.kt index 4cb0d873ca..510640ee00 100644 --- a/libs/pandautils/src/main/java/com/instructure/pandautils/room/appdatabase/entities/ToDoFilterEntity.kt +++ b/libs/pandautils/src/main/java/com/instructure/pandautils/room/appdatabase/entities/ToDoFilterEntity.kt @@ -28,6 +28,6 @@ data class ToDoFilterEntity( val calendarEvents: Boolean = false, val showCompleted: Boolean = false, val favoriteCourses: Boolean = false, - val pastDateRange: DateRangeSelection = DateRangeSelection.ONE_WEEK, - val futureDateRange: DateRangeSelection = DateRangeSelection.ONE_WEEK + val pastDateRange: DateRangeSelection = DateRangeSelection.FOUR_WEEKS, + val futureDateRange: DateRangeSelection = DateRangeSelection.THIS_WEEK ) \ No newline at end of file diff --git a/libs/pandautils/src/test/java/com/instructure/pandautils/features/todolist/ToDoListViewModelTest.kt b/libs/pandautils/src/test/java/com/instructure/pandautils/features/todolist/ToDoListViewModelTest.kt index f57f38a166..96372a2e20 100644 --- a/libs/pandautils/src/test/java/com/instructure/pandautils/features/todolist/ToDoListViewModelTest.kt +++ b/libs/pandautils/src/test/java/com/instructure/pandautils/features/todolist/ToDoListViewModelTest.kt @@ -120,8 +120,8 @@ class ToDoListViewModelTest { calendarEvents = true, showCompleted = true, // Important: show completed items in tests by default favoriteCourses = false, - pastDateRange = DateRangeSelection.ONE_WEEK, - futureDateRange = DateRangeSelection.ONE_WEEK + pastDateRange = DateRangeSelection.FOUR_WEEKS, + futureDateRange = DateRangeSelection.THIS_WEEK ) coEvery { toDoFilterDao.findByUser(any(), any()) } returns defaultTestFilter } @@ -1177,8 +1177,8 @@ class ToDoListViewModelTest { calendarEvents = false, showCompleted = false, favoriteCourses = false, - pastDateRange = DateRangeSelection.ONE_WEEK, - futureDateRange = DateRangeSelection.ONE_WEEK + pastDateRange = DateRangeSelection.FOUR_WEEKS, + futureDateRange = DateRangeSelection.THIS_WEEK ) coEvery { repository.getCourses(any()) } returns DataResult.Success(emptyList()) @@ -1276,8 +1276,8 @@ class ToDoListViewModelTest { calendarEvents = false, showCompleted = false, favoriteCourses = false, - pastDateRange = DateRangeSelection.ONE_WEEK, - futureDateRange = DateRangeSelection.ONE_WEEK + pastDateRange = DateRangeSelection.FOUR_WEEKS, + futureDateRange = DateRangeSelection.THIS_WEEK ) coEvery { repository.getCourses(any()) } returns DataResult.Success(emptyList()) diff --git a/libs/pandautils/src/test/java/com/instructure/pandautils/features/todolist/filter/ToDoFilterViewModelTest.kt b/libs/pandautils/src/test/java/com/instructure/pandautils/features/todolist/filter/ToDoFilterViewModelTest.kt index 20da4ade08..fb0893a3f9 100644 --- a/libs/pandautils/src/test/java/com/instructure/pandautils/features/todolist/filter/ToDoFilterViewModelTest.kt +++ b/libs/pandautils/src/test/java/com/instructure/pandautils/features/todolist/filter/ToDoFilterViewModelTest.kt @@ -112,9 +112,9 @@ class ToDoFilterViewModelTest { assertFalse(state.checkboxItems[2].checked) // Show completed assertFalse(state.checkboxItems[3].checked) // Favorite courses - // Default date range should be ONE_WEEK - assertEquals(DateRangeSelection.ONE_WEEK, state.selectedPastOption) - assertEquals(DateRangeSelection.ONE_WEEK, state.selectedFutureOption) + // Default date range should be FOUR_WEEKS (past) and THIS_WEEK (future) + assertEquals(DateRangeSelection.FOUR_WEEKS, state.selectedPastOption) + assertEquals(DateRangeSelection.THIS_WEEK, state.selectedFutureOption) // Flags should be false assertFalse(state.shouldCloseAndApplyFilters)