Commit 98db20f0 authored by Mark Lapierre's avatar Mark Lapierre

Assert successful sign in after registration

`.has_personal_area?` waits for sign in but does not ensure that it's
successful. Raise an exception if not successful so we can capture
a screenshot at the point of failure

Adds a workaround and code to help troubleshoot why a new user doesn't
stay signed in after loading a project page.
parent f9320089
...@@ -13,8 +13,43 @@ module QA ...@@ -13,8 +13,43 @@ module QA
product(:user) { |factory| factory.user } product(:user) { |factory| factory.user }
def visit_project_with_retry
# The user intermittently fails to stay signed in after visiting the
# project page. The new user is registered and then signs in and a
# screenshot shows that signing in was successful. Then the project
# page is visited but a screenshot shows the user is no longer signed
# in. It's difficult to reproduce locally but GDK logs don't seem to
# show anything unexpected. This method attempts to work around the
# problem and capture data to help troubleshoot.
Capybara::Screenshot.screenshot_and_save_page
start = Time.now
while Time.now - start < 20
push.project.visit!
puts "Visited project page"
Capybara::Screenshot.screenshot_and_save_page
return if Page::Menu::Main.act { has_personal_area?(wait: 0) }
puts "Not signed in. Attempting to sign in again."
Capybara::Screenshot.screenshot_and_save_page
Page::Menu::Main.act { sign_out }
Page::Main::Login.perform do |login|
login.sign_in_using_credentials(user)
end
end
raise "Failed to load project page and stay logged in"
end
def fabricate! def fabricate!
push.project.visit! visit_project_with_retry
Page::Project::Show.act { fork_project } Page::Project::Show.act { fork_project }
Page::Project::Fork::New.perform do |fork_new| Page::Project::Fork::New.perform do |fork_new|
......
...@@ -19,7 +19,7 @@ module QA ...@@ -19,7 +19,7 @@ module QA
fill_in :new_user_password, with: user.password fill_in :new_user_password, with: user.password
click_button 'Register' click_button 'Register'
Page::Menu::Main.act { has_personal_area? } Page::Menu::Main.act { assert_has_personal_area }
end end
end end
end end
......
...@@ -61,8 +61,13 @@ module QA ...@@ -61,8 +61,13 @@ module QA
end end
def has_personal_area?(wait: Capybara.default_max_wait_time) def has_personal_area?(wait: Capybara.default_max_wait_time)
# No need to wait, either we're logged-in, or not. using_wait_time(wait) do
using_wait_time(wait) { page.has_selector?('.qa-user-avatar') } page.has_selector?(element_selector_css(:user_avatar))
end
end
def assert_has_personal_area
raise "Failed to sign in" unless has_personal_area?
end end
private private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment