Commit 2233e27b authored by Dan Davison's avatar Dan Davison

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
parents 6769aab0 d4466ea9
...@@ -24,4 +24,4 @@ ...@@ -24,4 +24,4 @@
- if current_user_menu?(:sign_out) - if current_user_menu?(:sign_out)
%li.divider %li.divider
%li %li
= link_to _("Sign out"), destroy_user_session_path, class: "sign-out-link" = link_to _("Sign out"), destroy_user_session_path, class: "sign-out-link qa-sign-out-link"
...@@ -25,19 +25,10 @@ module QA ...@@ -25,19 +25,10 @@ module QA
end end
end end
def retry_until(max_attempts: 3, reload: false) def retry_until(max_attempts: 3, reload: false, sleep_interval: 0)
attempts = 0 QA::Support::Retrier.retry_until(max_attempts: max_attempts, reload: reload, sleep_interval: sleep_interval) do
yield
while attempts < max_attempts
result = yield
return result if result
refresh if reload
attempts += 1
end end
false
end end
def retry_on_exception(max_attempts: 3, reload: false, sleep_interval: 0.5) def retry_on_exception(max_attempts: 3, reload: false, sleep_interval: 0.5)
......
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
module Main module Main
class Menu < Page::Base class Menu < Page::Base
view 'app/views/layouts/header/_current_user_dropdown.html.haml' do 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 element :settings_link, 'link_to s_("CurrentUser|Settings")' # rubocop:disable QA/ElementWithPattern
end end
...@@ -53,7 +53,7 @@ module QA ...@@ -53,7 +53,7 @@ module QA
def sign_out def sign_out
within_user_menu do within_user_menu do
click_link 'Sign out' click_element :sign_out_link
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
require 'logger' require 'logger'
require 'forwardable'
module QA module QA
module Runtime module Runtime
......
...@@ -11,8 +11,10 @@ module QA ...@@ -11,8 +11,10 @@ module QA
expect(menu).to have_personal_area expect(menu).to have_personal_area
end end
Page::Main::Menu.perform do |menu| Support::Retrier.retry_until(reload: false, sleep_interval: 0.5) do
menu.sign_out Page::Main::Menu.perform(&:sign_out)
Page::Main::Login.perform(&:has_sign_in_tab?)
end end
Page::Main::Login.perform do |form| Page::Main::Login.perform do |form|
......
...@@ -23,6 +23,25 @@ module QA ...@@ -23,6 +23,25 @@ module QA
raise raise
end end
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 end
end end
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