Commit 7337810f authored by Mark Lapierre's avatar Mark Lapierre

Move server responding check to scenario before hook

This checks that the server is responding before any other actions,
including before trying to add a license.
parent c5b892f8
......@@ -8,7 +8,10 @@ module QA
end
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
......
......@@ -11,6 +11,10 @@ module QA
return unless ENV['EE_LICENSE']
QA::Runtime::Browser.visit(:gitlab, QA::Page::Main::Login) do
# 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::Page::Main::Login.perform(&:assert_page_loaded)
EE::Resource::License.fabricate!(ENV['EE_LICENSE'])
end
end
......
......@@ -40,6 +40,12 @@ module QA
element :login_page
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?
wait(max: 60) do
has_element?(:login_page)
......
......@@ -9,6 +9,8 @@ module QA
class Browser
include QA::Scenario::Actable
NotRespondingError = Class.new(RuntimeError)
def initialize
self.class.configure!
end
......
......@@ -5,20 +5,6 @@ require_relative '../qa'
end
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
if self.class.metadata.keys.include?(:quarantine)
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