Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.instructure.canvas.espresso.FeatureCategory
import com.instructure.canvas.espresso.Priority
import com.instructure.canvas.espresso.TestCategory
import com.instructure.canvas.espresso.TestMetaData
import com.instructure.canvas.espresso.annotations.Stub
import com.instructure.canvas.espresso.mockcanvas.MockCanvas
import com.instructure.canvas.espresso.mockcanvas.addAssignment
import com.instructure.canvas.espresso.mockcanvas.addFileToCourse
Expand Down Expand Up @@ -246,18 +245,86 @@ class SubmissionDetailsInteractionTest : StudentComposeTest() {
)
}

@Stub
@Test
@TestMetaData(Priority.COMMON, FeatureCategory.SUBMISSIONS, TestCategory.INTERACTION)
fun testComments_videoCommentPlayback() {
// After recording a video comment, user should be able to view a replay
fun testComments_videoCommentDisplayed() {
val data = getToCourse()
val user = data.users.values.first()
val assignment = data.addAssignment(
courseId = course.id,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
)

val videoAttachment = createVideoAttachment(data, "video_comment.mp4")

val commentText = "Here's a video comment"

val submissionComment = SubmissionComment(
id = data.newItemId(),
authorId = user.id,
authorName = user.name,
comment = commentText,
createdAt = Date(),
attachments = arrayListOf(videoAttachment),
author = Author(id = user.id, displayName = user.shortName),
attempt = 1
)

data.addSubmissionForAssignment(
assignmentId = assignment.id,
userId = user.id,
type = Assignment.SubmissionType.ONLINE_TEXT_ENTRY.apiString,
body = "Some Text!",
comment = submissionComment
)

courseBrowserPage.selectAssignments()
assignmentListPage.clickAssignment(assignment)
assignmentDetailsPage.goToSubmissionDetails()
submissionDetailsPage.openComments()
submissionDetailsPage.assertCommentDisplayed(commentText, user)
submissionDetailsPage.assertVideoCommentDisplayed()
}

@Stub
@Test
@TestMetaData(Priority.COMMON, FeatureCategory.SUBMISSIONS, TestCategory.INTERACTION)
fun testComments_audioCommentPlayback() {
// After recording an audio comment, user should be able to hear an audio playback
fun testComments_audioCommentDisplayed() {
val data = getToCourse()
val user = data.users.values.first()
val assignment = data.addAssignment(
courseId = course.id,
submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)
)

val audioAttachment = createAudioAttachment(data, "audio_comment.mp3")

val commentText = "Here's an audio comment"

val submissionComment = SubmissionComment(
id = data.newItemId(),
authorId = user.id,
authorName = user.name,
comment = commentText,
createdAt = Date(),
attachments = arrayListOf(audioAttachment),
author = Author(id = user.id, displayName = user.shortName),
attempt = 1
)

data.addSubmissionForAssignment(
assignmentId = assignment.id,
userId = user.id,
type = Assignment.SubmissionType.ONLINE_TEXT_ENTRY.apiString,
body = "Some Text!",
comment = submissionComment
)

courseBrowserPage.selectAssignments()
assignmentListPage.clickAssignment(assignment)
assignmentDetailsPage.goToSubmissionDetails()
submissionDetailsPage.openComments()
submissionDetailsPage.assertCommentDisplayed(commentText, user)
submissionDetailsPage.assertAudioCommentDisplayed()
}


Expand Down Expand Up @@ -286,6 +353,54 @@ class SubmissionDetailsInteractionTest : StudentComposeTest() {
return attachment
}

private fun createAudioAttachment(data: MockCanvas, name: String): Attachment {
val course1 = data.courses.values.first()
val fileId = data.addFileToCourse(
courseId = course1.id,
displayName = name,
contentType = "audio/mp3",
fileContent = "fake audio content"
)

val mockUrl = "https://mock-data.instructure.com/files/$fileId/preview"
val attachment = Attachment(
id = data.newItemId(),
contentType = "audio/mp3",
displayName = name,
filename = name,
url = mockUrl,
previewUrl = mockUrl,
createdAt = Date(),
size = 1024L
)

return attachment
}

private fun createVideoAttachment(data: MockCanvas, name: String): Attachment {
val course1 = data.courses.values.first()
val fileId = data.addFileToCourse(
courseId = course1.id,
displayName = name,
contentType = "video/mp4",
fileContent = "fake video content"
)

val mockUrl = "https://mock-data.instructure.com/files/$fileId/preview"
val attachment = Attachment(
id = data.newItemId(),
contentType = "video/mp4",
displayName = name,
filename = name,
url = mockUrl,
previewUrl = mockUrl,
createdAt = Date(),
size = 2048L
)

return attachment
}

// Mock a specified number of students and courses, sign in, then navigate to course browser page for
// first course.
private fun getToCourse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class CommentLibraryE2ETest : TeacherComposeTest() {

val testText = "another"
Log.d(STEP_TAG, "Type '$testText' word.")
speedGraderPage.typeComment(testText)
speedGraderPage.typeCommentInCommentLibraryInputField(testText)

Log.d(ASSERTION_TAG, "Assert that there is only 1 comment displayed in the comment library, which matches the filter.")
speedGraderPage.assertCommentLibraryItemCount(1)
Expand All @@ -126,7 +126,7 @@ class CommentLibraryE2ETest : TeacherComposeTest() {

val nonExistingCommentText = "csakafradi"
Log.d(STEP_TAG, "Type a non-existing comment text, '$nonExistingCommentText' into the comment input field.")
speedGraderPage.typeComment(nonExistingCommentText)
speedGraderPage.typeCommentInCommentLibraryInputField(nonExistingCommentText)

Log.d(ASSERTION_TAG, "Assert that there is no comment displayed in the comment library as there's no matching comment with the entered (filter) text.")
speedGraderPage.assertCommentLibraryItemCount(0)
Expand All @@ -148,7 +148,7 @@ class CommentLibraryE2ETest : TeacherComposeTest() {

val testText2 = "test"
Log.d(STEP_TAG, "Type '$testText2' word.")
speedGraderPage.typeComment(testText2)
speedGraderPage.typeCommentInCommentLibraryInputField(testText2)

Log.d(ASSERTION_TAG, "Assert that there are 2 comments displayed in the comment library, which matches the filter.")
speedGraderPage.assertCommentLibraryItemCount(2)
Expand All @@ -162,9 +162,9 @@ class CommentLibraryE2ETest : TeacherComposeTest() {
Log.d(ASSERTION_TAG, "Assert that the 'Comments' label is displayed with the corresponding number of comments, which is 2 at the moment.")
speedGraderPage.assertCommentsLabelDisplayed(2)

Log.d(ASSERTION_TAG, "Assert assert both the '$testComment' and '$testComment2' (whole) comments are displayed in the comments section.")
speedGraderPage.assertCommentDisplayed(testComment)
speedGraderPage.assertCommentDisplayed(testComment2)
Log.d(ASSERTION_TAG, "Assert that both the '$testComment' and '$testComment2' (whole) comments are displayed in the comments section.")
speedGraderPage.assertCommentDisplayed(testComment, author = null)
speedGraderPage.assertCommentDisplayed(testComment2, author = null)
}

private fun prepareSettingsAndMakeAssignmentWithSubmission(
Expand Down
Loading
Loading