diff options
author | Dan Davison <ddavison@gitlab.com> | 2019-07-10 21:47:08 +0000 |
---|---|---|
committer | Dan Davison <ddavison@gitlab.com> | 2019-07-10 21:47:08 +0000 |
commit | 2233e27b31b37d43ca8116ebc31a21dc09b190db (patch) | |
tree | 9802efefaa058bc8c42c3e8279116523a0c8ce12 /qa | |
parent | 6769aab08af1602905b82604ea26cc3bd758c5c2 (diff) | |
parent | d4466ea970480d6e494190bd25a6d195882d57f5 (diff) | |
download | gitlab-ce-2233e27b31b37d43ca8116ebc31a21dc09b190db.tar.gz |
Merge branch 'sl-stablise-basic-login-spec' into 'master'
Fix basic login test stability
Closes gitlab-org/quality/staging#57
See merge request gitlab-org/gitlab-ce!30446
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/page/base.rb | 15 | ||||
-rw-r--r-- | qa/qa/page/main/menu.rb | 4 | ||||
-rw-r--r-- | qa/qa/runtime/logger.rb | 1 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb | 6 | ||||
-rw-r--r-- | qa/qa/support/retrier.rb | 19 |
5 files changed, 29 insertions, 16 deletions
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index d0fe2987b0a..130e5e33ab4 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -25,19 +25,10 @@ module QA end end - def retry_until(max_attempts: 3, reload: false) - attempts = 0 - - while attempts < max_attempts - result = yield - return result if result - - refresh if reload - - attempts += 1 + def retry_until(max_attempts: 3, reload: false, sleep_interval: 0) + QA::Support::Retrier.retry_until(max_attempts: max_attempts, reload: reload, sleep_interval: sleep_interval) do + yield end - - false end def retry_on_exception(max_attempts: 3, reload: false, sleep_interval: 0.5) diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb index 5eb24d2d2ba..9c99e43d4c0 100644 --- a/qa/qa/page/main/menu.rb +++ b/qa/qa/page/main/menu.rb @@ -5,7 +5,7 @@ module QA module Main class Menu < Page::Base view 'app/views/layouts/header/_current_user_dropdown.html.haml' do - element :user_sign_out_link, 'link_to _("Sign out")' # rubocop:disable QA/ElementWithPattern + element :sign_out_link element :settings_link, 'link_to s_("CurrentUser|Settings")' # rubocop:disable QA/ElementWithPattern end @@ -53,7 +53,7 @@ module QA def sign_out within_user_menu do - click_link 'Sign out' + click_element :sign_out_link end end diff --git a/qa/qa/runtime/logger.rb b/qa/qa/runtime/logger.rb index bd5c4fe5bf5..7f73f1bd01b 100644 --- a/qa/qa/runtime/logger.rb +++ b/qa/qa/runtime/logger.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'logger' +require 'forwardable' module QA module Runtime diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb index cf225a639b6..5cd6bac3f5a 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb @@ -11,8 +11,10 @@ module QA expect(menu).to have_personal_area end - Page::Main::Menu.perform do |menu| - menu.sign_out + Support::Retrier.retry_until(reload: false, sleep_interval: 0.5) do + Page::Main::Menu.perform(&:sign_out) + + Page::Main::Login.perform(&:has_sign_in_tab?) end Page::Main::Login.perform do |form| diff --git a/qa/qa/support/retrier.rb b/qa/qa/support/retrier.rb index 8be4e9f5365..230cec8f8d2 100644 --- a/qa/qa/support/retrier.rb +++ b/qa/qa/support/retrier.rb @@ -23,6 +23,25 @@ module QA raise end end + + def retry_until(max_attempts: 3, reload: false, sleep_interval: 0) + QA::Runtime::Logger.debug("with retry_until: max_attempts #{max_attempts}; sleep_interval #{sleep_interval}; reload:#{reload}") + attempts = 0 + + while attempts < max_attempts + QA::Runtime::Logger.debug("Attempt number #{attempts + 1}") + result = yield + return result if result + + sleep sleep_interval + + refresh if reload + + attempts += 1 + end + + false + end end end end |