diff --git a/features/desktop/closes_account.feature b/features/desktop/closes_account.feature index 26b93607c..ece4afe58 100644 --- a/features/desktop/closes_account.feature +++ b/features/desktop/closes_account.feature @@ -8,7 +8,8 @@ Feature: Close account Given I am signed in When I go to the users edit page And I click on selector "#close_account" - Then I should see "Hey, please don’t go!" within "#closeAccountModal" + Then I should see a modal + And I should see "Hey, please don’t go!" within "#closeAccountModal" When I put in my password in "close_account_password" And I press "close_account_confirm" And I confirm the alert diff --git a/features/mobile/closes_account.feature b/features/mobile/closes_account.feature index f2458dba6..ceb74fd14 100644 --- a/features/mobile/closes_account.feature +++ b/features/mobile/closes_account.feature @@ -8,12 +8,13 @@ Feature: Close account Given I am signed in When I go to the users edit page And I click on selector "#close_account" - Then I should see "Hey, please don’t go!" within "#closeAccountModal" - When I put in my password in "close_account_password" + Then I should see a modal + And I should see "Hey, please don’t go!" within "#closeAccountModal" + When I put in my password in the close account modal And I press "close_account_confirm" And I confirm the alert + Then I should be on the mobile new user session page - When I am on the new user session page - And I try to sign in manually + When I try to sign in manually Then I should be on the new user session page And I should see a flash message with a warning diff --git a/features/step_definitions/modal_steps.rb b/features/step_definitions/modal_steps.rb index f672d9f03..36dbd9295 100644 --- a/features/step_definitions/modal_steps.rb +++ b/features/step_definitions/modal_steps.rb @@ -1,3 +1,14 @@ -Then /I should see the mention modal/ do +Then /^I should see a modal$/ do + step %{I should see a ".modal.in"} +end + +Then /^I should see the mention modal$/ do step %{I should see a "#mentionModal.in"} end + +When /^I put in my password in the close account modal$/ do + # Capybara helpers fill_in, set and send_keys currently don't work + # inside of Bootstrap modals on Travis CI + execute_script("$(\"#closeAccountModal input#close_account_password\").val(\"#{@me.password}\")") + expect(find("#closeAccountModal input#close_account_password").value).to eq(@me.password) +end diff --git a/features/support/paths.rb b/features/support/paths.rb index d1b923091..c19a72654 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -1,47 +1,43 @@ module NavigationHelpers def path_to(page_name) case page_name - when /^person_photos page$/ - person_photos_path(@me.person) - when /^the home(?: )?page$/ - stream_path - when /^step (\d)$/ - if $1.to_i == 1 - getting_started_path - else - getting_started_path(:step => $1) - end - when /^the tag page for "([^\"]*)"$/ - tag_path($1) - 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_profile_path - when /^my profile page$/ - person_path(@me.person) - when /^my acceptance form page$/ - invite_code_path(InvitationCode.first) - when /^the requestors profile$/ - person_path(Request.where(:recipient_id => @me.person.id).first.sender) - when /^"([^\"]*)"'s page$/ - p = User.find_by_email($1).person - { path: person_path(p), - # '#diaspora_handle' on desktop, '.description' on mobile - special_elem: { selector: '#diaspora_handle, .description', text: p.diaspora_handle } - } - when /^"([^\"]*)"'s photos page$/ - p = User.find_by_email($1).person - person_photos_path p - when /^my account settings page$/ - edit_user_path - when /^forgot password page$/ - new_user_password_path - when /^"(\/.*)"/ - $1 - else - raise "Can't find mapping from \"#{page_name}\" to a path." + when /^person_photos page$/ + person_photos_path(@me.person) + when /^the home(?: )?page$/ + stream_path + when /^the tag page for "([^\"]*)"$/ + tag_path(Regexp.last_match(1)) + when /^its ([\w ]+) page$/ + send("#{Regexp.last_match(1).gsub(/\W+/, '_')}_path", @it) + when /^the mobile ([\w ]+) page$/ + public_send("#{Regexp.last_match(1).gsub(/\W+/, '_')}_path", format: "mobile") + when /^the ([\w ]+) page$/ + public_send("#{Regexp.last_match(1).gsub(/\W+/, '_')}_path") + when /^my edit profile page$/ + edit_profile_path + when /^my profile page$/ + person_path(@me.person) + when /^my acceptance form page$/ + invite_code_path(InvitationCode.first) + when /^the requestors profile$/ + person_path(Request.where(recipient_id: @me.person.id).first.sender) + when /^"([^\"]*)"'s page$/ + p = User.find_by_email(Regexp.last_match(1)).person + {path: person_path(p), + # '#diaspora_handle' on desktop, '.description' on mobile + special_elem: {selector: "#diaspora_handle, .description", text: p.diaspora_handle} + } + when /^"([^\"]*)"'s photos page$/ + p = User.find_by_email(Regexp.last_match(1)).person + person_photos_path p + when /^my account settings page$/ + edit_user_path + when /^forgot password page$/ + new_user_password_path + when %r{^"(/.*)"} + Regexp.last_match(1) + else + raise "Can't find mapping from \"#{page_name}\" to a path." end end @@ -56,12 +52,12 @@ module NavigationHelpers def navigate_to(page_name) path = path_to(page_name) - unless path.is_a?(Hash) - visit(path) - else + if path.is_a?(Hash) visit(path[:path]) await_elem = path[:special_elem] find(await_elem.delete(:selector), await_elem) + else + visit(path) end end