summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qa/qa.rb1
-rw-r--r--qa/qa/page/base.rb17
-rw-r--r--qa/qa/page/project/issue/show.rb19
-rw-r--r--qa/qa/support/retrier.rb28
4 files changed, 48 insertions, 17 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index 8c5411d3f6b..d6dcfa3032b 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -367,6 +367,7 @@ module QA
end
autoload :Api, 'qa/support/api'
autoload :Waiter, 'qa/support/waiter'
+ autoload :Retrier, 'qa/support/retrier'
end
end
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb
index 01ac161d26d..05e38aba77d 100644
--- a/qa/qa/page/base.rb
+++ b/qa/qa/page/base.rb
@@ -39,18 +39,9 @@ module QA
false
end
- def retry_on_exception(max_attempts: 3, reload: false, sleep_interval: 0.0)
- attempts = 0
-
- begin
+ def retry_on_exception(max_attempts: 3, reload: false, sleep_interval: 0.5)
+ QA::Support::Retrier.retry_on_exception(max_attempts: max_attempts, reload_page: (reload && self), sleep_interval: sleep_interval) do
yield
- rescue StandardError
- sleep sleep_interval
- refresh if reload
- attempts += 1
-
- retry if attempts < max_attempts
- raise
end
end
@@ -162,6 +153,10 @@ module QA
click_link text
end
+ def click_body
+ find('body').click
+ end
+
def self.path
raise NotImplementedError
end
diff --git a/qa/qa/page/project/issue/show.rb b/qa/qa/page/project/issue/show.rb
index 1028cc045a0..1c25be5fd0c 100644
--- a/qa/qa/page/project/issue/show.rb
+++ b/qa/qa/page/project/issue/show.rb
@@ -37,18 +37,25 @@ module QA
end
def select_comments_only_filter
- click_element :discussion_filter
- find_element(:filter_options, "Show comments only").click
+ select_filter_with_text('Show comments only')
end
def select_history_only_filter
- click_element :discussion_filter
- find_element(:filter_options, "Show history only").click
+ select_filter_with_text('Show history only')
end
def select_all_activities_filter
- click_element :discussion_filter
- find_element(:filter_options, "Show all activity").click
+ select_filter_with_text('Show all activity')
+ end
+
+ private
+
+ def select_filter_with_text(text)
+ retry_on_exception do
+ click_body
+ click_element :discussion_filter
+ find_element(:filter_options, text).click
+ end
end
end
end
diff --git a/qa/qa/support/retrier.rb b/qa/qa/support/retrier.rb
new file mode 100644
index 00000000000..8be4e9f5365
--- /dev/null
+++ b/qa/qa/support/retrier.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module QA
+ module Support
+ module Retrier
+ module_function
+
+ def retry_on_exception(max_attempts: 3, reload_page: nil, sleep_interval: 0.5)
+ QA::Runtime::Logger.debug("with retry_on_exception: max_attempts #{max_attempts}; sleep_interval #{sleep_interval}")
+
+ attempts = 0
+
+ begin
+ QA::Runtime::Logger.debug("Attempt number #{attempts + 1}")
+ yield
+ rescue StandardError, RSpec::Expectations::ExpectationNotMetError
+ sleep sleep_interval
+ reload_page.refresh if reload_page
+ attempts += 1
+
+ retry if attempts < max_attempts
+ QA::Runtime::Logger.debug("Raising exception after #{max_attempts} attempts")
+ raise
+ end
+ end
+ end
+ end
+end