From d2795334f3decc6f4da3572e8d065908d077ef6f Mon Sep 17 00:00:00 2001 From: James Butters Date: Mon, 13 Aug 2018 15:10:25 -0600 Subject: [PATCH] spec: add specs for only selected provisional comments displayed to student fixes: GRADE-1390 Test Plan: jenkins passes Change-Id: Ia6a36e3965c82f0c1d326b8ddfb6f7ba2ac9852f Reviewed-on: https://gerrit.instructure.com/160709 Tested-by: Jenkins Reviewed-by: Derek Bender Reviewed-by: Spencer Olson Product-Review: James Butters QA-Review: James Butters --- .../moderation/moderated_marking_spec.rb | 47 +++++++++++++++++-- spec/selenium/grades/pages/moderate_page.rb | 6 ++- .../grades/pages/student_grades_page.rb | 8 ++++ 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/spec/selenium/grades/moderation/moderated_marking_spec.rb b/spec/selenium/grades/moderation/moderated_marking_spec.rb index 20fed9c52fd..0a557e659f6 100644 --- a/spec/selenium/grades/moderation/moderated_marking_spec.rb +++ b/spec/selenium/grades/moderation/moderated_marking_spec.rb @@ -164,15 +164,15 @@ describe 'Moderated Marking' do ModeratePage.click_post_grades_button driver.switch_to.alert.accept wait_for_ajaximations - # wait for info header stating grades are posted - wait = Selenium::WebDriver::Wait.new(timeout: 5) - wait.until { ff("#content header div").size > 3 } + # wait for element to exist, means page has loaded + ModeratePage.grades_posted_button + # unmute using Display to Students button ModeratePage.click_display_to_students_button driver.switch_to.alert.accept wait_for_ajaximations - # wait for flash alert stating grades are visible to students - wait.until {ff("#flashalert_message_holder div").size > 1} + # wait for element to exist, means page has loaded + ModeratePage.grades_posted_button # switch session to student user_session(@student1) @@ -181,6 +181,43 @@ describe 'Moderated Marking' do expect(StudentGradesPage.fetch_assignment_score(@moderated_assignment)).to eq '15' end + it 'displays comments from chosen grader', priority: "1", test_id: 3513994 do + skip('Unskip in GRADE-1326') + submissions = @moderated_assignment.find_or_create_submissions([@student1, @student2]) + + submissions.each do |submission| + submission.add_comment(author: @teacher1, comment: 'Just a comment by teacher1') + submission.add_comment(author: @teacher2, comment: 'Just a comment by teacher2') + end + + # select a provisional grade for each student + ModeratePage.select_provisional_grade_for_student_by_position(@student1, 1) + ModeratePage.select_provisional_grade_for_student_by_position(@student2, 2) + + # post the grades + ModeratePage.click_post_grades_button + driver.switch_to.alert.accept + wait_for_ajaximations + # wait for element to exist, means page has loaded + ModeratePage.grades_posted_button + + # unmute using Display to Students button + ModeratePage.click_display_to_students_button + driver.switch_to.alert.accept + wait_for_ajaximations + # wait for element to exist, means page has loaded + ModeratePage.grades_visible_to_students_button + + # switch session to student + user_session(@student1) + + StudentGradesPage.visit_as_student(@moderated_course) + StudentGradesPage.comment_button.click + + expect(StudentGradesPage.comments(@moderated_assignment).count).to eq 1 + expect(StudentGradesPage.comments(@moderated_assignment).first).to include_text 'Just a comment by teacher1' + end + it 'display to students button disabled until grades are posted', priority: '1', test_id: 3513991 do expect(ModeratePage.display_to_students_button).to be_disabled end diff --git a/spec/selenium/grades/pages/moderate_page.rb b/spec/selenium/grades/pages/moderate_page.rb index ba0503284fa..fad2d2c9295 100644 --- a/spec/selenium/grades/pages/moderate_page.rb +++ b/spec/selenium/grades/pages/moderate_page.rb @@ -121,7 +121,11 @@ class ModeratePage end def display_to_students_button - fj("button:contains('Display')") + fj("button:contains('Display to Students')") + end + + def grades_visible_to_students_button + fj("button:contains('Grades Visible to Students')") end def page_buttons diff --git a/spec/selenium/grades/pages/student_grades_page.rb b/spec/selenium/grades/pages/student_grades_page.rb index cdd65766c3d..bc080afe34e 100644 --- a/spec/selenium/grades/pages/student_grades_page.rb +++ b/spec/selenium/grades/pages/student_grades_page.rb @@ -87,6 +87,14 @@ class StudentGradesPage f("#submission_#{assignment_id} .assignment_score .grade").text end + def comment_button + ffxpath('//a[@aria-label="Read comments"]').select(&:displayed?).first + end + + def comments(assignment) + ff("#comments_thread_#{assignment.id} table tbody tr") + end + def fetch_assignment_score(assignment) if assignment.grading_type == "letter_grade" assignment_row(assignment).find_element(css: '.assignment_score .score_value').text