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

@ -5,18 +5,14 @@ module NavigationHelpers
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)$/
if $1.to_i == 1
getting_started_path
else
getting_started_path(:step => $1)
end
when /^the tag page for "([^\"]*)"$/ when /^the tag page for "([^\"]*)"$/
tag_path($1) tag_path(Regexp.last_match(1))
when /^its ([\w ]+) page$/ when /^its ([\w ]+) page$/
send("#{$1.gsub(/\W+/, '_')}_path", @it) 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$/ when /^the ([\w ]+) page$/
send("#{$1.gsub(/\W+/, '_')}_path") public_send("#{Regexp.last_match(1).gsub(/\W+/, '_')}_path")
when /^my edit profile page$/ when /^my edit profile page$/
edit_profile_path edit_profile_path
when /^my profile page$/ when /^my profile page$/
@ -24,22 +20,22 @@ module NavigationHelpers
when /^my acceptance form page$/ when /^my acceptance form page$/
invite_code_path(InvitationCode.first) invite_code_path(InvitationCode.first)
when /^the requestors profile$/ when /^the requestors profile$/
person_path(Request.where(:recipient_id => @me.person.id).first.sender) person_path(Request.where(recipient_id: @me.person.id).first.sender)
when /^"([^\"]*)"'s page$/ when /^"([^\"]*)"'s page$/
p = User.find_by_email($1).person p = User.find_by_email(Regexp.last_match(1)).person
{path: person_path(p), {path: person_path(p),
# '#diaspora_handle' on desktop, '.description' on mobile # '#diaspora_handle' on desktop, '.description' on mobile
special_elem: { selector: '#diaspora_handle, .description', text: p.diaspora_handle } special_elem: {selector: "#diaspora_handle, .description", text: p.diaspora_handle}
} }
when /^"([^\"]*)"'s photos page$/ when /^"([^\"]*)"'s photos page$/
p = User.find_by_email($1).person p = User.find_by_email(Regexp.last_match(1)).person
person_photos_path p person_photos_path p
when /^my account settings page$/ when /^my account settings page$/
edit_user_path edit_user_path
when /^forgot password page$/ when /^forgot password page$/
new_user_password_path new_user_password_path
when /^"(\/.*)"/ when %r{^"(/.*)"}
$1 Regexp.last_match(1)
else else
raise "Can't find mapping from \"#{page_name}\" to a path." raise "Can't find mapping from \"#{page_name}\" to a path."
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