Skip to content
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
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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!!)
}
Expand Down
2 changes: 1 addition & 1 deletion libs/pandares/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@
<string name="widgetErrorTitle">Oops! Something Went Wrong</string>
<string name="widgetErrorSubtitle">We\'re having trouble showing your tasks right now. Please try again in a bit or head to the app.</string>
<string name="widgetToDoEmptyTitle">You’re all done for now!</string>
<string name="widgetToDoEmptySubtitle">Looks like you\'re free for the next 4 weeks. Do you want to add some to-dos?</string>
<string name="widgetToDoEmptySubtitle">Looks like you are free, you have no upcoming tasks. Do you want to add some to-dos?</string>
<string name="widgetNotLoggedInTitle">Let\'s Get You Logged In!</string>
<string name="widgetToDoNotLoggedInSubtitle">To see your to-dos, please log in to your account in the app. It\'ll just take a sec!</string>
<string name="a11y_widgetToDoOpenToDoList">Open To Do list screen</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading