spec: add spec for switching grade-type in assignment header menu

Change-Id: I8db96b5d0a12934fe4336b9edb70dc1f75959b71
fixes: GRADE-305
Reviewed-on: https://gerrit.instructure.com/134757
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
Reviewed-by: Indira Pai <ipai@instructure.com>
Product-Review: Anju Reddy <areddy@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
This commit is contained in:
Anju Reddy 2017-12-06 22:08:35 +05:30
parent a4d2b5295f
commit 77d1c2a751
2 changed files with 46 additions and 8 deletions

View File

@ -18,6 +18,7 @@
require_relative '../../helpers/gradezilla_common'
require_relative '../../helpers/groups_common'
require_relative '../pages/gradezilla_page'
require_relative '../pages/gradezilla_cells_page'
describe "Gradezilla - Assignment Column Options" do
include_context "in-process server selenium tests"
@ -36,19 +37,20 @@ describe "Gradezilla - Assignment Column Options" do
@assignment = @course.assignments.create!(
title: "An Assignment",
grading_type: 'letter_grade',
points_possible: 10,
due_at: 1.day.from_now
)
@course.student_enrollments.collect(&:user).each do |student|
@assignment.submit_homework(student, body: 'a body')
@assignment.grade_student(student, grade: 10, grader: @teacher)
@assignment.grade_student(student, grade: 'A', grader: @teacher)
end
end
before(:each) { user_session(@teacher) }
describe "Sorting" do
context "Sorting" do
it "sorts by Missing" do
third_student = @course.students.find_by!(name: 'Student 3')
@assignment.submissions.find_by!(user: third_student).update!(late_policy_status: "missing")
@ -70,4 +72,29 @@ describe "Gradezilla - Assignment Column Options" do
expect(Gradezilla.fetch_student_names).to eq ["Student 3", "Student 1", "Student 2"]
end
end
context "Enter Grades As Menu" do
before(:each) do
Gradezilla.visit(@course)
end
it "Can switch from grading-scheme to points", priority: "1", test_id: 3415925 do
# Initial grade is letter-grade
expect(Gradezilla::Cells.get_grade(@course.students[2], @assignment)).to eq 'A'
# Change grade type to points
Gradezilla.click_assignment_header_menu(@assignment.id)
Gradezilla.click_assignment_popover_enter_grade_as('Points')
wait_for_ajaximations
expect(Gradezilla::Cells.get_grade(@course.students[2], @assignment)).to eq '10'
end
it "Active grade-type displays a check", priority: "2", test_id: 3415924 do
# Initial grade is letter-grade
Gradezilla.click_assignment_header_menu(@assignment.id)
expect(Gradezilla.enter_grade_as_popover_menu_item_checked?('Grading Scheme')).to eq 'true'
end
end
end

View File

@ -61,12 +61,12 @@ class Gradezilla
f("span[data-menu-item-id=#{item_name}]")
end
def assignment_header_menu_sort_by_element
fj('button:contains("Sort by")')
def assignment_header_popover_menu_element(menu_name)
fj("button:contains('#{menu_name}')")
end
def assignment_header_sort_by_item_element(item)
fj("span[role=menuitemradio] span:contains(#{item})")
def assignment_header_popover_sub_item_element(item)
fj("span[role=menuitemradio]:contains(#{item})")
end
def assignment_header_cell_label_element(title)
@ -633,7 +633,7 @@ class Gradezilla
end
def click_assignment_popover_sort_by(sort_type)
hover(assignment_header_menu_sort_by_element)
hover(assignment_header_popover_menu_element("Sort by"))
sort_by_item = ""
if sort_type =~ /(low[\s\-]to[\s\-]high)/i
@ -647,7 +647,18 @@ class Gradezilla
elsif sort_type =~ /(unposted)/i
sort_by_item = 'Unposted'
end
assignment_header_sort_by_item_element(sort_by_item).click
assignment_header_popover_sub_item_element(sort_by_item).click
end
def click_assignment_popover_enter_grade_as(grade_type)
hover(assignment_header_popover_menu_element("Enter Grades as"))
assignment_header_popover_sub_item_element(grade_type).click
end
def enter_grade_as_popover_menu_item_checked?(grade_type)
hover(assignment_header_popover_menu_element("Enter Grades as"))
menu_item = assignment_header_popover_sub_item_element(grade_type)
menu_item.attribute('aria-checked')
end
def select_assignment_header_cell_element(name)