Skip to content

Commit 2dbfa74

Browse files
author
Jake Sorce
committed
spec: add selenium spec to gradebook2 file refs #7540
Change-Id: If672a04e6e6cacf5078ea5d44f29f9f80fe1657d Reviewed-on: https://gerrit.instructure.com/9140 Reviewed-by: Bryan Madsen <bryan@instructure.com> Tested-by: Hudson <hudson@instructure.com>
1 parent fa0f116 commit 2dbfa74

1 file changed

Lines changed: 77 additions & 58 deletions

File tree

spec/selenium/gradebook2_spec.rb

Lines changed: 77 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ def set_default_grade(cell_index, points = "5")
1010
dialog_form = dialog.find_element(:css, '.ui-dialog-content')
1111
driver.find_element(:css, '.grading_value').send_keys(points)
1212
dialog_form.submit
13+
keep_trying_until do
14+
driver.switch_to.alert.should_not be_nil
15+
driver.switch_to.alert.dismiss
16+
true
17+
end
18+
driver.switch_to.default_content
1319
end
1420

1521
def open_assignment_options(cell_index)
@@ -275,8 +281,8 @@ def conclude_and_unconclude_course
275281
wait_for_ajaximations
276282
els = driver.find_elements(:css, '.student-name')
277283
els.map { |e| URI.parse(e.find_element(:css, 'a').attribute('href')).path }.should == [
278-
"/courses/#{@course.id}/grades/#{@student_1.id}",
279-
"/courses/#{@course.id}/grades/#{@student_2.id}",
284+
"/courses/#{@course.id}/grades/#{@student_1.id}",
285+
"/courses/#{@course.id}/grades/#{@student_2.id}",
280286
]
281287
end
282288

@@ -436,33 +442,6 @@ def toggle_muting(assignment)
436442
validate_cell_text(grade_cells[4].find_element(:css, '.percentage'), STUDENT_2_TOTAL_IGNORING_UNGRADED)
437443
end
438444

439-
it "should validate setting group weights" do
440-
weight_num = 50.0
441-
442-
get "/courses/#{@course.id}/gradebook2"
443-
wait_for_ajaximations
444-
445-
driver.find_element(:id, 'gradebook_settings').click
446-
wait_for_animations
447-
driver.find_element(:css, '[aria-controls="assignment_group_weights_dialog"]').click
448-
449-
dialog = driver.find_element(:id, 'assignment_group_weights_dialog')
450-
dialog.should be_displayed
451-
452-
dialog.find_element(:css, '#group_weighting_scheme').click
453-
set_value(dialog.find_element(:css, '.group_weight'), weight_num)
454-
455-
save_button = find_with_jquery('.ui-dialog-buttonset .ui-button:contains("Save")')
456-
save_button.click
457-
wait_for_ajax_requests
458-
@course.reload.group_weighting_scheme.should == 'percent'
459-
@group.reload.group_weight.should eql(weight_num)
460-
461-
# TODO: make the header cell in the UI update to reflect new value
462-
# heading = find_with_jquery(".slick-column-name:contains('#{@group.name}') .assignment-points-possible")
463-
# heading.should include_text("#{weight_num}% of grade")
464-
end
465-
466445
it "should validate arrange columns by due date option" do
467446
expected_text = "-"
468447

@@ -515,14 +494,14 @@ def toggle_muting(assignment)
515494

516495
it "should let you post a group comment to a group assignment" do
517496
group_assignment = assignment_model({
518-
:course => @course,
519-
:name => 'group assignment',
520-
:due_at => (Time.now + 1.week),
521-
:points_possible => ASSIGNMENT_3_POINTS,
522-
:submission_types => 'online_text_entry',
523-
:assignment_group => @group,
524-
:group_category => GroupCategory.create!(:name => "groups", :context => @course),
525-
:grade_group_students_individually => true
497+
:course => @course,
498+
:name => 'group assignment',
499+
:due_at => (Time.now + 1.week),
500+
:points_possible => ASSIGNMENT_3_POINTS,
501+
:submission_types => 'online_text_entry',
502+
:assignment_group => @group,
503+
:group_category => GroupCategory.create!(:name => "groups", :context => @course),
504+
:grade_group_students_individually => true
526505
})
527506
project_group = group_assignment.group_category.groups.create!(:name => 'g1', :context => @course)
528507
project_group.users << @student_1
@@ -571,16 +550,7 @@ def toggle_muting(assignment)
571550
#for the test to work correctly
572551

573552
set_default_grade(2, 5)
574-
575-
keep_trying_until do
576-
driver.switch_to.alert.should_not be_nil
577-
driver.switch_to.alert.dismiss
578-
end
579-
580-
driver.switch_to.default_content
581-
582553
grade_grid = driver.find_element(:css, '#gradebook_grid')
583-
584554
@course.student_enrollments.each_with_index do |e, n|
585555
next if e.completed?
586556
find_slick_cells(n, grade_grid)[2].text.should == 5
@@ -661,6 +631,41 @@ def toggle_muting(assignment)
661631
driver.find_element(:id, 'after_fudge_points_total').text.should == points.to_s
662632
end
663633
end
634+
635+
it "should validate setting default grade for an assignment" do
636+
expected_grade = "45"
637+
638+
get "/courses/#{@course.id}/gradebook2"
639+
wait_for_ajaximations
640+
641+
set_default_grade(2, expected_grade)
642+
grade_grid = driver.find_element(:css, '#gradebook_grid')
643+
StudentEnrollment.count.times do |n|
644+
find_slick_cells(n, grade_grid)[2].text.should == expected_grade
645+
end
646+
end
647+
648+
it "should correctly set default grades for a specific section" do
649+
pending('bug 7540 - Setting default grade for one section changes it for all ') do
650+
def open_section_menu_and_click(menu_item_css)
651+
driver.find_element(:id, 'section_to_show').click
652+
section_menu = driver.find_element(:id, 'section-to-show-menu')
653+
section_menu.should be_displayed
654+
section_menu.find_element(:css, menu_item_css).click
655+
end
656+
657+
expected_grade = "45"
658+
gradebook_row_1 = '#gradebook_grid [row="1"]'
659+
get "/courses/#{@course.id}/gradebook2"
660+
wait_for_ajaximations
661+
662+
open_section_menu_and_click('#section-to-show-menu-1')
663+
set_default_grade(2, expected_grade)
664+
open_section_menu_and_click('#section-to-show-menu-0')
665+
driver.find_element(:css, gradebook_row_1).should be_displayed
666+
validate_cell_text(driver.find_element(:css, "#{gradebook_row_1} .r2"), '-')
667+
end
668+
end
664669
end
665670

666671
context "group weights" do
@@ -704,23 +709,38 @@ def check_group_points(expected_weight_text)
704709
@course.reload
705710
end
706711

707-
it "should validate setting default grade for an assignment" do
708-
expected_grade = "45"
712+
it "should validate setting group weights" do
713+
weight_numbers = [30.0, 70.0]
709714

710715
get "/courses/#{@course.id}/gradebook2"
711716
wait_for_ajaximations
712717

713-
set_default_grade(1, expected_grade)
718+
driver.find_element(:id, 'gradebook_settings').click
719+
wait_for_animations
720+
driver.find_element(:css, '[aria-controls="assignment_group_weights_dialog"]').click
721+
722+
dialog = driver.find_element(:id, 'assignment_group_weights_dialog')
723+
dialog.should be_displayed
724+
725+
group_check = dialog.find_element(:id, 'group_weighting_scheme')
714726
keep_trying_until do
715-
driver.switch_to.alert.should_not be_nil
716-
driver.switch_to.alert.dismiss
717-
true
727+
group_check.click
728+
is_checked('#group_weighting_scheme').should be_true
718729
end
719-
driver.switch_to.default_content
720-
grade_grid = driver.find_element(:css, '#gradebook_grid')
721-
StudentEnrollment.count.times do |n|
722-
find_slick_cells(n, grade_grid)[1].text.should == expected_grade
730+
group_weight_inputs = driver.find_elements(:css, '.group_weight')
731+
2.times { |i| set_value(group_weight_inputs[i], weight_numbers[i]) }
732+
save_button = find_with_jquery('.ui-dialog-buttonset .ui-button:contains("Save")')
733+
save_button.click
734+
wait_for_ajax_requests
735+
@course.reload.group_weighting_scheme.should == 'percent'
736+
assignment_groups = AssignmentGroup.all
737+
assignment_groups.each_with_index do |ag, i|
738+
ag.reload.group_weight.should eql(weight_numbers[i])
723739
end
740+
741+
# TODO: make the header cell in the UI update to reflect new value
742+
# heading = find_with_jquery(".slick-column-name:contains('#{@group.name}') .assignment-points-possible")
743+
# heading.should include_text("#{weight_num}% of grade")
724744
end
725745

726746
it "should display group weights correctly when set on assignment groups" do
@@ -735,8 +755,7 @@ def check_group_points(expected_weight_text)
735755
get "/courses/#{@course.id}/assignments"
736756
driver.find_element(:id, 'class_weighting_policy').click
737757
wait_for_ajaximations
738-
get "/courses/#{@course.id}/gradebook2"
739-
wait_for_ajaximations
758+
740759

741760
check_group_points('0%')
742761
end

0 commit comments

Comments
 (0)