Skip to content

Commit

Permalink
[MBL-14902][Teacher] Created E2E test for People (#1131)
Browse files Browse the repository at this point in the history
* Created E2E test for People

refs: MBL-14902
affects: Teacher
release note: Extended test matrix

test plan:

* refs: MBL-14902
affects: Teacher
release note: Extended test matrix

test plan:
  • Loading branch information
davidvarga93 authored Dec 11, 2020
1 parent 7bed43f commit f217e07
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (C) 2020 - present Instructure, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.instructure.teacher.ui.e2e

import com.instructure.canvas.espresso.E2E
import com.instructure.dataseeding.api.SubmissionsApi
import com.instructure.dataseeding.model.SubmissionType
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.dataseeding.util.days
import com.instructure.dataseeding.util.fromNow
import com.instructure.dataseeding.util.iso8601
import com.instructure.teacher.ui.utils.*
import org.junit.Test

class PeopleE2ETest: TeacherTest() {
override fun displaysPageObjects() = Unit

override fun enableAndConfigureAccessibilityChecks() {
//We dont want to see accessibility errors on E2E tests
}

@E2E
@Test
@TestMetaData(Priority.P0, FeatureCategory.PEOPLE, TestCategory.E2E)
fun testPeopleE2E() {

val data = seedData(teachers = 1, students = 2, courses = 1)
val teacher = data.teachersList[0]
val notGradedStudent = data.studentsList[0]
val gradedStudent = data.studentsList[1]
val course = data.coursesList[0]

val assignments = seedAssignments(
courseId = course.id,
dueAt = 1.days.fromNow.iso8601,
submissionTypes = listOf(SubmissionType.ONLINE_TEXT_ENTRY),
teacherToken = teacher.token,
pointsPossible = 10.0
)

seedAssignmentSubmission(
submissionSeeds = listOf(SubmissionsApi.SubmissionSeedInfo(
amount = 1,
submissionType = SubmissionType.ONLINE_TEXT_ENTRY
)),
assignmentId = assignments[0].id,
courseId = course.id,
studentToken = gradedStudent.token
)

SubmissionsApi.gradeSubmission(
teacherToken = teacher.token,
courseId = course.id,
assignmentId = assignments[0].id,
studentId = gradedStudent.id,
postedGrade = "10",
excused = false
)


tokenLogin(teacher)

dashboardPage.openCourse(course.name)
courseBrowserPage.openPeopleTab()
peopleListPage.clickPerson(teacher)
studentContextPage.assertDisplaysCourseInfo(course)
studentContextPage.navigateBack()

peopleListPage.clickPerson(notGradedStudent)
studentContextPage.assertDisplaysStudentInfo(notGradedStudent)
studentContextPage.assertDisplaysCourseInfo(course)
studentContextPage.assertStudentGrade("--")
studentContextPage.assertStudentSubmission("--")
studentContextPage.navigateBack()

peopleListPage.clickPerson(gradedStudent)
studentContextPage.assertDisplaysStudentInfo(gradedStudent)
studentContextPage.assertDisplaysCourseInfo(course)
studentContextPage.assertStudentGrade("100.0")
studentContextPage.assertStudentSubmission("1")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DashboardPage : BasePage() {

fun assertOpensCourse(course: CourseApiModel) {
assertDisplaysCourse(course)
onView(withText(course.name)).click()
openCourse(courseName = course.name)
onView(withId(R.id.courseBrowserTitle)).assertContainsText(course.name)
navigateBack(R.id.overlayToolbar)
}
Expand All @@ -79,6 +79,10 @@ class DashboardPage : BasePage() {

}

fun openCourse(courseName: String) {
onView(withText(courseName)).click()
}

private fun scrollAndAssertDisplayed(matcher: Matcher<View>) {
onView(matcher).assertDisplayed()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

package com.instructure.teacher.ui.pages

import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import com.instructure.dataseeding.model.CanvasUserApiModel
import com.instructure.dataseeding.model.CourseApiModel
import com.instructure.espresso.WaitForViewWithId
import com.instructure.espresso.assertDisplayed
import com.instructure.espresso.assertHasText
import com.instructure.espresso.click
import com.instructure.espresso.page.*
import com.instructure.teacher.R

Expand All @@ -47,4 +49,15 @@ class StudentContextPage : BasePage(R.id.studentContextPage) {
courseName.assertHasText(course.name)
}

fun assertStudentGrade(grade: String) {
onView(withId(R.id.gradeBeforePosting)).assertHasText(grade)
}

fun assertStudentSubmission(submittedCount: String) {
onView(withId(R.id.submittedCount)).assertHasText(submittedCount)
}

fun navigateBack() {
onView(withParent(R.id.toolbar) + withContentDescription("Navigate up")).click()
}
}

0 comments on commit f217e07

Please sign in to comment.