diff options
author | Rémy Coutable <remy@rymai.me> | 2018-09-25 17:22:26 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-09-25 17:22:26 +0000 |
commit | 57c27b7c01568fd6081de77c7c430e5f0701d432 (patch) | |
tree | c6bbf381fdc509e601ce752e112d3f861ef49b55 | |
parent | cc8424d4e80a5866bbfb7ee7814d0302991e4a60 (diff) | |
parent | 98db20f02e62f1770182ef2826a81c28c2a77bde (diff) | |
download | gitlab-ce-57c27b7c01568fd6081de77c7c430e5f0701d432.tar.gz |
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
-rw-r--r-- | qa/qa/factory/resource/fork.rb | 37 | ||||
-rw-r--r-- | qa/qa/page/main/sign_up.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/menu/main.rb | 9 |
3 files changed, 44 insertions, 4 deletions
diff --git a/qa/qa/factory/resource/fork.rb b/qa/qa/factory/resource/fork.rb index 01969c31438..92050eaba2a 100644 --- a/qa/qa/factory/resource/fork.rb +++ b/qa/qa/factory/resource/fork.rb @@ -13,8 +13,43 @@ module QA 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! - push.project.visit! + visit_project_with_retry + Page::Project::Show.act { fork_project } Page::Project::Fork::New.perform do |fork_new| diff --git a/qa/qa/page/main/sign_up.rb b/qa/qa/page/main/sign_up.rb index 33ab56236f4..64cd395de78 100644 --- a/qa/qa/page/main/sign_up.rb +++ b/qa/qa/page/main/sign_up.rb @@ -19,7 +19,7 @@ module QA fill_in :new_user_password, with: user.password click_button 'Register' - Page::Menu::Main.act { has_personal_area? } + Page::Menu::Main.act { assert_has_personal_area } end end end diff --git a/qa/qa/page/menu/main.rb b/qa/qa/page/menu/main.rb index 36e7285f7b7..2ae86bbc7dc 100644 --- a/qa/qa/page/menu/main.rb +++ b/qa/qa/page/menu/main.rb @@ -61,8 +61,13 @@ module QA end 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) { page.has_selector?('.qa-user-avatar') } + using_wait_time(wait) do + 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 private |