Skip to content

Commit

Permalink
spec: better loading for assignments page
Browse files Browse the repository at this point in the history
specs are flaky due to interacting with the page before
it is fully loaded. Added some better waits.

Change-Id: I5f042777c84a7f08a652b566437af0ce0b44925a
Reviewed-on: https://gerrit.instructure.com/201961
Tested-by: Jenkins
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: James Butters <jbutters@instructure.com>
  • Loading branch information
jbutte committed Jul 19, 2019
1 parent ebb12fa commit b4ca96d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions spec/selenium/assignments/assignments_student_spec.rb
Expand Up @@ -41,6 +41,8 @@
@fourth_assignment = @course.assignments.create!(:title => 'assignment 4', :name => 'assignment 4', :due_at => @due_date - 1.day)

get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations
titles = ff('.ig-title')
expect(titles[0].text).to eq @fourth_assignment.title
expect(titles[1].text).to eq @assignment.title
Expand Down Expand Up @@ -142,6 +144,8 @@
it "should verify due date is enforced" do
due_date_assignment = @course.assignments.create!(:name => 'due date assignment', :due_at => 5.days.ago)
get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations
expect(f("#assignment_group_past #assignment_#{due_date_assignment.id}")).to be_displayed
due_date_assignment.update_attributes(:due_at => 2.days.from_now)
refresh_page # to show the updated assignment
Expand Down Expand Up @@ -320,6 +324,7 @@
ag = @course.assignment_groups.first

get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations

move_to_click("label[for=show_by_type]")
Expand All @@ -332,6 +337,7 @@
ag = @course.assignment_groups.first

get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations

expect(f("#content")).not_to contain_css('.new_assignment')
Expand All @@ -345,6 +351,7 @@
@course.assignments.create!(:title => 'undated assignment', :name => 'undated assignment')

get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations

expect(is_checked('#show_by_date')).to be_truthy
Expand All @@ -358,13 +365,15 @@
ag = @course.assignment_groups.first

get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations

move_to_click("label[for=show_by_type]")
expect(is_checked('#show_by_type')).to be_truthy
expect(f("#assignment_group_#{ag.id}")).not_to be_nil

get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations
expect(is_checked('#show_by_type')).to be_truthy
end
Expand All @@ -374,6 +383,7 @@
empty_ag = @course.assignment_groups.create!(:name => "Empty")

get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations

expect(f("#content")).not_to contain_css('#assignment_group_overdue')
Expand All @@ -394,6 +404,7 @@
empty_ag = @course.assignment_groups.create!(:name => "Empty", :group_weight => 10)

get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations

move_to_click("label[for=show_by_type]")
Expand All @@ -405,6 +416,7 @@
undated, upcoming = @course.assignments.partition{ |a| a.due_date.nil? }

get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations

undated.each do |a|
Expand Down Expand Up @@ -436,16 +448,16 @@

it "should exhaust all pagination of assignment groups" do
get "/courses/#{@course.id}/assignments"
wait_for_no_such_element { f('[data-view="assignmentGroups"] .loadingIndicator') }
wait_for_ajaximations

# if there are more assignment_groups visible than we fetch per page,
# it must mean that it paginated succcessfully

count_to_expect = @count_to_make + 1 # add one for the @assignment created in the root `before` block
expect(ff('[data-view="assignmentGroups"] .assignment').length).to be(count_to_expect)
expect(ff('[data-view="assignmentGroups"] .assignment').length).to eq(count_to_expect)

move_to_click("label[for=show_by_type]")
expect(ff('[data-view="assignmentGroups"] .assignment_group').length).to be(count_to_expect)
expect(ff('[data-view="assignmentGroups"] .assignment_group').length).to eq(count_to_expect)
end
end
end
Expand Down

0 comments on commit b4ca96d

Please sign in to comment.