Stabilize mobile close account cukes

This commit is contained in:
Steffen van Bergerem 2015-06-18 22:31:27 +02:00
parent b3c535bab4
commit d6d1e38ba1
4 changed files with 59 additions and 50 deletions

View file

@ -8,7 +8,8 @@ Feature: Close account
Given I am signed in Given I am signed in
When I go to the users edit page When I go to the users edit page
And I click on selector "#close_account" And I click on selector "#close_account"
Then I should see "Hey, please dont go!" within "#closeAccountModal" Then I should see a modal
And I should see "Hey, please dont go!" within "#closeAccountModal"
When I put in my password in "close_account_password" When I put in my password in "close_account_password"
And I press "close_account_confirm" And I press "close_account_confirm"
And I confirm the alert And I confirm the alert

View file

@ -8,12 +8,13 @@ Feature: Close account
Given I am signed in Given I am signed in
When I go to the users edit page When I go to the users edit page
And I click on selector "#close_account" And I click on selector "#close_account"
Then I should see "Hey, please dont go!" within "#closeAccountModal" Then I should see a modal
When I put in my password in "close_account_password" And I should see "Hey, please dont go!" within "#closeAccountModal"
When I put in my password in the close account modal
And I press "close_account_confirm" And I press "close_account_confirm"
And I confirm the alert 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 When I try to sign in manually
And I try to sign in manually
Then I should be on the new user session page Then I should be on the new user session page
And I should see a flash message with a warning And I should see a flash message with a warning

View file

@ -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"} step %{I should see a "#mentionModal.in"}
end 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

View file

@ -1,47 +1,43 @@
module NavigationHelpers module NavigationHelpers
def path_to(page_name) def path_to(page_name)
case page_name case page_name
when /^person_photos page$/ when /^person_photos page$/
person_photos_path(@me.person) person_photos_path(@me.person)
when /^the home(?: )?page$/ when /^the home(?: )?page$/
stream_path stream_path
when /^step (\d)$/ when /^the tag page for "([^\"]*)"$/
if $1.to_i == 1 tag_path(Regexp.last_match(1))
getting_started_path when /^its ([\w ]+) page$/
else send("#{Regexp.last_match(1).gsub(/\W+/, '_')}_path", @it)
getting_started_path(:step => $1) when /^the mobile ([\w ]+) page$/
end public_send("#{Regexp.last_match(1).gsub(/\W+/, '_')}_path", format: "mobile")
when /^the tag page for "([^\"]*)"$/ when /^the ([\w ]+) page$/
tag_path($1) public_send("#{Regexp.last_match(1).gsub(/\W+/, '_')}_path")
when /^its ([\w ]+) page$/ when /^my edit profile page$/
send("#{$1.gsub(/\W+/, '_')}_path", @it) edit_profile_path
when /^the ([\w ]+) page$/ when /^my profile page$/
send("#{$1.gsub(/\W+/, '_')}_path") person_path(@me.person)
when /^my edit profile page$/ when /^my acceptance form page$/
edit_profile_path invite_code_path(InvitationCode.first)
when /^my profile page$/ when /^the requestors profile$/
person_path(@me.person) person_path(Request.where(recipient_id: @me.person.id).first.sender)
when /^my acceptance form page$/ when /^"([^\"]*)"'s page$/
invite_code_path(InvitationCode.first) p = User.find_by_email(Regexp.last_match(1)).person
when /^the requestors profile$/ {path: person_path(p),
person_path(Request.where(:recipient_id => @me.person.id).first.sender) # '#diaspora_handle' on desktop, '.description' on mobile
when /^"([^\"]*)"'s page$/ special_elem: {selector: "#diaspora_handle, .description", text: p.diaspora_handle}
p = User.find_by_email($1).person }
{ path: person_path(p), when /^"([^\"]*)"'s photos page$/
# '#diaspora_handle' on desktop, '.description' on mobile p = User.find_by_email(Regexp.last_match(1)).person
special_elem: { selector: '#diaspora_handle, .description', text: p.diaspora_handle } person_photos_path p
} when /^my account settings page$/
when /^"([^\"]*)"'s photos page$/ edit_user_path
p = User.find_by_email($1).person when /^forgot password page$/
person_photos_path p new_user_password_path
when /^my account settings page$/ when %r{^"(/.*)"}
edit_user_path Regexp.last_match(1)
when /^forgot password page$/ else
new_user_password_path raise "Can't find mapping from \"#{page_name}\" to a path."
when /^"(\/.*)"/
$1
else
raise "Can't find mapping from \"#{page_name}\" to a path."
end end
end end
@ -56,12 +52,12 @@ module NavigationHelpers
def navigate_to(page_name) def navigate_to(page_name)
path = path_to(page_name) path = path_to(page_name)
unless path.is_a?(Hash) if path.is_a?(Hash)
visit(path)
else
visit(path[:path]) visit(path[:path])
await_elem = path[:special_elem] await_elem = path[:special_elem]
find(await_elem.delete(:selector), await_elem) find(await_elem.delete(:selector), await_elem)
else
visit(path)
end end
end end