From 1396210ba52541ba06a4a9761b45248fa2c9ca1e Mon Sep 17 00:00:00 2001
From: Akos Hermann <72087159+hermannakos@users.noreply.github.com>
Date: Thu, 3 Feb 2022 11:07:04 +0100
Subject: [PATCH] [MBL-15817][Student] Important dates interaction tests
(#1471)
refs: MBL-15817
affects: Student
release note: none
test plan:
---
apps/student/flank_tablet.yml | 2 +-
.../ImportantDatesInteractionTest.kt | 145 ++++++++++++++++++
.../ui/pages/ElementaryDashboardPage.kt | 3 +-
.../student/ui/pages/ImportantDatesPage.kt | 43 ++++++
.../student/ui/utils/StudentTest.kt | 1 +
.../StudentImportantDatesRouter.kt | 5 +-
apps/teacher/flank_tablet.yml | 2 +-
.../TeacherImportantDatesRouter.kt | 3 +-
.../canvas/espresso/StubTabletAnnotation.kt | 21 +++
.../canvas/espresso/mockCanvas/MockCanvas.kt | 30 +++-
.../canvasapi2/models/ScheduleItem.kt | 2 +
.../importantdates/ImportantDatesFragment.kt | 2 +-
.../importantdates/ImportantDatesRouter.kt | 3 +-
.../importantdates/ImportantDatesViewData.kt | 3 +-
.../importantdates/ImportantDatesViewModel.kt | 2 +-
.../fragment_important_dates.xml | 4 +-
.../res/layout/fragment_important_dates.xml | 4 +-
.../ImportantDatesViewModelTest.kt | 2 +-
18 files changed, 262 insertions(+), 15 deletions(-)
create mode 100644 apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ImportantDatesInteractionTest.kt
create mode 100644 apps/student/src/androidTest/java/com/instructure/student/ui/pages/ImportantDatesPage.kt
create mode 100644 automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/StubTabletAnnotation.kt
diff --git a/apps/student/flank_tablet.yml b/apps/student/flank_tablet.yml
index 03db43d962..ff1b6d0238 100644
--- a/apps/student/flank_tablet.yml
+++ b/apps/student/flank_tablet.yml
@@ -12,7 +12,7 @@ gcloud:
record-video: true
timeout: 60m
test-targets:
- - notAnnotation com.instructure.canvas.espresso.E2E, com.instructure.canvas.espresso.Stub
+ - notAnnotation com.instructure.canvas.espresso.E2E, com.instructure.canvas.espresso.Stub, com.instructure.canvas.espresso.StubTablet
device:
- model: Nexus9
version: 26
diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ImportantDatesInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ImportantDatesInteractionTest.kt
new file mode 100644
index 0000000000..673c5066c4
--- /dev/null
+++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ImportantDatesInteractionTest.kt
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2022 - present Instructure, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.instructure.student.ui.interaction
+
+import com.instructure.canvas.espresso.StubTablet
+import com.instructure.canvas.espresso.mockCanvas.*
+import com.instructure.canvasapi2.models.Assignment
+import com.instructure.dataseeding.util.days
+import com.instructure.dataseeding.util.fromNow
+import com.instructure.dataseeding.util.iso8601
+import com.instructure.panda_annotations.FeatureCategory
+import com.instructure.panda_annotations.Priority
+import com.instructure.panda_annotations.TestCategory
+import com.instructure.panda_annotations.TestMetaData
+import com.instructure.student.ui.pages.ElementaryDashboardPage
+import com.instructure.student.ui.utils.StudentTest
+import com.instructure.student.ui.utils.tokenLoginElementary
+import dagger.hilt.android.testing.HiltAndroidTest
+import org.junit.Test
+
+@HiltAndroidTest
+class ImportantDatesInteractionTest : StudentTest() {
+ override fun displaysPageObjects() = Unit
+
+ @Test
+ //The UI is different on tablet, so we only check the phone version
+ @StubTablet
+ @TestMetaData(Priority.P0, FeatureCategory.K5_DASHBOARD, TestCategory.INTERACTION)
+ fun testShowCalendarEvents() {
+ val data = createMockData(courseCount = 1)
+ val course = data.courses.values.toList()[0]
+
+ val event = data.addCourseCalendarEvent(course.id, 2.days.fromNow.iso8601, "Important event", "Important event description", true)
+
+ goToImportantDatesTab(data)
+ importantDatesPage.assertItemDisplayed(event.title!!)
+ }
+
+ @Test
+ @StubTablet
+ @TestMetaData(Priority.P0, FeatureCategory.K5_DASHBOARD, TestCategory.INTERACTION)
+ fun testShowAssignment() {
+ val data = createMockData(courseCount = 1)
+ val course = data.courses.values.toList()[0]
+
+ val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
+ data.addAssignmentCalendarEvent(course.id, 2.days.fromNow.iso8601, assignment.name!!, assignment.description!!, true, assignment)
+
+ goToImportantDatesTab(data)
+ importantDatesPage.assertItemDisplayed(assignment.name!!)
+ }
+
+ @Test
+ @StubTablet
+ @TestMetaData(Priority.P0, FeatureCategory.K5_DASHBOARD, TestCategory.INTERACTION)
+ fun testEmptyView() {
+ val data = createMockData(courseCount = 1)
+
+ goToImportantDatesTab(data)
+
+ importantDatesPage.assertEmptyViewDisplayed()
+ }
+
+ @Test
+ @StubTablet
+ @TestMetaData(Priority.P1, FeatureCategory.K5_DASHBOARD, TestCategory.INTERACTION)
+ fun testPullToRefresh() {
+ val data = createMockData(courseCount = 1)
+ val course = data.courses.values.toList()[0]
+ data.addCourseCalendarEvent(course.id, 2.days.fromNow.iso8601, "Important event", "Important event description", true)
+
+ goToImportantDatesTab(data)
+ val eventToCheck = data.addCourseCalendarEvent(course.id, 2.days.fromNow.iso8601, "Important event 2", "Important event 2 description", true)
+
+ importantDatesPage.pullToRefresh()
+ importantDatesPage.assertItemDisplayed(eventToCheck.title!!)
+ }
+
+ @Test
+ @StubTablet
+ @TestMetaData(Priority.P1, FeatureCategory.K5_DASHBOARD, TestCategory.INTERACTION)
+ fun testOpenCalendarEvent() {
+ val data = createMockData(courseCount = 1)
+ val course = data.courses.values.toList()[0]
+ val event = data.addCourseCalendarEvent(course.id, 2.days.fromNow.iso8601, "Important event", "Important event description", true)
+
+ goToImportantDatesTab(data)
+ importantDatesPage.assertItemDisplayed(event.title!!)
+ importantDatesPage.clickImportantDatesItem(event.title!!)
+ calendarEventPage.verifyTitle(event.title!!)
+ calendarEventPage.verifyDescription(event.description!!)
+ }
+
+ @Test
+ @StubTablet
+ @TestMetaData(Priority.P1, FeatureCategory.K5_DASHBOARD, TestCategory.INTERACTION)
+ fun testOpenAssignment() {
+ val data = createMockData(courseCount = 1)
+ val course = data.courses.values.toList()[0]
+
+ val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
+ data.addAssignmentCalendarEvent(course.id, 2.days.fromNow.iso8601, assignment.name!!, assignment.description!!, true, assignment)
+
+ goToImportantDatesTab(data)
+ importantDatesPage.assertItemDisplayed(assignment.name!!)
+ importantDatesPage.clickImportantDatesItem(assignment.name!!)
+ assignmentDetailsPage.verifyAssignmentDetails(assignment)
+ }
+
+ private fun goToImportantDatesTab(data: MockCanvas) {
+ val student = data.students[0]
+ val token = data.tokenFor(student)!!
+ tokenLoginElementary(data.domain, token, student)
+ elementaryDashboardPage.waitForRender()
+ elementaryDashboardPage.selectTab(ElementaryDashboardPage.ElementaryTabType.IMPORTANT_DATES)
+ //We need this to allow the ViewPager to switch tabs
+ Thread.sleep(100)
+ }
+
+ private fun createMockData(
+ courseCount: Int = 0,
+ withGradingPeriods: Boolean = false,
+ homeroomCourseCount: Int = 0): MockCanvas {
+
+ return MockCanvas.init(
+ studentCount = 1,
+ courseCount = courseCount,
+ withGradingPeriods = withGradingPeriods,
+ homeroomCourseCount = homeroomCourseCount)
+ }
+}
\ No newline at end of file
diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/pages/ElementaryDashboardPage.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/pages/ElementaryDashboardPage.kt
index af4536f294..e70ea4f77e 100644
--- a/apps/student/src/androidTest/java/com/instructure/student/ui/pages/ElementaryDashboardPage.kt
+++ b/apps/student/src/androidTest/java/com/instructure/student/ui/pages/ElementaryDashboardPage.kt
@@ -88,6 +88,7 @@ class ElementaryDashboardPage : BasePage(R.id.elementaryDashboardPage) {
HOMEROOM(R.string.dashboardTabHomeroom),
SCHEDULE(R.string.dashboardTabSchedule),
GRADES(R.string.dashboardTabGrades),
- RESOURCES(R.string.dashboardTabResources)
+ RESOURCES(R.string.dashboardTabResources),
+ IMPORTANT_DATES(R.string.dashboardTabImportantDates)
}
}
\ No newline at end of file
diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/pages/ImportantDatesPage.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/pages/ImportantDatesPage.kt
new file mode 100644
index 0000000000..4df827a217
--- /dev/null
+++ b/apps/student/src/androidTest/java/com/instructure/student/ui/pages/ImportantDatesPage.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2022 - present Instructure, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.instructure.student.ui.pages
+
+import com.instructure.espresso.assertDisplayed
+import com.instructure.espresso.click
+import com.instructure.espresso.page.*
+import com.instructure.espresso.swipeDown
+import com.instructure.student.R
+
+
+class ImportantDatesPage : BasePage(R.id.importantDatesPage) {
+
+ fun assertItemDisplayed(itemName: String) {
+ waitForView(withAncestor(R.id.importantDatesRecyclerView) + withText(itemName)).assertDisplayed()
+ }
+
+ fun assertEmptyViewDisplayed() {
+ onView(withId(R.id.importantDatesEmptyView)).assertDisplayed()
+ }
+
+ fun pullToRefresh() {
+ onView(withId(R.id.importantDatesRecyclerView)).swipeDown()
+ }
+
+ fun clickImportantDatesItem(title: String) {
+ waitForView(withAncestor(R.id.importantDatesRecyclerView) + withText(title)).click()
+ }
+}
\ No newline at end of file
diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentTest.kt
index 60d702ce78..885a0f1c6a 100644
--- a/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentTest.kt
+++ b/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentTest.kt
@@ -109,6 +109,7 @@ abstract class StudentTest : CanvasTest() {
val schedulePage = SchedulePage()
val gradesPage = GradesPage()
val resourcesPage = ResourcesPage()
+ val importantDatesPage = ImportantDatesPage()
// A no-op interaction to afford us an easy, harmless way to get a11y checking to trigger.
fun meaninglessSwipe() {
diff --git a/apps/student/src/main/java/com/instructure/student/mobius/elementary/importantdates/StudentImportantDatesRouter.kt b/apps/student/src/main/java/com/instructure/student/mobius/elementary/importantdates/StudentImportantDatesRouter.kt
index 6cfcad25bd..14840c7e7d 100644
--- a/apps/student/src/main/java/com/instructure/student/mobius/elementary/importantdates/StudentImportantDatesRouter.kt
+++ b/apps/student/src/main/java/com/instructure/student/mobius/elementary/importantdates/StudentImportantDatesRouter.kt
@@ -18,14 +18,15 @@ package com.instructure.student.mobius.elementary.importantdates
import androidx.fragment.app.FragmentActivity
import com.instructure.canvasapi2.models.CanvasContext
+import com.instructure.canvasapi2.models.ScheduleItem
import com.instructure.pandautils.features.elementary.importantdates.ImportantDatesRouter
import com.instructure.student.fragment.CalendarEventFragment
import com.instructure.student.mobius.assignmentDetails.ui.AssignmentDetailsFragment
import com.instructure.student.router.RouteMatcher
class StudentImportantDatesRouter(private val activity: FragmentActivity) : ImportantDatesRouter {
- override fun openCalendarEvent(canvasContext: CanvasContext, scheduleItemId: Long) {
- RouteMatcher.route(activity, CalendarEventFragment.makeRoute(canvasContext, scheduleItemId))
+ override fun openCalendarEvent(canvasContext: CanvasContext, scheduleItem: ScheduleItem) {
+ RouteMatcher.route(activity, CalendarEventFragment.makeRoute(canvasContext, scheduleItem))
}
override fun openAssignment(canvasContext: CanvasContext, assignmentId: Long) {
diff --git a/apps/teacher/flank_tablet.yml b/apps/teacher/flank_tablet.yml
index 61d8a6a4f4..63ecdcc003 100644
--- a/apps/teacher/flank_tablet.yml
+++ b/apps/teacher/flank_tablet.yml
@@ -9,7 +9,7 @@ gcloud:
record-video: true
timeout: 60m
test-targets:
- - notAnnotation com.instructure.canvas.espresso.E2E, com.instructure.canvas.espresso.Stub
+ - notAnnotation com.instructure.canvas.espresso.E2E, com.instructure.canvas.espresso.Stub, com.instructure.canvas.espresso.StubTablet
device:
- model: Nexus9
version: 26
diff --git a/apps/teacher/src/main/java/com/instructure/teacher/features/elementary/importantdates/TeacherImportantDatesRouter.kt b/apps/teacher/src/main/java/com/instructure/teacher/features/elementary/importantdates/TeacherImportantDatesRouter.kt
index 3319e818dc..ca20d982ee 100644
--- a/apps/teacher/src/main/java/com/instructure/teacher/features/elementary/importantdates/TeacherImportantDatesRouter.kt
+++ b/apps/teacher/src/main/java/com/instructure/teacher/features/elementary/importantdates/TeacherImportantDatesRouter.kt
@@ -17,11 +17,12 @@
package com.instructure.teacher.features.elementary.importantdates
import com.instructure.canvasapi2.models.CanvasContext
+import com.instructure.canvasapi2.models.ScheduleItem
import com.instructure.pandautils.features.elementary.importantdates.ImportantDatesRouter
class TeacherImportantDatesRouter : ImportantDatesRouter {
override fun openAssignment(canvasContext: CanvasContext, assignmentId: Long) = Unit
- override fun openCalendarEvent(canvasContext: CanvasContext, scheduleItemId: Long) = Unit
+ override fun openCalendarEvent(canvasContext: CanvasContext, scheduleItem: ScheduleItem) = Unit
}
\ No newline at end of file
diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/StubTabletAnnotation.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/StubTabletAnnotation.kt
new file mode 100644
index 0000000000..af8423273c
--- /dev/null
+++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/StubTabletAnnotation.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2022 - present Instructure, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.instructure.canvas.espresso
+
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.RUNTIME)
+annotation class StubTablet
diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/mockCanvas/MockCanvas.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/mockCanvas/MockCanvas.kt
index e9c03f72b6..2b9621c6ca 100644
--- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/mockCanvas/MockCanvas.kt
+++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/mockCanvas/MockCanvas.kt
@@ -19,6 +19,7 @@
package com.instructure.canvas.espresso.mockCanvas
import android.util.Log
+import com.github.javafaker.Bool
import com.github.javafaker.Faker
import com.instructure.canvas.espresso.mockCanvas.utils.Randomizer
import com.instructure.canvasapi2.models.*
@@ -541,7 +542,7 @@ fun MockCanvas.addUserPermissions(userId: Long, canUpdateName: Boolean, canUpdat
user?.permissions = CanvasContextPermission(canUpdateAvatar = canUpdateAvatar, canUpdateName = canUpdateName)
}
-fun MockCanvas.addCourseCalendarEvent(courseId: Long, date: String, title: String, description: String) : ScheduleItem {
+fun MockCanvas.addCourseCalendarEvent(courseId: Long, date: String, title: String, description: String, isImportantDate: Boolean = false) : ScheduleItem {
val newScheduleItem = ScheduleItem(
itemId = newItemId().toString(),
title = title,
@@ -550,7 +551,32 @@ fun MockCanvas.addCourseCalendarEvent(courseId: Long, date: String, title: Strin
isAllDay = true,
allDayAt = date,
startAt = date,
- contextCode = "course_$courseId"
+ contextCode = "course_$courseId",
+ importantDates = isImportantDate
+ )
+
+ var calendarEventList = courseCalendarEvents[courseId]
+ if(calendarEventList == null) {
+ calendarEventList = mutableListOf()
+ courseCalendarEvents[courseId] = calendarEventList
+ }
+ calendarEventList.add(newScheduleItem)
+
+ return newScheduleItem
+}
+
+fun MockCanvas.addAssignmentCalendarEvent(courseId: Long, date: String, title: String, description: String, isImportantDate: Boolean = false, assignment: Assignment): ScheduleItem {
+ val newScheduleItem = ScheduleItem(
+ itemId = newItemId().toString(),
+ title = title,
+ description = description,
+ itemType = ScheduleItem.Type.TYPE_ASSIGNMENT,
+ isAllDay = true,
+ allDayAt = date,
+ startAt = date,
+ contextCode = "course_$courseId",
+ importantDates = isImportantDate,
+ assignment = assignment
)
var calendarEventList = courseCalendarEvents[courseId]
diff --git a/libs/canvas-api-2/src/main/java/com/instructure/canvasapi2/models/ScheduleItem.kt b/libs/canvas-api-2/src/main/java/com/instructure/canvasapi2/models/ScheduleItem.kt
index 1794f7c33c..c170100f76 100644
--- a/libs/canvas-api-2/src/main/java/com/instructure/canvasapi2/models/ScheduleItem.kt
+++ b/libs/canvas-api-2/src/main/java/com/instructure/canvasapi2/models/ScheduleItem.kt
@@ -55,6 +55,8 @@ data class ScheduleItem(
val isHidden: Boolean = false,
@SerializedName("assignment_overrides")
val assignmentOverrides: List? = arrayListOf(),
+ @SerializedName("important_dates")
+ val importantDates: Boolean = false,
// Not API related - Included here so they get parcelized
var submissionTypes: List = ArrayList(),
diff --git a/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesFragment.kt b/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesFragment.kt
index d051d48ea4..29f96f6ec3 100644
--- a/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesFragment.kt
+++ b/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesFragment.kt
@@ -59,7 +59,7 @@ class ImportantDatesFragment : Fragment() {
is ImportantDatesAction.OpenAssignment -> router.openAssignment(action.canvasContext, action.assignmentId)
is ImportantDatesAction.OpenCalendarEvent -> router.openCalendarEvent(
action.canvasContext,
- action.scheduleItemId
+ action.scheduleItem
)
is ImportantDatesAction.ShowToast -> {
Toast.makeText(requireContext(), action.toast, Toast.LENGTH_SHORT).show()
diff --git a/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesRouter.kt b/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesRouter.kt
index 07d817f95e..edc472689f 100644
--- a/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesRouter.kt
+++ b/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesRouter.kt
@@ -17,10 +17,11 @@
package com.instructure.pandautils.features.elementary.importantdates
import com.instructure.canvasapi2.models.CanvasContext
+import com.instructure.canvasapi2.models.ScheduleItem
interface ImportantDatesRouter {
fun openAssignment(canvasContext: CanvasContext, assignmentId: Long)
- fun openCalendarEvent(canvasContext: CanvasContext, scheduleItemId: Long)
+ fun openCalendarEvent(canvasContext: CanvasContext, scheduleItem: ScheduleItem)
}
\ No newline at end of file
diff --git a/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewData.kt b/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewData.kt
index 48859f6dfb..4064e50901 100644
--- a/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewData.kt
+++ b/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewData.kt
@@ -19,6 +19,7 @@ package com.instructure.pandautils.features.elementary.importantdates
import androidx.annotation.DrawableRes
import com.instructure.canvasapi2.models.CanvasContext
import com.instructure.canvasapi2.models.Course
+import com.instructure.canvasapi2.models.ScheduleItem
import com.instructure.pandautils.features.elementary.importantdates.itemviewmodels.ImportantDatesHeaderItemViewModel
import com.instructure.pandautils.mvvm.ItemViewModel
import java.util.*
@@ -39,7 +40,7 @@ data class ImportantDatesItemViewData(
sealed class ImportantDatesAction {
data class OpenAssignment(val canvasContext: CanvasContext, val assignmentId: Long) : ImportantDatesAction()
- data class OpenCalendarEvent(val canvasContext: CanvasContext, val scheduleItemId: Long) : ImportantDatesAction()
+ data class OpenCalendarEvent(val canvasContext: CanvasContext, val scheduleItem: ScheduleItem) : ImportantDatesAction()
data class ShowToast(val toast: String) : ImportantDatesAction()
}
diff --git a/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewModel.kt b/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewModel.kt
index 2c34770f78..590b68e557 100644
--- a/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewModel.kt
+++ b/libs/pandautils/src/main/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewModel.kt
@@ -177,7 +177,7 @@ class ImportantDatesViewModel @Inject constructor(
val canvasContext = CanvasContext.fromContextCode(course?.contextId)
if (scheduleItem != null && canvasContext != null) {
if (scheduleItem.assignment == null) {
- _events.postValue(Event(ImportantDatesAction.OpenCalendarEvent(canvasContext, scheduleItemId)))
+ _events.postValue(Event(ImportantDatesAction.OpenCalendarEvent(canvasContext, scheduleItem)))
} else {
_events.postValue(Event(ImportantDatesAction.OpenAssignment(canvasContext, scheduleItem.assignment!!.id)))
}
diff --git a/libs/pandautils/src/main/res/layout-sw720dp/fragment_important_dates.xml b/libs/pandautils/src/main/res/layout-sw720dp/fragment_important_dates.xml
index 9c6eb4ca26..f31aa372e1 100644
--- a/libs/pandautils/src/main/res/layout-sw720dp/fragment_important_dates.xml
+++ b/libs/pandautils/src/main/res/layout-sw720dp/fragment_important_dates.xml
@@ -24,6 +24,7 @@
@@ -55,6 +56,7 @@
android:textStyle="bold" />
diff --git a/libs/pandautils/src/main/res/layout/fragment_important_dates.xml b/libs/pandautils/src/main/res/layout/fragment_important_dates.xml
index 13d5baaa28..c7e819b117 100644
--- a/libs/pandautils/src/main/res/layout/fragment_important_dates.xml
+++ b/libs/pandautils/src/main/res/layout/fragment_important_dates.xml
@@ -24,6 +24,7 @@
@@ -35,6 +36,7 @@
app:refreshState="@{viewModel.state}">
diff --git a/libs/pandautils/src/test/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewModelTest.kt b/libs/pandautils/src/test/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewModelTest.kt
index 9c3e939cd8..29a2791ff4 100644
--- a/libs/pandautils/src/test/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewModelTest.kt
+++ b/libs/pandautils/src/test/java/com/instructure/pandautils/features/elementary/importantdates/ImportantDatesViewModelTest.kt
@@ -263,7 +263,7 @@ class ImportantDatesViewModelTest {
viewModel.data.value?.itemViewModels!![0].itemViewModels[0].open()
val canvasContext = CanvasContext.fromContextCode("course_1")
- val expectedData = ImportantDatesAction.OpenCalendarEvent(canvasContext!!, 1)
+ val expectedData = ImportantDatesAction.OpenCalendarEvent(canvasContext!!, events[0])
assertEquals(expectedData, viewModel.events.value?.getContentIfNotHandled())
}