cleanup old selenium initializer stuff and migrate edit_a_todo

This commit is contained in:
Reinier Balt 2012-02-15 21:42:06 +01:00
parent d193e21ee0
commit d8b5c7d0d2
19 changed files with 501 additions and 191 deletions

View file

@ -13,13 +13,13 @@ When /^I mark "([^"]*)" as uncompleted$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
check "mark_complete_#{todo.id}"
uncheck "mark_complete_#{todo.id}"
wait_for_ajax
end
When /^I mark the complete todo "([^"]*)" active$/ do |action_description|
When "I mark \"#{action_description}\" as uncompleted"
step "I mark \"#{action_description}\" as uncompleted"
end
####### (UN)STARRING #######
@ -31,14 +31,15 @@ When /^I star the action "([^"]*)"$/ do |action_description|
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
selenium.is_element_present(xpath_unstarred).should be_true
page.should have_xpath(xpath_unstarred)
star_img = "//img[@id='star_img_#{todo.id}']"
selenium.click(star_img, :wait_for => :ajax, :javascript_framework => :jquery)
wait_for :timeout => 5 do
selenium.is_element_present(xpath_starred)
end
page.find(:xpath, star_img).click
wait_for_ajax
wait_for_animations_to_end
page.should have_xpath(xpath_starred)
end
When /^I unstar the action "([^"]*)"$/ do |action_description|
@ -72,11 +73,11 @@ When /I change the (.*) field of "([^\"]*)" to "([^\"]*)"$/ do |field_name, todo
end
When /^I edit the context of "([^"]*)" to "([^"]*)"$/ do |todo_name, context_new_name|
When "I change the context_name field of \"#{todo_name}\" to \"#{context_new_name}\""
step "I change the context_name field of \"#{todo_name}\" to \"#{context_new_name}\""
end
When /^I edit the project of "([^"]*)" to "([^"]*)"$/ do |todo_name, project_new_name|
When "I change the project_name field of \"#{todo_name}\" to \"#{project_new_name}\""
step "I change the project_name field of \"#{todo_name}\" to \"#{project_new_name}\""
end
When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description|
@ -92,7 +93,9 @@ When /^I try to edit the description of "([^"]*)" to "([^"]*)"$/ do |action_desc
todo.should_not be_nil
open_edit_form_for(todo)
fill_in "todo_description", :with => new_description
selenium.click("//div[@id='edit_todo_#{todo.id}']//button[@id='submit_todo_#{todo.id}']", :wait_for => :ajax, :javascript_framework => :jquery)
submit_button_xpath = "//div[@id='edit_todo_#{todo.id}']//button[@id='submit_todo_#{todo.id}']"
page.find(:xpath, submit_button_xpath).click
wait_for_ajax
# do not wait for form to disappear to be able to test failures
end
@ -107,12 +110,12 @@ end
When /^I edit the due date of "([^"]*)" to tomorrow$/ do |action_description|
date = format_date(Time.zone.now + 1.day)
When "I edit the due date of \"#{action_description}\" to \"#{date}\""
step "I edit the due date of \"#{action_description}\" to \"#{date}\""
end
When /^I edit the due date of "([^"]*)" to next month$/ do |action_description|
date = format_date(Time.zone.now + 1.month)
When "I edit the due date of \"#{action_description}\" to \"#{date}\""
step "I edit the due date of \"#{action_description}\" to \"#{date}\""
end
When /^I clear the due date of "([^"]*)"$/ do |action_description|
@ -141,23 +144,24 @@ When /^I remove the show from date from "([^"]*)"$/ do |action_description|
todo.should_not be_nil
open_edit_form_for(todo)
selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='show_from_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery)
page.find("//div[@id='edit_todo_#{todo.id}']//a[@id='show_from_x_todo_#{todo.id}']/img").click
submit_edit_todo_form(todo)
end
When /^I clear the show from date of "([^"]*)"$/ do |action_description|
When "I remove the show from date from \"#{action_description}\""
step "I remove the show from date from \"#{action_description}\""
end
When /^I defer "([^"]*)" for 1 day$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
defer_todo_1day_button = "xpath=//a[@id='defer_1_todo_#{todo.id}']/img"
selenium.click defer_todo_1day_button
open_submenu_for(todo)
click_link "defer_1_todo_#{todo.id}"
wait_for_ajax
wait_for_animations_to_end
end
When /^I edit the tags of "([^"]*)" to "([^"]*)"$/ do |action_description, tags|
@ -173,19 +177,17 @@ When /^I make a project of "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
make_project_button = "xpath=//a[@id='to_project_todo_#{todo.id}']/img"
selenium.click make_project_button
open_submenu_for(todo)
click_link "to_project_todo_#{todo.id}"
wait_for :timeout => 5 do
!selenium.is_element_present("//div[@id='line_todo_#{todo.id}']")
end
page.should have_no_css("div#line_todo_#{todo.id}")
wait_for_ajax
wait_for_animations_to_end
end
####### THEN #######
Then /^I should see an error message$/ do
error_block = "xpath=//form/div[@id='edit_error_status']"
wait_for :timeout => 5 do
selenium.is_element_present(error_block)
end
error_block = "//form/div[@id='edit_error_status']"
page.find(:xpath, error_block).should_not be_nil
end