migrate dependencies and admin feature

This commit is contained in:
Reinier Balt 2012-02-03 15:57:23 +01:00
parent c8ab797924
commit d193e21ee0
11 changed files with 70 additions and 117 deletions

View file

@ -44,10 +44,7 @@ Then /^I should see the container for context "([^"]*)"$/ do |context_name|
context.should_not be_nil
xpath = "//div[@id='c#{context.id}']"
wait_for :timeout => 5 do
selenium.is_visible(xpath)
end
page.should have_xpath(xpath)
end
Then /^the container for the context "([^"]*)" should be visible$/ do |context_name|
@ -61,9 +58,7 @@ Then /^I should see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_
todo.should_not be_nil
xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_visible(xpath)
end
page.should have_xpath(xpath)
end
Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name|
@ -73,13 +68,7 @@ Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |t
todo.should_not be_nil
xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']"
if selenium.is_element_present(xpath)
# give jquery some time to finish
wait_for :timeout_in_seconds => 5 do
!selenium.is_visible(xpath)
end
end
page.should_not have_xpath(xpath)
end
####### Deferred #######
@ -88,22 +77,14 @@ Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
page.should have_xpath("//div[@id='tickler']//div[@id='line_todo_#{todo.id}']")
end
Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
page.should_not have_xpath("//div[@id='tickler']//div[@id='line_todo_#{todo.id}']")
end
####### Project #######
@ -113,10 +94,7 @@ Then /^I should see "([^"]*)" in the action container$/ do |todo_description|
todo.should_not be_nil
xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
page.should have_xpath(xpath)
end
Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |todo_description, project_name|
@ -127,12 +105,7 @@ Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |to
project.should_not be_nil
xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']"
if selenium.is_element_present(xpath)
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
page.should_not have_xpath(xpath)
end
Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_description, project_name|
@ -143,9 +116,7 @@ Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_desc
project.should_not be_nil
xpath = "//div[@id='p#{project.id}items']//div[@id='line_todo_#{todo.id}']"
selenium.wait_for_element("xpath=#{xpath}", :timeout_in_seconds => 5)
selenium.is_visible(xpath).should be_true
page.should have_xpath(xpath)
end
####### Completed #######
@ -155,10 +126,7 @@ Then /^I should see "([^"]*)" in the completed container$/ do |todo_description|
todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
page.should have_xpath(xpath)
end
Then /^I should not see "([^"]*)" in the completed container$/ do |todo_description|
@ -166,12 +134,7 @@ Then /^I should not see "([^"]*)" in the completed container$/ do |todo_descript
todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
if selenium.is_element_present(xpath)
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
page.should_not have_xpath(xpath)
end
####### Hidden #######
@ -181,10 +144,7 @@ Then /^I should see "([^"]*)" in the hidden container$/ do |todo_description|
todo.should_not be_nil
xpath = "//div[@id='hidden']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
page.should have_xpath(xpath)
end
####### Calendar #######
@ -194,7 +154,7 @@ Then /^I should see "([^"]*)" in the due next month container$/ do |todo_descrip
todo.should_not be_nil
within "div#due_after_this_month" do
find("div#line_todo_#{todo.id}").should_not be_nil
page.should have_css("div#line_todo_#{todo.id}")
end
end

View file

@ -10,20 +10,20 @@ end
When /^I drag "(.*)" to "(.*)"$/ do |dragged, target|
drag_id = Todo.find_by_description(dragged).id
drop_id = Todo.find_by_description(target).id
drag_name = "xpath=//div[@id='line_todo_#{drag_id}']//img[@class='grip']"
drop_name = "xpath=//div[@id='line_todo_#{drop_id}']//div[@class='description']"
drag_elem = page.find(:xpath, "//div[@id='line_todo_#{drag_id}']//img[@class='grip']")
drop_elem = page.find(:xpath, "//div[@id='line_todo_#{drop_id}']//div[@class='description']")
selenium.drag_and_drop_to_object(drag_name, drop_name)
wait_for_ajax
drag_elem.drag_to(drop_elem)
end
When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name|
todo = Todo.find_by_description(todo_name)
todo.should_not be_nil
expand_img_locator = "xpath=//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
selenium.click(expand_img_locator)
expand_img_locator = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
page.find(:xpath, expand_img_locator).click
wait_for_animations_to_end
end
When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |todo_description, predecessor_description|
@ -34,20 +34,23 @@ When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |
open_edit_form_for(todo)
input = "xpath=//form[@id='form_todo_#{todo.id}']//input[@id='predecessor_input']"
selenium.focus(input)
selenium.type_keys input, predecessor_description
form_css = "form#form_todo_#{todo.id}"
within form_css do
fill_in 'predecessor_input', :with => predecessor_description
end
# in webkit, the autocompleter is not fired after fill_in
page.execute_script %Q{$("#{form_css}").find('input[id$="predecessor_input"]').autocomplete('search')} if Capybara.javascript_driver == :webkit
# wait for auto complete
autocomplete = "xpath=//a[@id='ui-active-menuitem']"
selenium.wait_for_element(autocomplete, :timeout_in_seconds => 5)
page.should have_css("a#ui-active-menuitem")
# click first line
first_elem = "xpath=//ul/li[1]/a[@id='ui-active-menuitem']"
selenium.click(first_elem)
page.find(:xpath, "//ul/li[1]/a[@id='ui-active-menuitem']").click
new_dependency_line = "xpath=//li[@id='pred_#{predecessor.id}']"
selenium.wait_for_element(new_dependency_line, :timeout_in_seconds => 5)
# wait for the new dependency to be added to the list
page.should have_css("li#pred_#{predecessor.id}")
submit_edit_todo_form(todo)
end
@ -60,14 +63,14 @@ When /^I edit the dependency of "([^"]*)" to remove "([^"]*)" as predecessor$/ d
open_edit_form_for(todo)
delete_dep_button = "xpath=//form[@id='form_todo_#{todo.id}']//img[@id='delete_dep_#{predecessor.id}']"
selenium.click(delete_dep_button)
wait_for :timeout=>5 do
!selenium.is_element_present(delete_dep_button)
end
delete_dep_button = "//form[@id='form_todo_#{todo.id}']//img[@id='delete_dep_#{predecessor.id}']"
page.find(:xpath, delete_dep_button).click
page.should_not have_xpath(delete_dep_button)
submit_edit_todo_form(todo)
# note that animations will be running after the ajax is completed
wait_for_ajax
wait_for_animations_to_end
end
When /^I edit the dependency of "([^"]*)" to "([^"]*)"$/ do |todo_name, deps|
@ -90,40 +93,21 @@ end
Then /^I should see "([^\"]*)" within the dependencies of "([^\"]*)"$/ do |successor_description, todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
successor = @current_user.todos.find_by_description(successor_description)
successor.should_not be_nil
# argh, webrat on selenium does not support within, so this won't work
# xpath = "//div[@id='line_todo_#{todo.id}'"
# Then "I should see \"#{successor_description}\" within \"xpath=#{xpath}\""
# let selenium look for the presence of the successor
xpath = "xpath=//div[@id='line_todo_#{todo.id}']//div[@id='successor_line_todo_#{successor.id}']//span"
selenium.wait_for_element(xpath, :timeout_in_seconds => 5)
Then "I should see \"#{successor_description}\" within \"div#line_todo_#{todo.id}\""
end
Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |successor_description, todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
successor = @current_user.todos.find_by_description(successor_description)
successor.should_not be_nil
# let selenium look for the presence of the successor
xpath = "xpath=//div[@id='line_todo_#{todo.id}']//div[@id='successor_line_todo_#{successor.id}']//span"
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
Then "I should not see \"#{successor_description}\" within \"div#line_todo_#{todo.id}\""
end
Then /^I should see that "([^"]*)" does not have dependencies$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
dependencies_icon = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
if selenium.is_element_present(dependencies_icon)
wait_for :timeout => 5 do
!selenium.is_element_present(dependencies_icon)
end
end
page.should_not have_xpath(dependencies_icon)
end

View file

@ -16,9 +16,7 @@ Then /the badge should show (.*)/ do |number|
end
Then /^I should see the empty message in the deferred container$/ do
wait_for :timeout => 5 do
selenium.is_visible("xpath=//div[@id='tickler']//div[@id='tickler-empty-nd']")
end
page.should have_xpath("//div[@id='tickler']//div[@id='tickler-empty-nd']")
end
Then /^I should see the empty tickler message$/ do
@ -35,7 +33,7 @@ end
Then /^I should see an error flash message saying "([^"]*)"$/ do |message|
xpath = "//div[@id='message_holder']/h4[@id='flash']"
text = response.selenium.get_text("xpath=#{xpath}")
text = page.find(:xpath, xpath).text
text.should == message
end

View file

@ -1,5 +1,5 @@
Given /^public signups are turned (.*)$/ do |state|
case state
case state
when 'on'
SITE_CONFIG['open_signups'] = true
when 'off'
@ -13,5 +13,5 @@ When /^I submit the signup form with username "([^\"]*)", password "([^\"]*)" an
fill_in 'Desired login', :with => username
fill_in 'Choose password', :with => password
fill_in 'Confirm password', :with => confirm
click_button
click_button "Signup"
end

View file

@ -9,6 +9,9 @@ When /^I delete the action "([^"]*)"$/ do |action_description|
find("a#delete_todo_#{todo.id}").click
end
get_confirm_text.should == "Are you sure that you want to delete the action '#{todo.description}'?"
wait_for_ajax
wait_for_animations_to_end
end
When /^I delete the todo "([^"]*)"$/ do |action_description|