spec: make have_class wait, refs SD-1145
test plan: * specs pass Change-Id: I2afa9f13c6e1cee5c12e3ac35e48f234c33ef4fd Reviewed-on: https://gerrit.instructure.com/80269 Tested-by: Jenkins Reviewed-by: Jon Jensen <jon@instructure.com> Product-Review: Jon Jensen <jon@instructure.com> QA-Review: Jon Jensen <jon@instructure.com>
This commit is contained in:
parent
84c1e347df
commit
82e6977a7f
|
@ -86,7 +86,7 @@ describe "account" do
|
|||
f('.editing_term .general_dates .start_date .edit_term input').send_keys("2011-07-01")
|
||||
f('.editing_term .general_dates .end_date .edit_term input').send_keys("2011-07-31")
|
||||
f("button[type='submit']").click
|
||||
keep_trying_until { term.attribute(:class) !~ /editing_term/ }
|
||||
expect(term).not_to have_class("editing_term")
|
||||
verify_displayed_term_dates(term, {
|
||||
:general => ["Jul 1", "Jul 31"],
|
||||
:student_enrollment => ["term start", "term end"],
|
||||
|
@ -102,7 +102,7 @@ describe "account" do
|
|||
f('.editing_term .student_enrollment_dates .start_date .edit_term input').send_keys("2011-07-02")
|
||||
f('.editing_term .student_enrollment_dates .end_date .edit_term input').send_keys("2011-07-30")
|
||||
f("button[type='submit']").click
|
||||
keep_trying_until { term.attribute(:class) !~ /editing_term/ }
|
||||
expect(term).not_to have_class("editing_term")
|
||||
verify_displayed_term_dates(term, {
|
||||
:general => ["whenever", "whenever"],
|
||||
:student_enrollment => ["Jul 2", "Jul 30"],
|
||||
|
@ -118,7 +118,7 @@ describe "account" do
|
|||
f('.editing_term .teacher_enrollment_dates .start_date .edit_term input').send_keys("2011-07-03")
|
||||
f('.editing_term .teacher_enrollment_dates .end_date .edit_term input').send_keys("2011-07-29")
|
||||
f("button[type='submit']").click
|
||||
keep_trying_until { term.attribute(:class) !~ /editing_term/ }
|
||||
expect(term).not_to have_class("editing_term")
|
||||
verify_displayed_term_dates(term, {
|
||||
:general => ["whenever", "whenever"],
|
||||
:student_enrollment => ["term start", "term end"],
|
||||
|
@ -134,7 +134,7 @@ describe "account" do
|
|||
f('.editing_term .ta_enrollment_dates .start_date .edit_term input').send_keys("2011-07-04")
|
||||
f('.editing_term .ta_enrollment_dates .end_date .edit_term input').send_keys("2011-07-28")
|
||||
f("button[type='submit']").click
|
||||
keep_trying_until { term.attribute(:class) !~ /editing_term/ }
|
||||
expect(term).not_to have_class("editing_term")
|
||||
verify_displayed_term_dates(term, {
|
||||
:general => ["whenever", "whenever"],
|
||||
:student_enrollment => ["term start", "term end"],
|
||||
|
|
|
@ -84,19 +84,14 @@ describe 'developer keys' do
|
|||
end
|
||||
|
||||
it "should be paginated", priority: "1", test_id: 344532 do
|
||||
25.times { |i| Account.default.developer_keys.create!(name: "tool #{i}") }
|
||||
11.times { |i| Account.default.developer_keys.create!(name: "tool #{i}") }
|
||||
get "/accounts/#{Account.default.id}/developer_keys"
|
||||
expect(f("#loading")).not_to have_class('loading')
|
||||
# pagination should load 10 objects by default
|
||||
expect(ff("#keys tbody tr").length).to eq 10
|
||||
expect(ff("#keys tbody tr")).to have_size(10)
|
||||
expect(f('#loading')).to have_class('show_more')
|
||||
f("#loading .show_all").click
|
||||
wait_for_ajaximations
|
||||
loading = f("#loading")
|
||||
keep_trying_until do
|
||||
expect(loading).not_to have_class('loading')
|
||||
true
|
||||
end
|
||||
expect(ff("#keys tbody tr").length).to eq 25
|
||||
expect(f("#loading")).not_to have_class('loading')
|
||||
expect(ff("#keys tbody tr")).to have_size(11)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,18 +74,13 @@ describe "managing developer keys" do
|
|||
|
||||
it "should show the first 10 by default, with pagination working" do
|
||||
count = DeveloperKey.count
|
||||
25.times { |i| DeveloperKey.create!(:name => "tool #{i}") }
|
||||
11.times { |i| DeveloperKey.create!(:name => "tool #{i}") }
|
||||
get '/developer_keys'
|
||||
expect(f("#loading")).not_to have_class('loading')
|
||||
expect(ff("#keys tbody tr").length).to eq 10
|
||||
expect(ff("#keys tbody tr")).to have_size(10)
|
||||
expect(f('#loading')).to have_class('show_more')
|
||||
f("#loading .show_all").click
|
||||
wait_for_ajaximations
|
||||
loading = f("#loading")
|
||||
keep_trying_until do
|
||||
expect(loading).not_to have_class('loading')
|
||||
true
|
||||
end
|
||||
expect(ff("#keys tbody tr").length).to eq count + 25
|
||||
expect(f("#loading")).not_to have_class('loading')
|
||||
expect(ff("#keys tbody tr")).to have_size(count + 11)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -492,22 +492,14 @@ describe "assignments" do
|
|||
|
||||
it "should allow publishing from the show page", priority: "1", test_id: 647851 do
|
||||
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
|
||||
wait_for_ajaximations
|
||||
|
||||
def speedgrader_hidden?
|
||||
driver.execute_script(
|
||||
"return $('#assignment-speedgrader-link').hasClass('hidden')"
|
||||
)
|
||||
end
|
||||
|
||||
expect(speedgrader_hidden?).to eq true
|
||||
expect(f("#assignment-speedgrader-link")).to have_class("hidden")
|
||||
|
||||
f("#assignment_publish_button").click
|
||||
wait_for_ajaximations
|
||||
|
||||
expect(@assignment.reload).to be_published
|
||||
expect(f("#assignment_publish_button").text).to match "Published"
|
||||
expect(speedgrader_hidden?).to eq false
|
||||
expect(f("#assignment_publish_button")).to include_text("Published")
|
||||
expect(f("#assignment-speedgrader-link")).not_to have_class("hidden")
|
||||
end
|
||||
|
||||
it "should show publishing status on the edit page", priority: "2", test_id: 647852 do
|
||||
|
@ -531,15 +523,10 @@ describe "assignments" do
|
|||
get "/courses/#{@course.id}/assignments"
|
||||
|
||||
f("#assignment_#{@assignment.id} .publish-icon").click
|
||||
wait_for_ajaximations
|
||||
keep_trying_until { @assignment.reload.published? }
|
||||
|
||||
# need to make sure buttons
|
||||
keep_trying_until do
|
||||
driver.execute_script(
|
||||
"return !$('#assignment_#{@assignment.id} .publish-icon').hasClass('disabled')"
|
||||
)
|
||||
end
|
||||
expect(f("#assignment_#{@assignment.id} .publish-icon")).not_to have_class("disabled")
|
||||
|
||||
f("#assignment_#{@assignment.id} .publish-icon").click
|
||||
wait_for_ajaximations
|
||||
|
|
|
@ -792,16 +792,12 @@ describe "context modules" do
|
|||
wait_for_ajaximations(1000)
|
||||
context_module_items[0].send_keys("i")
|
||||
item = f('.context_module_item')
|
||||
keep_trying_until do
|
||||
expect(item).to have_class('indent_1')
|
||||
end
|
||||
expect(item).to have_class('indent_1')
|
||||
|
||||
wait_for_ajaximations(1000)
|
||||
ff('.context_module_item a.title')[0].send_keys("o")
|
||||
item = f('.context_module_item')
|
||||
keep_trying_until do
|
||||
expect(item).to have_class('indent_0')
|
||||
end
|
||||
expect(item).to have_class('indent_0')
|
||||
|
||||
# Test Delete key
|
||||
wait_for_ajaximations(1000)
|
||||
|
@ -911,8 +907,8 @@ describe "context modules" do
|
|||
|
||||
# make sure the completion criterion was preserved
|
||||
module_item = f("#context_module_item_#{tag.id}")
|
||||
expect(module_item.attribute('class').split).to include 'must_submit_requirement'
|
||||
expect(f('.criterion', module_item).attribute('class').split).to include 'defined'
|
||||
expect(module_item).to have_class 'must_submit_requirement'
|
||||
expect(f('.criterion', module_item)).to have_class 'defined'
|
||||
expect(driver.execute_script("return $('#context_module_item_#{tag.id} .criterion_type').text()")).to eq "must_submit"
|
||||
end
|
||||
|
||||
|
|
|
@ -400,15 +400,16 @@ describe "dashboard" do
|
|||
context "course menu customization" do
|
||||
|
||||
it "should always have a link to the courses page (with customizations)", priority: "1", test_id: 216378 do
|
||||
20.times { course_with_teacher({:user => @user, :active_course => true, :active_enrollment => true}) }
|
||||
course_with_teacher({:user => @user, :active_course => true, :active_enrollment => true})
|
||||
get "/"
|
||||
if ENV['CANVAS_FORCE_USE_NEW_STYLES']
|
||||
f('#global_nav_courses_link').click
|
||||
expect(fj('.ReactTray-list-item a:contains("All Courses")')).to be_present
|
||||
else
|
||||
driver.execute_script %{$('#courses_menu_item').addClass('hover');}
|
||||
expect(fj('#courses_menu_item')).to include_text('My Courses')
|
||||
expect(fj('#courses_menu_item')).to include_text('View All or Customize')
|
||||
course_menu_item = f("#courses_menu_item")
|
||||
hover(course_menu_item)
|
||||
expect(course_menu_item).to include_text('My Courses')
|
||||
expect(course_menu_item).to include_text('View All or Customize')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -243,7 +243,7 @@ describe "dashboard" do
|
|||
context "course menu customization" do
|
||||
|
||||
it "should always have a link to the courses page (with customizations)", priority: "1", test_id: 216404 do
|
||||
20.times { course_with_teacher({:user => @user, :active_course => true, :active_enrollment => true}) }
|
||||
course_with_teacher({:user => @user, :active_course => true, :active_enrollment => true})
|
||||
|
||||
get "/"
|
||||
|
||||
|
@ -251,9 +251,10 @@ describe "dashboard" do
|
|||
f('#global_nav_courses_link').click
|
||||
expect(fj('.ReactTray-list-item a:contains("All Courses")')).to be_present
|
||||
else
|
||||
driver.execute_script %{$('#courses_menu_item').addClass('hover');}
|
||||
expect(fj('#courses_menu_item')).to include_text('My Courses')
|
||||
expect(fj('#courses_menu_item')).to include_text('View All or Customize')
|
||||
course_menu_item = f("#courses_menu_item")
|
||||
hover(course_menu_item)
|
||||
expect(course_menu_item).to include_text('My Courses')
|
||||
expect(course_menu_item).to include_text('View All or Customize')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -155,16 +155,16 @@ describe "editing grades" do
|
|||
assignment_2_sel= '#gradebook_grid .container_1 .slick-row:nth-child(1) .l4'
|
||||
a1 = f(assignment_1_sel)
|
||||
a2 = f(assignment_2_sel)
|
||||
expect(a1['class']).to include 'dropped'
|
||||
expect(a2['class']).not_to include 'dropped'
|
||||
expect(a1).to have_class 'dropped'
|
||||
expect(a2).not_to have_class 'dropped'
|
||||
|
||||
a2.click
|
||||
grade_input = a2.find_element(:css, '.grade')
|
||||
set_value(grade_input, 3)
|
||||
grade_input.send_keys(:tab)
|
||||
wait_for_ajaximations
|
||||
expect(f(assignment_1_sel)['class']).not_to include 'dropped'
|
||||
expect(f(assignment_2_sel)['class']).to include 'dropped'
|
||||
expect(f(assignment_1_sel)).not_to have_class 'dropped'
|
||||
expect(f(assignment_2_sel)).to have_class 'dropped'
|
||||
end
|
||||
|
||||
it "should update a grade when clicking outside of slickgrid", priority: "1", test_id: 220319 do
|
||||
|
|
|
@ -55,7 +55,7 @@ describe "grading standards" do
|
|||
|
||||
dialog.find_element(:css, ".find_grading_standard_link").click
|
||||
find_grading_standard = f(".find_grading_standard")
|
||||
keep_trying_until { expect(find_grading_standard).to have_class("loaded") }
|
||||
expect(find_grading_standard).to have_class("loaded")
|
||||
expect(dialog.find_element(:css, ".find_grading_standard")).to be_displayed
|
||||
expect(dialog.find_element(:css, ".display_grading_standard")).not_to be_displayed
|
||||
dialog.find_element(:css, ".cancel_find_grading_standard_link").click
|
||||
|
@ -96,7 +96,7 @@ describe "grading standards" do
|
|||
|
||||
dialog.find_element(:css, ".find_grading_standard_link").click
|
||||
find_grading_standard = f(".find_grading_standard")
|
||||
keep_trying_until { expect(find_grading_standard).to have_class("loaded") }
|
||||
expect(find_grading_standard).to have_class("loaded")
|
||||
expect(dialog.find_elements(:css, ".grading_standard_select .title")[-1].text).to eq @standard.title
|
||||
dialog.find_elements(:css, ".grading_standard_select")[-1].click
|
||||
expect(standard_brief = dialog.find_element(:css, "#grading_standard_brief_#{@standard.id}")).to be_displayed
|
||||
|
|
|
@ -55,7 +55,7 @@ describe "help dialog" do
|
|||
get "/dashboard"
|
||||
link = f('.support_url')
|
||||
expect(link['href']).to eq support_url
|
||||
expect(link['class']).not_to match 'help_dialog_trigger'
|
||||
expect(link).not_to have_class 'help_dialog_trigger'
|
||||
|
||||
# if show_feedback_link is true hijack clicks on the footer help link to show help dialog
|
||||
Setting.set('show_feedback_link', 'true')
|
||||
|
|
|
@ -217,14 +217,8 @@ module DiscussionsCommon
|
|||
end
|
||||
|
||||
def wait_for_subscription_icon_to_load(expected_class)
|
||||
wait = Selenium::WebDriver::Wait.new(timeout: 5)
|
||||
wait.until do
|
||||
f(".subscription-toggler").present?
|
||||
end
|
||||
expect(f(".subscription-toggler")).to be
|
||||
driver.execute_script(%{$('.subscription-toggler').trigger('mouseleave')})
|
||||
wait.until do
|
||||
f(".subscription-toggler").attribute("class").include?(expected_class) &&
|
||||
f(".#{expected_class}").present?
|
||||
end
|
||||
expect(f(".subscription-toggler")).to have_class(expected_class)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -62,22 +62,18 @@ describe "better_file_browsing, folders" do
|
|||
it "should unpublish and publish a folder from cloud icon", priority: "1", test_id: 220354 do
|
||||
set_item_permissions(:unpublish, :cloud_icon)
|
||||
expect(f('.btn-link.published-status.unpublished')).to be_displayed
|
||||
expect(driver.find_element(:class => 'unpublished')).to be_displayed
|
||||
set_item_permissions(:publish, :cloud_icon)
|
||||
expect(f('.btn-link.published-status.published')).to be_displayed
|
||||
expect(driver.find_element(:class => 'published')).to be_displayed
|
||||
end
|
||||
|
||||
it "should make folder available to student with link", priority: "1", test_id: 133110 do
|
||||
set_item_permissions(:restricted_access, :available_with_link, :cloud_icon)
|
||||
expect(f('.btn-link.published-status.hiddenState')).to be_displayed
|
||||
expect(driver.find_element(:class => 'hiddenState')).to be_displayed
|
||||
end
|
||||
|
||||
it "should make folder available to student within given timeframe", priority: "1", test_id: 193160 do
|
||||
set_item_permissions(:restricted_access, :available_with_timeline, :cloud_icon)
|
||||
expect(f('.btn-link.published-status.restricted')).to be_displayed
|
||||
expect(driver.find_element(:class => 'restricted')).to be_displayed
|
||||
end
|
||||
|
||||
it "should delete folder from toolbar", priority: "1", test_id: 133105 do
|
||||
|
|
|
@ -44,20 +44,16 @@ describe "better_file_browsing" do
|
|||
it "should unpublish and publish a file", priority: "1", test_id: 133096 do
|
||||
set_item_permissions(:unpublish, :cloud_icon)
|
||||
expect(f('.btn-link.published-status.unpublished')).to be_displayed
|
||||
expect(driver.find_element(:class => 'unpublished')).to be_displayed
|
||||
set_item_permissions(:publish, :cloud_icon)
|
||||
expect(f('.btn-link.published-status.published')).to be_displayed
|
||||
expect(driver.find_element(:class => 'published')).to be_displayed
|
||||
end
|
||||
it "should make file available to student with link", priority: "1", test_id: 223504 do
|
||||
set_item_permissions(:restricted_access, :available_with_link, :cloud_icon)
|
||||
expect(f('.btn-link.published-status.hiddenState')).to be_displayed
|
||||
expect(driver.find_element(:class => 'hiddenState')).to be_displayed
|
||||
end
|
||||
it "should make file available to student within given timeframe", priority: "1", test_id: 223505 do
|
||||
set_item_permissions(:restricted_access, :available_with_timeline, :cloud_icon)
|
||||
expect(f('.btn-link.published-status.restricted')).to be_displayed
|
||||
expect(driver.find_element(:class => 'restricted')).to be_displayed
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -69,20 +65,16 @@ describe "better_file_browsing" do
|
|||
it "should unpublish and publish a file", priority: "1", test_id: 223503 do
|
||||
set_item_permissions(:unpublish, :toolbar_menu)
|
||||
expect(f('.btn-link.published-status.unpublished')).to be_displayed
|
||||
expect(driver.find_element(:class => 'unpublished')).to be_displayed
|
||||
set_item_permissions(:publish, :toolbar_menu)
|
||||
expect(f('.btn-link.published-status.published')).to be_displayed
|
||||
expect(driver.find_element(:class => 'published')).to be_displayed
|
||||
end
|
||||
it "should make file available to student with link from toolbar", priority: "1", test_id: 193158 do
|
||||
set_item_permissions(:restricted_access, :available_with_link, :toolbar_menu)
|
||||
expect(f('.btn-link.published-status.hiddenState')).to be_displayed
|
||||
expect(driver.find_element(:class => 'hiddenState')).to be_displayed
|
||||
end
|
||||
it "should make file available to student within given timeframe from toolbar", priority: "1", test_id: 193159 do
|
||||
set_item_permissions(:restricted_access, :available_with_timeline, :toolbar_menu)
|
||||
expect(f('.btn-link.published-status.restricted')).to be_displayed
|
||||
expect(driver.find_element(:class => 'restricted')).to be_displayed
|
||||
end
|
||||
|
||||
it "should disable the file preview button when a folder is selected" do
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
# assert the presence (or absence) of a css class on an element.
|
||||
# will return as soon as the expectation is met, e.g.
|
||||
#
|
||||
# headers = ff(".enhanceable_content.accordion .ui-accordion-header")
|
||||
# expect(headers[0]).to have_class('ui-state-active')
|
||||
# headers[1].click
|
||||
# expect(headers[0]).to have_class('ui-state-default')
|
||||
RSpec::Matchers.define :have_class do |class_name|
|
||||
match do |element|
|
||||
!!element.attribute('class').match(class_name)
|
||||
wait_for(method: :have_class) do
|
||||
element.attribute('class').match(class_name)
|
||||
end
|
||||
end
|
||||
|
||||
match_when_negated do |element|
|
||||
wait_for(method: :have_class) do
|
||||
!element.attribute('class').match(class_name)
|
||||
end
|
||||
end
|
||||
|
||||
failure_message do |element|
|
||||
|
|
|
@ -22,7 +22,7 @@ describe "users" do
|
|||
submit_form(pseudonym_form)
|
||||
wait_for_ajaximations
|
||||
|
||||
new_login = ff('.login').find { |e| e.attribute(:class) !~ /blank/ }
|
||||
new_login = f('.login:not(.blank)')
|
||||
expect(new_login).not_to be_nil
|
||||
expect(new_login.find_element(:css, '.account_name').text()).not_to be_blank
|
||||
pseudonym = Pseudonym.by_unique_id('new_user').first
|
||||
|
|
Loading…
Reference in New Issue