diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index a89ee5d0..d79c6bb3 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -16,7 +16,7 @@ <%= hidden_field "user", "login", :value => session[:cas_user] %> <%= hidden_field "user", "password", :value => session[:cas_user] %> <%= hidden_field "user", "password_confirmation", :value => session[:cas_user] %> - <%= hidden_field"user", "auth_type", :value => "cas" %> + <%= hidden_field "user", "auth_type", :value => "cas" %> <%else%> diff --git a/config/cucumber.yml b/config/cucumber.yml index 621a14ce..199cb582 100644 --- a/config/cucumber.yml +++ b/config/cucumber.yml @@ -4,5 +4,5 @@ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'pr std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip" %> default: <%= std_opts %> features -wip: --tags @wip:3 --wip features +wip: --tags @wip:10 --wip features rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip diff --git a/features/context_list.feature b/features/context_list.feature index 87bd202c..999e790f 100644 --- a/features/context_list.feature +++ b/features/context_list.feature @@ -103,7 +103,7 @@ Feature: Manage the list of contexts And I add a new active context "foo, bar" Then I should see "Name cannot contain the comma" - @javascript @wip + @javascript Scenario: I can drag and drop to order the contexts Given I have the following contexts | context | diff --git a/features/dependencies.feature b/features/dependencies.feature index 8e240f84..eb3b10f8 100644 --- a/features/dependencies.feature +++ b/features/dependencies.feature @@ -9,7 +9,7 @@ Feature: dependencies | testuser | secret | false | And I have logged in as "testuser" with password "secret" - @selenium + @javascript @webkit_only Scenario: Adding dependency to dependency by drag and drop Given I have a project "dependencies" with 3 todos And "todo 2" depends on "todo 1" @@ -23,7 +23,7 @@ Feature: dependencies When I expand the dependencies of "todo 2" Then I should see "todo 3" within the dependencies of "todo 2" - @selenium + @javascript Scenario: I can edit a todo to add the todo as a dependency to another Given I have a context called "@pc" And I have a project "dependencies" that has the following todos @@ -43,7 +43,7 @@ Feature: dependencies Then I should see "test 1" within the dependencies of "test 3" Then I should see "test 2" within the dependencies of "test 3" - @selenium + @javascript Scenario: I can remove a dependency by editing the todo Given I have a context called "@pc" And I have a project "dependencies" that has the following todos @@ -57,7 +57,7 @@ Feature: dependencies Then I should not see "test 1" within the dependencies of "test 2" And I should not see "test 1" in the deferred container - @selenium + @javascript Scenario: Completing a predecessor will activate successors Given I have a context called "@pc" And I have a project "dependencies" that has the following todos @@ -75,7 +75,7 @@ Feature: dependencies And I should not see "test 2" in the deferred container And I should see the empty message in the deferred container - @selenium + @javascript @selenium_only Scenario: Deleting a predecessor will activate successors Given I have a context called "@pc" And I have a project "dependencies" that has the following todos @@ -88,11 +88,11 @@ Feature: dependencies Then I should see "test 2" in the deferred container And I should see "test 1" in the action container When I delete the action "test 1" - And I should see "test 2" in the action container + Then I should see "test 2" in the action container And I should not see "test 2" in the deferred container And I should see the empty message in the deferred container - @selenium + @javascript @selenium_only Scenario: Deleting a successor will update predecessor Given I have a context called "@pc" And I have a project "dependencies" that has the following todos @@ -111,7 +111,7 @@ Feature: dependencies Then I should see "test 3" within the dependencies of "test 1" And I should not see "test 2" - @selenium + @javascript @webkit_only Scenario: Dragging an action to a completed action will not add it as a dependency Given I have a context called "@pc" And I have a project "dependencies" that has the following todos @@ -124,7 +124,7 @@ Feature: dependencies Then I should see an error flash message saying "Cannot add this action as a dependency to a completed action!" And I should see "test 1" in project container for "dependencies" - @selenium + @javascript @webkit_only Scenario Outline: Marking a successor as complete will update predecessor Given I have a context called "@pc" And I have a project "dependencies" that has the following todos @@ -146,7 +146,7 @@ Feature: dependencies | "dependencies" project | | tag page for "bla" | - @selenium + @javascript @webkit_only Scenario Outline: Marking a successor as active will update predecessor Given I have a context called "@pc" And I have a project "dependencies" that has the following todos diff --git a/features/step_definitions/container_steps.rb b/features/step_definitions/container_steps.rb index d2b73bd8..1067d6db 100644 --- a/features/step_definitions/container_steps.rb +++ b/features/step_definitions/container_steps.rb @@ -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 diff --git a/features/step_definitions/dependencies_steps.rb b/features/step_definitions/dependencies_steps.rb index 2dd19e67..66c66ef7 100644 --- a/features/step_definitions/dependencies_steps.rb +++ b/features/step_definitions/dependencies_steps.rb @@ -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 diff --git a/features/step_definitions/generic_steps.rb b/features/step_definitions/generic_steps.rb index e0d64ad1..f9af1e7c 100644 --- a/features/step_definitions/generic_steps.rb +++ b/features/step_definitions/generic_steps.rb @@ -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 diff --git a/features/step_definitions/signup_steps.rb b/features/step_definitions/signup_steps.rb index 113ce137..5bbba959 100644 --- a/features/step_definitions/signup_steps.rb +++ b/features/step_definitions/signup_steps.rb @@ -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 \ No newline at end of file diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index 62d0a3e3..dc27a3f6 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -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| diff --git a/features/support/env.rb b/features/support/env.rb index 68df1dd2..a7b1a067 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -19,7 +19,7 @@ require 'capybara/session' # BUG in this version of cucumber/capybara: require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript Capybara.default_wait_time = 5 -Capybara.javascript_driver = :webkit +Capybara.javascript_driver = ENV["JS_DRIVER"] ? ENV["JS_DRIVER"].to_sym : :selenium if Capybara.javascript_driver == :webkit require 'capybara/webkit' diff --git a/features/support/world.rb b/features/support/world.rb index 6adc0f2b..9b14b021 100644 --- a/features/support/world.rb +++ b/features/support/world.rb @@ -62,6 +62,14 @@ module TracksStepHelper page.evaluate_script('$(":animated").length') == 0 end end + + def wait_for_ajax + start_time = Time.now + page.evaluate_script('jQuery.isReady&&jQuery.active==0').class.should_not eql(String) + until(page.evaluate_script('jQuery.isReady&&jQuery.active==0') || (start_time + 5.seconds) < Time.now) + sleep 1 + end + end def handle_js_confirm(accept=true) page.execute_script "window.original_confirm_function = window.confirm"