@@ -18,14 +18,11 @@ package com.instructure.student.ui.e2e.classic
1818
1919import android.util.Log
2020import androidx.test.espresso.Espresso
21- import androidx.test.espresso.matcher.ViewMatchers.withText
2221import com.instructure.canvas.espresso.FeatureCategory
2322import com.instructure.canvas.espresso.Priority
2423import com.instructure.canvas.espresso.TestCategory
2524import com.instructure.canvas.espresso.TestMetaData
2625import com.instructure.canvas.espresso.annotations.E2E
27- import com.instructure.canvas.espresso.annotations.Stub
28- import com.instructure.canvas.espresso.containsTextCaseInsensitive
2926import com.instructure.dataseeding.api.AssignmentsApi
3027import com.instructure.dataseeding.api.QuizzesApi
3128import com.instructure.dataseeding.api.SubmissionsApi
@@ -36,8 +33,8 @@ import com.instructure.dataseeding.model.SubmissionType
3633import com.instructure.dataseeding.util.days
3734import com.instructure.dataseeding.util.fromNow
3835import com.instructure.dataseeding.util.iso8601
39- import com.instructure.espresso.getDateInCanvasCalendarFormat
40- import com.instructure.student.R
36+ import com.instructure.espresso.convertIso8601ToCanvasFormat
37+ import com.instructure.espresso.retryWithIncreasingDelay
4138import com.instructure.student.ui.utils.StudentComposeTest
4239import com.instructure.student.ui.utils.extensions.seedData
4340import com.instructure.student.ui.utils.extensions.tokenLogin
@@ -51,7 +48,6 @@ class GradesE2ETest: StudentComposeTest() {
5148
5249 override fun enableAndConfigureAccessibilityChecks () = Unit
5350
54- @Stub(" Grades screen has been redesigned, needs to be fixed in ticket MBL-19640" )
5551 @E2E
5652 @Test
5753 @TestMetaData(Priority .MANDATORY , FeatureCategory .GRADES , TestCategory .E2E )
@@ -83,114 +79,125 @@ class GradesE2ETest: StudentComposeTest() {
8379 Log .d(STEP_TAG , " Navigate to Grades Page." )
8480 courseBrowserPage.selectGrades()
8581
86- Log .d(ASSERTION_TAG , " Assert that there is no grade for any submission yet ." )
87- courseGradesPage.assertTotalGrade(withText( R .string.noGradeText) )
82+ Log .d(ASSERTION_TAG , " Assert that the toolbar title is 'Grades' and the subtitle is ' ${course.name} ' course name ." )
83+ gradesPage.assertToolbarTitles(course.name )
8884
89- Log .d(ASSERTION_TAG , " Assert that 'Base on graded assignment' checkbox is checked and the 'Show What-If Score' checkbox is NOT checked by default." )
90- courseGradesPage.assertBaseOnGradedAssignmentsChecked()
91- courseGradesPage.assertWhatIfUnChecked()
85+ Log .d(ASSERTION_TAG , " Assert that the 'Total' grade text is 'N/A' as there is no grade for any assignments yet." )
86+ gradesPage.assertTotalGradeText(" N/A" )
9287
93- val assignmentMatcher = withText(assignment.name)
94- val quizMatcher = withText(quiz.title)
95- Log .d(ASSERTION_TAG , " Refresh the page. Assert that the '${assignment.name} ' assignment and '${quiz.title} ' quiz are displayed and there is no grade for them." )
96- courseGradesPage.refresh()
97- courseGradesPage.assertItemDisplayed(assignmentMatcher)
98- courseGradesPage.assertGradeNotDisplayed(assignmentMatcher)
99- courseGradesPage.assertItemDisplayed(quizMatcher)
100- courseGradesPage.assertGradeNotDisplayed(quizMatcher)
88+ Log .d(ASSERTION_TAG , " Assert that 'Based on graded assignment' checkbox is checked and the 'Show What-If Score' checkbox is NOT checked by default." )
89+ gradesPage.assertBasedOnGradedAssignmentsLabel()
90+ gradesPage.assertBasedOnGradedAssignmentsToggleState(true )
91+ gradesPage.assertShowWhatIfScoreIsDisplayed()
92+ gradesPage.assertShowWhatIfScoreToggleState(false )
10193
102- var dueDateInCanvasFormat = getDateInCanvasCalendarFormat(1 .days.fromNow.iso8601)
103- dueDateInCanvasFormat = dueDateInCanvasFormat.replace(" 0" , " " )
104- Log .d(ASSERTION_TAG , " Assert that the '${assignment.name} ' assignment's due date is tomorrow ('$dueDateInCanvasFormat ')." )
105- courseGradesPage.assertAssignmentDueDate(assignment.name, dueDateInCanvasFormat)
94+ Log .d(ASSERTION_TAG , " Assert that the '${assignment.name} ', '${assignment2.name} ' assignments and '${quiz.title} ' quiz are displayed and there is no grade for them." )
95+ gradesPage.assertAssignmentIsDisplayed(assignment.name)
96+ gradesPage.assertAssignmentGradeText(assignment.name," -/15" )
97+ gradesPage.assertAssignmentIsDisplayed(assignment2.name)
98+ gradesPage.assertAssignmentGradeText(assignment2.name," -/15" )
99+ gradesPage.assertAssignmentIsDisplayed(quiz.title)
100+ gradesPage.assertAssignmentGradeText(quiz.title," -/10" )
106101
107- Log .d(ASSERTION_TAG , " Assert that the '${assignment2.name} ' assignment's due date is tomorrow ('$dueDateInCanvasFormat ')." )
108- courseGradesPage.assertAssignmentDueDate(assignment2.name, dueDateInCanvasFormat)
102+ var dueDateInCanvasFormat = convertIso8601ToCanvasFormat(assignment.dueAt.orEmpty())
103+ Log .d(ASSERTION_TAG , " Assert that the '${assignment.name} ' and '${assignment2.name} ' assignments' due date is tomorrow ('$dueDateInCanvasFormat ')." )
104+ gradesPage.assertAssignmentDueDate(assignment.name, " Due $dueDateInCanvasFormat " )
105+ gradesPage.assertAssignmentDueDate(assignment2.name, " Due $dueDateInCanvasFormat " )
109106
110107 Log .d(ASSERTION_TAG , " Assert that the '${quiz.title} ' quiz's due date has not set." )
111- courseGradesPage .assertAssignmentDueDate(quiz.title, " No due date" )
108+ gradesPage .assertAssignmentDueDate(quiz.title, " No due date" )
112109
113110 Log .d(ASSERTION_TAG , " Assert that all the 3 assignment's state is 'Not Submitted' yet." )
114- courseGradesPage .assertAssignmentStatus(assignment.name, " Not Submitted" )
115- courseGradesPage .assertAssignmentStatus(assignment2.name, " Not Submitted" )
116- courseGradesPage .assertAssignmentStatus(quiz.title, " Not Submitted" )
111+ gradesPage .assertAssignmentStatus(assignment.name, " Not Submitted" )
112+ gradesPage .assertAssignmentStatus(assignment2.name, " Not Submitted" )
113+ gradesPage .assertAssignmentStatus(quiz.title, " Not Submitted" )
117114
118115 Log .d(STEP_TAG , " Check in the 'What-If Score' checkbox." )
119- courseGradesPage.checkWhatIf ()
116+ gradesPage.clickShowWhatIfScore ()
120117
121118 Log .d(ASSERTION_TAG , " Assert that the 'Show What-If Score' checkbox is checked." )
122- courseGradesPage.assertWhatIfChecked( )
119+ gradesPage.assertShowWhatIfScoreToggleState( true )
123120
124121 Log .d(STEP_TAG , " Enter '12' as a what-if grade for '${assignment.name} ' assignment." )
125- courseGradesPage.enterWhatIfGrade(assignmentMatcher, " 12" )
122+ gradesPage.clickEditWhatIfScore(assignment.name)
123+ gradesPage.enterWhatIfScore(" 12" )
124+ gradesPage.clickDoneInWhatIfDialog()
125+
126+ Log .d(ASSERTION_TAG , " Assert that the what-if grade for '${assignment.name} ' assignment is 'What-if: 12/15'." )
127+ gradesPage.assertWhatIfGradeText(assignment.name.orEmpty(), " What-if: 12/15" )
126128
127129 Log .d(ASSERTION_TAG , " Assert that 'Total Grade' contains the score '80%'." )
128- courseGradesPage.assertTotalGrade(containsTextCaseInsensitive( " 80" ) )
130+ gradesPage.assertTotalGradeText( " 80% " )
129131
130132 Log .d(STEP_TAG , " Check out the 'What-If Score' checkbox." )
131- courseGradesPage.uncheckWhatIf ()
133+ gradesPage.clickShowWhatIfScore ()
132134
133135 Log .d(ASSERTION_TAG , " Assert that the 'Show What-If Score' checkbox is unchecked." )
134- courseGradesPage.assertWhatIfUnChecked( )
136+ gradesPage.assertShowWhatIfScoreToggleState( false )
135137
136- Log .d(ASSERTION_TAG , " Assert that after disabling the 'What-If Score' checkbox there will be no 'real' grade." )
137- courseGradesPage.assertTotalGrade(withText( R .string.noGradeText) )
138+ Log .d(ASSERTION_TAG , " Assert that the 'Total' grade text is 'N/A' as there is no grade for any assignments yet ." )
139+ gradesPage.assertTotalGradeText( " N/A " )
138140
139141 Log .d(PREPARATION_TAG , " Seed a submission for '${assignment.name} ' assignment." )
140142 SubmissionsApi .submitCourseAssignment(course.id, student.token, assignment.id, SubmissionType .ONLINE_TEXT_ENTRY )
141143
142144 Log .d(PREPARATION_TAG , " Grade the previously seeded submission for '${assignment.name} ' assignment." )
143145 SubmissionsApi .gradeSubmission(teacher.token, course.id, assignment.id, student.id, postedGrade = " 9" )
144146
145- Log .d(ASSERTION_TAG , " Refresh the page. Assert that the assignment's score is '60%'." )
146- courseGradesPage.refresh()
147- courseGradesPage.assertGradeDisplayed(
148- assignmentMatcher,
149- containsTextCaseInsensitive(" 60" ))
147+ Log .d(ASSERTION_TAG , " Refresh the page. Assert that the assignment's score is '60%' and so the 'Total' grade." )
148+ gradesPage.refresh()
149+ retryWithIncreasingDelay(times = 15 , maxDelay = 3000 , catchBlock = { gradesPage.refresh() }) {
150+ gradesPage.assertAssignmentGradeText(assignment.name, " 60%" )
151+ gradesPage.assertTotalGradeText(" 60%" )
152+ }
150153
151- Log .d(STEP_TAG , " Uncheck 'Base on graded assignments' button." )
152- courseGradesPage.uncheckBaseOnGradedAssignments ()
154+ Log .d(STEP_TAG , " Check out 'Base on graded assignments' button." )
155+ gradesPage.clickBasedOnGradedAssignments ()
153156
154157 Log .d(ASSERTION_TAG , " Assert that we can see the correct score (22.5%) and the 'Base on graded assignments' checkbox is unchecked." )
155- courseGradesPage.assertBaseOnGradedAssignmentsUnChecked( )
156- courseGradesPage.refreshUntilAssertTotalGrade(containsTextCaseInsensitive( " 22.5%" ) )
158+ gradesPage.assertBasedOnGradedAssignmentsToggleState( false )
159+ gradesPage.assertTotalGradeText( " 22.5%" )
157160
158- Log .d(STEP_TAG , " Check 'Base on graded assignments' button." )
159- courseGradesPage.checkBaseOnGradedAssignments ()
161+ Log .d(STEP_TAG , " Check in 'Base on graded assignments' button." )
162+ gradesPage.clickBasedOnGradedAssignments ()
160163
161164 Log .d(ASSERTION_TAG , " Assert that we can see the correct score (60%) and the 'Base on graded assignments' checkbox is checked." )
162- courseGradesPage.assertBaseOnGradedAssignmentsChecked( )
163- courseGradesPage.refreshUntilAssertTotalGrade(containsTextCaseInsensitive( " 60" ) )
165+ gradesPage.assertBasedOnGradedAssignmentsToggleState( true )
166+ gradesPage.assertTotalGradeText( " 60% " )
164167
165168 Log .d(PREPARATION_TAG , " Seed a submission for '${assignment2.name} ' assignment." )
166169 SubmissionsApi .submitCourseAssignment(course.id, student.token, assignment2.id, SubmissionType .ONLINE_TEXT_ENTRY )
167170
168171 Log .d(PREPARATION_TAG , " Grade the previously seeded submission for '${assignment2.name} ' assignment." )
169172 SubmissionsApi .gradeSubmission(teacher.token, course.id, assignment2.id, student.id, postedGrade = " 10" )
170173
171- Log .d(ASSERTION_TAG , " Assert that we can see the correct score at the '${assignment2.name} ' assignment (66.67%) and at the total score as well (63.33%)." )
172- courseGradesPage .refresh()
173- courseGradesPage.assertGradeDisplayed(
174- withText (assignment2.name),
175- containsTextCaseInsensitive( " 66.67 " ) )
176- courseGradesPage.refreshUntilAssertTotalGrade(containsTextCaseInsensitive( " 63.33 " ))
174+ Log .d(ASSERTION_TAG , " Refresh the page. Assert that we can see the correct score at the '${assignment2.name} ' assignment (66.67%) and at the total score as well (63.33%)." )
175+ gradesPage .refresh()
176+ retryWithIncreasingDelay(times = 15 , maxDelay = 5000 , catchBlock = { gradesPage.refresh() }) {
177+ gradesPage.assertAssignmentGradeText (assignment2.name, " 66.67% " )
178+ gradesPage.assertTotalGradeText( " 63.33% " )
179+ }
177180
178- Log .d(PREPARATION_TAG , " Grade the previously seeded submission for '${assignment.name} ' assignment." )
181+ Log .d(PREPARATION_TAG , " Excuse the submission for '${assignment.name} ' assignment." )
179182 SubmissionsApi .gradeSubmission(teacher.token, course.id, assignment.id, student.id, excused = true )
180- courseGradesPage.refresh()
181183
182- Log .d(ASSERTION_TAG , " Assert that we can see the correct score (66.67%)." )
183- courseGradesPage.refreshUntilAssertTotalGrade(containsTextCaseInsensitive(" 66.67" ))
184+ Log .d(ASSERTION_TAG , " Refresh the page. Assert that we can see the correct score (66.67%)." )
185+ gradesPage.refresh()
186+ retryWithIncreasingDelay(times = 15 , maxDelay = 5000 , catchBlock = { gradesPage.refresh() }) {
187+ gradesPage.assertTotalGradeText(" 66.67%" )
188+ }
184189
185190 Log .d(PREPARATION_TAG , " Grade the previously seeded submission for '${assignment.name} ' assignment." )
186191 SubmissionsApi .gradeSubmission(teacher.token, course.id, assignment.id, student.id, postedGrade = " 9" )
187- courseGradesPage.refresh()
188192
189- Log .d(ASSERTION_TAG , " Assert that we can see the correct score (63.33%)." )
190- courseGradesPage.refreshUntilAssertTotalGrade(containsTextCaseInsensitive(" 63.33" ))
193+ Log .d(ASSERTION_TAG , " Refresh the page. Assert that we can see the correct score (63.33%)." )
194+ gradesPage.refresh()
195+ retryWithIncreasingDelay(times = 15 , maxDelay = 5000 , catchBlock = { gradesPage.refresh() }) {
196+ gradesPage.assertTotalGradeText(" 63.33%" )
197+ }
191198
192- Log .d(STEP_TAG , " Open '${assignment.name} ' assignment." )
193- courseGradesPage.openAssignment (assignment.name)
199+ Log .d(STEP_TAG , " Click on the '${assignment.name} ' assignment to open it's details ." )
200+ gradesPage.clickAssignment (assignment.name)
194201
195202 Log .d(ASSERTION_TAG , " Assert if the Assignment Details Page is displayed with the corresponding grade." )
196203 assignmentDetailsPage.assertPageObjects()
@@ -199,32 +206,17 @@ class GradesE2ETest: StudentComposeTest() {
199206 Log .d(STEP_TAG , " Navigate back to Course Grades Page." )
200207 Espresso .pressBack()
201208
202- Log .d(STEP_TAG , " Click on the expand/collapse button to collapse the list." )
203- courseGradesPage.clickOnExpandCollapseButton()
204-
205- Log .d(ASSERTION_TAG , " Assert that the assignment will disappear from the list view." )
206- courseGradesPage.assertAssignmentCount(0 )
207-
208- Log .d(STEP_TAG , " Click on the expand/collapse button again to expand the list." )
209- courseGradesPage.clickOnExpandCollapseButton()
209+ Log .d(STEP_TAG , " Collapse the 'Upcoming Assignments' list." )
210+ gradesPage.clickAssignmentGroupExpandCollapseButton(" Upcoming Assignments" )
210211
211- Log .d(ASSERTION_TAG , " Assert that the assignment will disappear from the list view ." )
212- courseGradesPage.assertAssignmentCount( 3 )
212+ Log .d(ASSERTION_TAG , " Assert that only 1 assignment, the ' ${quiz.title} ' quiz is display as the others are collapsed ." )
213+ gradesPage.assertAllAssignmentItemCount( 1 )
213214
214- /* TODO: Submit a quiz if/when we can do so via WebView
215- // Let's submit our quiz
216- courseGradesPage.selectItem(quizMatcher)
217- assignmentDetailsPage.viewQuiz()
218- quizDetailsPage.takeQuiz(quizQuestions)
219- quizDetailsPage.submitQuiz()
220- Espresso.pressBack() // to assignment details
221- Espresso.pressBack() // to grades
215+ Log .d(STEP_TAG , " Expand the 'Upcoming Assignments' list." )
216+ gradesPage.clickAssignmentGroupExpandCollapseButton(" Upcoming Assignments" )
222217
223- // And make sure our new quiz grade shows up in our grades
224- courseGradesPage.refresh()
225- courseGradesPage.assertGradeDisplayed(quizMatcher, containsTextCaseInsensitive("10/10"))
226- courseGradesPage.refreshUntilAssertTotalGrade(containsTextCaseInsensitive("76"))
227- */
218+ Log .d(ASSERTION_TAG , " Assert that all the 3 assignments are displayed." )
219+ gradesPage.assertAllAssignmentItemCount(3 )
228220 }
229221
230222 private fun makeQuizQuestions () = listOf (
0 commit comments