Commit e2a56bd1 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'qa-ml-check-server-in-before-hook' into 'master'

[QA-CE] Move server responding check to scenario before hook

See merge request gitlab-org/gitlab-ce!25257
parents 701303a5 e5e57df6
...@@ -8,7 +8,10 @@ module QA ...@@ -8,7 +8,10 @@ module QA
end end
def perform_before_hooks def perform_before_hooks
# noop # The login page could take some time to load the first time it is visited.
# We visit the login page and wait for it to properly load only once before the tests.
QA::Runtime::Browser.visit(:gitlab, QA::Page::Main::Login)
QA::Page::Main::Login.perform(&:assert_page_loaded)
end end
end end
end end
......
...@@ -40,6 +40,12 @@ module QA ...@@ -40,6 +40,12 @@ module QA
element :login_page element :login_page
end end
def assert_page_loaded
unless page_loaded?
raise QA::Runtime::Browser::NotRespondingError, "Login page did not load at #{QA::Page::Main::Login.perform(&:current_url)}"
end
end
def page_loaded? def page_loaded?
wait(max: 60) do wait(max: 60) do
has_element?(:login_page) has_element?(:login_page)
......
...@@ -8,6 +8,8 @@ module QA ...@@ -8,6 +8,8 @@ module QA
class Browser class Browser
include QA::Scenario::Actable include QA::Scenario::Actable
NotRespondingError = Class.new(RuntimeError)
def initialize def initialize
self.class.configure! self.class.configure!
end end
......
...@@ -5,20 +5,6 @@ require_relative '../qa' ...@@ -5,20 +5,6 @@ require_relative '../qa'
end end
RSpec.configure do |config| RSpec.configure do |config|
ServerNotRespondingError = Class.new(RuntimeError)
# The login page could take some time to load the first time it is visited.
# We visit the login page and wait for it to properly load only once at the beginning of the suite.
config.before(:suite) do
if QA::Runtime::Scenario.respond_to?(:gitlab_address)
QA::Runtime::Browser.visit(:gitlab, QA::Page::Main::Login)
unless QA::Page::Main::Login.perform(&:page_loaded?)
raise ServerNotRespondingError, "Login page did not load at #{QA::Page::Main::Login.perform(&:current_url)}"
end
end
end
config.before(:context) do config.before(:context) do
if self.class.metadata.keys.include?(:quarantine) if self.class.metadata.keys.include?(:quarantine)
skip_or_run_quarantined_tests(self.class.metadata.keys, config.inclusion_filter.rules.keys) skip_or_run_quarantined_tests(self.class.metadata.keys, config.inclusion_filter.rules.keys)
......
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