Clean up manual timeouts in feature tests

This commit is contained in:
Dan Rice 2014-09-09 22:52:45 -04:00
parent ab7081482e
commit 4830cc028a
5 changed files with 16 additions and 44 deletions

View file

@ -85,11 +85,9 @@ Then /^the successors of "(.*)" should include "(.*)"$/ do |parent_name, child_n
parent = @current_user.todos.where(:description => parent_name).first
expect(parent).to_not be_nil
# wait until the successor is added. TODO: make this not loop indefinitly
# wait until the successor is added.
wait_until do
found = !parent.pending_successors.where(:description => child_name).first.nil?
sleep 0.2 unless found
found
!parent.pending_successors.where(:description => child_name).first.nil?
end
end
@ -119,4 +117,4 @@ Then /^I should see that "([^"]*)" does not have dependencies$/ do |todo_descrip
expect(todo).to_not be_nil
dependencies_icon = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
expect(page).to_not have_xpath(dependencies_icon)
end
end

View file

@ -7,9 +7,7 @@ When /^I delete project "([^"]*)"$/ do |project_name|
end
expect(get_confirm_text).to eq("Are you sure that you want to delete the project '#{project_name}'?")
wait_until do
!page.has_css?("a#delete_project_#{project.id}")
end
expect(page).to_not have_css("a#delete_project_#{project.id}")
end
When /^I drag the project "([^"]*)" below "([^"]*)"$/ do |project_drag, project_drop|

View file

@ -214,10 +214,7 @@ When /^I add a note "([^"]*)" to the project$/ do |note_body|
expect(elem).to_not be_nil
elem.click
wait_until do
!elem.visible?
end
expect(page).to_not have_css(submit_button, visible: true)
end
When /^I click on the first note icon$/ do
@ -283,9 +280,7 @@ Then /^I should see the italic text "([^\"]*)" in the project description$/ do |
end
Then /^the project title should be "(.*)"$/ do |title|
wait_until do
page.find("h2#project_name_container span#project_name").text == title
end
expect(page).to have_css("h2#project_name_container span#project_name", text: title, exact: true)
end
Then /^I should see the project name is "([^"]*)"$/ do |project_name|

View file

@ -138,9 +138,7 @@ When /^I clear the due date of "([^"]*)"$/ do |action_description|
# de same todo more than once
within all("div#edit_todo_#{todo.id}")[0] do
find("a#due_x_todo_#{todo.id}").click
wait_until do
find("input#due_todo_#{todo.id}").value == ""
end
expect(page).to have_field("due_todo_#{todo.id}", with: "")
end
submit_edit_todo_form(todo)
end
@ -208,4 +206,4 @@ end
Then /^I should see an error message$/ do
error_block = "//form/div[@id='edit_error_status']"
expect(page).to have_xpath(error_block)
end
end