Commit 57c27b7c authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '51316-qa-fix-transient-fork-spec-failure' into 'master'

Troubleshoot "Transient failure in qa/specs/features/project/fork_project_spec.rb"

See merge request gitlab-org/gitlab-ce!21858
parents cc8424d4 98db20f0
...@@ -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