Skip to content

Commit

Permalink
[MBL-16500][Student][Teacher] - Refactor MockCanvas addAssignment met…
Browse files Browse the repository at this point in the history
…hod to handle multiple submission types (as a list) (#2311)
  • Loading branch information
kdeakinstructure authored Jan 25, 2024
1 parent 7e4822e commit b48e6a3
Show file tree
Hide file tree
Showing 33 changed files with 276 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.instructure.canvas.espresso.mockCanvas.init
import com.instructure.canvasapi2.models.Assignment
import com.instructure.canvasapi2.models.CourseSettings
import com.instructure.canvasapi2.utils.toApiString
import com.instructure.dataseeding.model.SubmissionType
import com.instructure.student.ui.utils.StudentTest
import com.instructure.student.ui.utils.routeTo
import com.instructure.student.ui.utils.tokenLogin
Expand All @@ -53,7 +54,7 @@ class AssignmentDetailsInteractionTest : StudentTest() {
val course = data.courses.values.first()
val student = data.students[0]
val token = data.tokenFor(student)!!
val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_URL)
val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_URL))
data.addSubmissionForAssignment(
assignmentId = assignment.id,
userId = data.users.values.first().id,
Expand Down Expand Up @@ -118,7 +119,7 @@ class AssignmentDetailsInteractionTest : StudentTest() {

@Test
@TestMetaData(Priority.COMMON, FeatureCategory.ASSIGNMENTS, TestCategory.INTERACTION)
fun testDisplayBookmarMenu() {
fun testDisplayBookmarkMenu() {
val data = setUpData()
goToAssignmentList()
val assignmentList = data.assignments
Expand Down Expand Up @@ -349,6 +350,41 @@ class AssignmentDetailsInteractionTest : StudentTest() {
assignmentDetailsPage.assertScoreNotDisplayed()
}

@Test
@TestMetaData(Priority.IMPORTANT, FeatureCategory.SUBMISSIONS, TestCategory.INTERACTION, SecondaryFeatureCategory.SUBMISSIONS_MULTIPLE_TYPE)
fun testSubmission_multipleSubmissionType() {
val data = MockCanvas.init(
studentCount = 1,
courseCount = 1
)

val course = data.courses.values.first()
val student = data.students[0]
val token = data.tokenFor(student)!!
val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY, Assignment.SubmissionType.ONLINE_UPLOAD, Assignment.SubmissionType.MEDIA_RECORDING, Assignment.SubmissionType.DISCUSSION_TOPIC, Assignment.SubmissionType.ONLINE_URL))
data.addSubmissionForAssignment(
assignmentId = assignment.id,
userId = data.users.values.first().id,
type = Assignment.SubmissionType.ONLINE_URL.apiString
)
tokenLogin(data.domain, token, student)
routeTo("courses/${course.id}/assignments", data.domain)
assignmentListPage.waitForPage()

assignmentListPage.clickAssignment(assignment)
assignmentDetailsPage.clickSubmit()

assignmentDetailsPage.assertSubmissionTypeDisplayed("Text Entry")
assignmentDetailsPage.assertSubmissionTypeDisplayed("Website URL")
assignmentDetailsPage.assertSubmissionTypeDisplayed("File Upload")
assignmentDetailsPage.assertSubmissionTypeDisplayed("Media Recording")

//Try 1 submission to check if it's possible to submit even when there are multiple submission types available.
assignmentDetailsPage.selectSubmissionType(SubmissionType.ONLINE_URL)
urlSubmissionUploadPage.submitText("https://google.com")
assignmentDetailsPage.assertStatusSubmitted()
}

private fun setUpData(restrictQuantitativeData: Boolean = false): MockCanvas {
// Test clicking on the Submission and Rubric button to load the Submission Details Page
val data = MockCanvas.init(
Expand Down Expand Up @@ -401,7 +437,7 @@ class AssignmentDetailsInteractionTest : StudentTest() {

val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
gradingType = Assignment.gradingTypeToAPIString(gradingType) ?: "",
pointsPossible = maxScore,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class AssignmentListInteractionTest : StudentTest() {
repeat(assignmentCount) {
val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
)
assignmentList.add(assignment)
}
Expand Down Expand Up @@ -254,7 +254,7 @@ class AssignmentListInteractionTest : StudentTest() {

val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
gradingType = Assignment.gradingTypeToAPIString(gradingType) ?: "",
pointsPossible = maxScore,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class BookmarkInteractionTest : StudentTest() {
val course = data.courses.values.first()
val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
)

val token = data.tokenFor(student)!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class CourseGradesInteractionTest : StudentTest() {

val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
gradingType = Assignment.gradingTypeToAPIString(gradingType) ?: "",
pointsPossible = maxScore,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ class DiscussionsInteractionTest : StudentTest() {
// Add an assignment
val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
name = assignmentName,
pointsPossible = 12
)
Expand Down Expand Up @@ -649,7 +649,7 @@ class DiscussionsInteractionTest : StudentTest() {
// Add an assignment
val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
name = assignmentName,
pointsPossible = 12
)
Expand Down Expand Up @@ -694,7 +694,7 @@ class DiscussionsInteractionTest : StudentTest() {
// Add an assignment
val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
name = assignmentName,
pointsPossible = 12
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ class HomeroomInteractionTest : StudentTest() {

val courses = data.courses.values.filter { !it.homeroomCourse }

data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY))
data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY))

goToHomeroomTab(data)

Expand All @@ -259,8 +259,8 @@ class HomeroomInteractionTest : StudentTest() {

val courses = data.courses.values.filter { !it.homeroomCourse }

val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY))
data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY))

goToHomeroomTab(data)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ImportantDatesInteractionTest : StudentTest() {
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)
val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY))
val assignmentScheduleItem = data.addAssignmentCalendarEvent(course.id, 2.days.fromNow.iso8601, assignment.name!!, assignment.description!!, true, assignment)

goToImportantDatesTab(data)
Expand Down Expand Up @@ -132,7 +132,7 @@ class ImportantDatesInteractionTest : StudentTest() {
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)
val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY))
val assignmentScheduleItem = data.addAssignmentCalendarEvent(course.id, 2.days.fromNow.iso8601, assignment.name!!, assignment.description!!, true, assignment)

goToImportantDatesTab(data)
Expand All @@ -152,7 +152,7 @@ class ImportantDatesInteractionTest : StudentTest() {
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)
val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY))
data.addAssignmentCalendarEvent(course.id, 2.days.fromNow.iso8601, assignment.name!!, assignment.description!!, true, assignment)
val calendarEvent = data.addCourseCalendarEvent(course.id, 2.days.fromNow.iso8601, "Important event", "Important event description", true)

Expand All @@ -176,7 +176,7 @@ class ImportantDatesInteractionTest : StudentTest() {
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)
val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY))
val twoDaysFromNowEvent = data.addAssignmentCalendarEvent(course.id,
2.days.fromNow.iso8601, "Important event two days later", "Important event two days later description", true, assignment)
val threeDaysFromNowEvent = data.addCourseCalendarEvent(course.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ModuleInteractionTest : StudentTest() {
// Create an assignment and add it as a module item
assignment = data.addAssignment(
courseId = course1.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
)
data.addItemToModule(
course = course1,
Expand Down Expand Up @@ -324,7 +324,7 @@ class ModuleInteractionTest : StudentTest() {
// Create an assignment and add it as a module item
assignment = data.addAssignment(
courseId = course1.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
)
data.addItemToModule(
course = course1,
Expand Down Expand Up @@ -385,7 +385,7 @@ class ModuleInteractionTest : StudentTest() {
// Create an assignment and add it as a module item
assignment = data.addAssignment(
courseId = course1.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
)
data.addItemToModule(
course = course1,
Expand Down Expand Up @@ -501,7 +501,7 @@ class ModuleInteractionTest : StudentTest() {
// And let's add an assignment to the new module
var unavailableAssignment = data.addAssignment(
courseId = course1.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
// Man, this is a bit hokey, but it's what I had to do to get the assignment to show
// up as unavailable in the assignment details page
lockInfo = LockInfo(
Expand Down Expand Up @@ -541,7 +541,7 @@ class ModuleInteractionTest : StudentTest() {
// And let's create an assignment and add it to the "locked" module.
val lockedAssignment = data.addAssignment(
courseId = course1.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
)
data.addItemToModule(
course = course1,
Expand All @@ -568,7 +568,7 @@ class ModuleInteractionTest : StudentTest() {

val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
pointsPossible = 10
)

Expand All @@ -595,7 +595,7 @@ class ModuleInteractionTest : StudentTest() {

val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
pointsPossible = 10
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class NotificationInteractionTest : StudentTest() {
repeat(numSubmissions) {
val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY),
gradingType = Assignment.gradingTypeToAPIString(gradingType).orEmpty(),
pointsPossible = 20
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class PdfInteractionTest : StudentTest() {
val pdfUrlElementId = "testLinkElement"
val assignmentDescriptionHtml = """<a id="$pdfUrlElementId" href="$url">pdf baby!!!</a>"""

val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_UPLOAD, description = assignmentDescriptionHtml)
val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD), description = assignmentDescriptionHtml)

assignmentListPage.waitForPage()
assignmentListPage.refresh()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class PickerSubmissionUploadInteractionTest : StudentTest() {
// Let's set up an assignment that requires an online upload
val assignment = data.addAssignment(
courseId = course.id,
submissionType = Assignment.SubmissionType.ONLINE_UPLOAD
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD)
)

// Sign in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ScheduleInteractionTest : StudentTest() {
courses[0].name = "Course 1"

val currentDate = dateTimeProvider.getCalendar().time.toApiString()
val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate, name = "Assignment 1")
val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate, name = "Assignment 1")

goToScheduleTab(data)
schedulePage.scrollToPosition(10)
Expand All @@ -101,7 +101,7 @@ class ScheduleInteractionTest : StudentTest() {
val courses = data.courses.values.filter { !it.homeroomCourse }

val currentDate = dateTimeProvider.getCalendar().time.toApiString()
val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate)
val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate)

goToScheduleTab(data)
schedulePage.scrollToPosition(12)
Expand Down Expand Up @@ -140,8 +140,8 @@ class ScheduleInteractionTest : StudentTest() {
schedulePage.assertNoScheduleItemDisplayed()

val currentDate = dateTimeProvider.getCalendar().time.toApiString()
val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate)
val assignment2 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate)
val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate)
val assignment2 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate)

schedulePage.scrollToPosition(0)
schedulePage.refresh()
Expand Down Expand Up @@ -209,7 +209,7 @@ class ScheduleInteractionTest : StudentTest() {
courses[0].name = "Course 1"

val currentDate = dateTimeProvider.getCalendar().time.toApiString()
val assignment = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate, name = "Assignment 1")
val assignment = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate, name = "Assignment 1")

goToScheduleTab(data)
schedulePage.scrollToPosition(9)
Expand All @@ -228,7 +228,7 @@ class ScheduleInteractionTest : StudentTest() {
val courses = data.courses.values.filter { !it.homeroomCourse }

val currentDate = dateTimeProvider.getCalendar().time.toApiString()
data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate)
data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate)

goToScheduleTab(data)
schedulePage.scrollToPosition(8)
Expand Down Expand Up @@ -265,7 +265,7 @@ class ScheduleInteractionTest : StudentTest() {
courses[0].name = "Course 1"

val currentDate = dateTimeProvider.getCalendar().time.toApiString()
val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate, name = "Assignment 1")
val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate, name = "Assignment 1")

goToScheduleTab(data)

Expand Down
Loading

0 comments on commit b48e6a3

Please sign in to comment.