From e7cf5fc841c55e4b8c3dd7c7e93e61eb22f625e3 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 2 Feb 2011 17:17:00 -0800 Subject: [PATCH] Fix/expand cucumber feature for new user signup. Replace "wait for aspects page"-type steps with general wait for step. --- .../users/getting_started/_step_2.html.haml | 2 +- features/manages_contact_requests.feature | 2 +- features/signs_up.feature | 15 +++--- features/step_definitions/custom_web_steps.rb | 17 +++---- features/support/paths.rb | 46 +++++++++++-------- 5 files changed, 45 insertions(+), 37 deletions(-) diff --git a/app/views/users/getting_started/_step_2.html.haml b/app/views/users/getting_started/_step_2.html.haml index 8b966ac17..b4d593674 100644 --- a/app/views/users/getting_started/_step_2.html.haml +++ b/app/views/users/getting_started/_step_2.html.haml @@ -49,7 +49,7 @@ %h4 = t('.aspect_name') = form_for Aspect.new do |aspect| - = aspect.text_field :name, :style => "display:inline;" + = aspect.text_field :name, :id => "step-2-aspect-name", :style => "display:inline;" %p.checkbox_select = aspect.label :contacts_visible, t('aspects.edit.make_aspect_list_visible') = aspect.check_box :contacts_visible, :default => true diff --git a/features/manages_contact_requests.feature b/features/manages_contact_requests.feature index b45d1d34e..69fc3a494 100644 --- a/features/manages_contact_requests.feature +++ b/features/manages_contact_requests.feature @@ -17,7 +17,7 @@ Feature: managing contact requests When I am on the aspects manage page Then I should see "1" within "#notification_badge" When I click on the contact request - And I wait for the requestors profile page to load + And I wait for "the requestors profile" to load Then I should be on the requestors profile And I should see "wants to share with you" diff --git a/features/signs_up.feature b/features/signs_up.feature index 7ace4790d..2d9018c49 100644 --- a/features/signs_up.feature +++ b/features/signs_up.feature @@ -16,21 +16,22 @@ Feature: new user registration And I fill in "profile_last_name" with "Hai" And I fill in "profile_gender" with "guess!" And I press "Save and continue" + And I wait for "step 2" to load Then I should see "Profile updated" And I should see "Your aspects" + When I fill in "step-2-aspect-name" with "cheez friends" + And I press "Add" + Then I should see "cheez friends" -# Not working with selenium - it thinks the aspect name field is hidden -# When I fill in "Aspect name" with "cheez friends" -# And I press "Add" -# And show me the page -# Then I should see "cheez friends" When I follow "Save and continue" + And I wait for "step 3" to load Then I should see "Your services" When I follow "Save and continue" + And I wait for "step 4" to load Then I should see "You're all set up, O!" - And I should not see "skip getting started" + But I should not see "skip getting started" When I follow "Continue on to your Home page, an overview of all of your aspects." Then I should be on the aspects page @@ -43,6 +44,6 @@ Feature: new user registration Scenario: new user skips the setup wizard When I follow "skip getting started" - And I wait for the aspects page to load + And I wait for "the aspects page" to load Then I should be on the aspects page And I should see "Bring the people that matter in your life to Diaspora!" diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 611e55e6a..5628cd067 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -47,14 +47,6 @@ Then /^I should see "([^\"]*)" in the main content area$/ do |stuff| end end -When /^I wait for the aspects page to load$/ do - wait_until { current_path == aspects_path } -end - -When /^I wait for the requestors profile page to load$/ do - wait_until { current_path == person_path(Request.where(:recipient_id => @me.person.id).first.sender) } -end - When /^I wait for the ajax to finish$/ do wait_until(10) { evaluate_script("$.active") == 0 } end @@ -68,3 +60,12 @@ When /^I click ok in the confirm dialog to appear next$/ do window.confirm = function() { return true; }; JS end + +When /^I wait for "([^\"]*)" to load$/ do |page_name| + wait_until(10) do + uri = URI.parse(current_url) + current_location = uri.path + current_location << "?#{uri.query}" unless uri.query.blank? + current_location == path_to(page_name) + end +end \ No newline at end of file diff --git a/features/support/paths.rb b/features/support/paths.rb index 0265ce7c9..ed078dfa4 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -1,26 +1,32 @@ module NavigationHelpers def path_to(page_name) case page_name - when /^the home page$/ - root_path - when /^its ([\w ]+) page$/ - send("#{$1.gsub(/\W+/, '_')}_path", @it) - when /^the ([\w ]+) page$/ - send("#{$1.gsub(/\W+/, '_')}_path") - when /^my edit profile page$/ - edit_person_path(@me.person) - when /^my acceptance form page$/ - accept_user_invitation_path(:invitation_token => @me.invitation_token) - when /^the requestors profile$/ - person_path(Request.where(:recipient_id => @me.person.id).first.sender) - when /^"([^\"]*)"'s page$/ - person_path(User.find_by_email($1).person) - when /^my account settings page$/ - edit_user_path(@me) - when /^"(\/.*)"/ - $1 - else - raise "Can't find mapping from \"#{page_name}\" to a path." + when /^the home page$/ + root_path + when /^step (\d)$/ + if $1.to_i == 1 + getting_started_path + else + getting_started_path(:step => $1) + end + when /^its ([\w ]+) page$/ + send("#{$1.gsub(/\W+/, '_')}_path", @it) + when /^the ([\w ]+) page$/ + send("#{$1.gsub(/\W+/, '_')}_path") + when /^my edit profile page$/ + edit_person_path(@me.person) + when /^my acceptance form page$/ + accept_user_invitation_path(:invitation_token => @me.invitation_token) + when /^the requestors profile$/ + person_path(Request.where(:recipient_id => @me.person.id).first.sender) + when /^"([^\"]*)"'s page$/ + person_path(User.find_by_email($1).person) + when /^my account settings page$/ + edit_user_path(@me) + when /^"(\/.*)"/ + $1 + else + raise "Can't find mapping from \"#{page_name}\" to a path." end end end