Commit 9bcb0239 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'zm-target-canary' into 'master'

Enable canary switching during spec execution

See merge request gitlab-org/gitlab!69421
parents 4005df9a 7a197c32
......@@ -15,7 +15,7 @@
%span.logo-text.d-none.d-lg-block.gl-ml-3
= logo_text
- if Gitlab.com_and_canary?
= link_to 'https://next.gitlab.com', class: 'canary-badge bg-transparent', target: :_blank, rel: :_noopener do
= link_to 'https://next.gitlab.com', class: 'canary-badge bg-transparent', data: { qa_selector: 'canary_badge_link' }, target: :_blank, rel: :_noopener do
%span.gl-badge.gl-bg-green-500.gl-text-white.gl-rounded-pill.gl-font-weight-bold.gl-py-1
= _('Next')
......
......@@ -11,6 +11,7 @@ module QA
view 'app/views/layouts/header/_default.html.haml' do
element :navbar, required: true
element :canary_badge_link
element :user_avatar, required: true
element :user_menu, required: true
element :stop_impersonation_link
......@@ -168,6 +169,16 @@ module QA
click_element(:stop_impersonation_link)
end
# To verify whether the user has been directed to a canary web node
# @return [Boolean] result of checking existence of :canary_badge_link element
# @example:
# Menu.perform do |menu|
# expect(menu.canary?).to be(true)
# end
def canary?
has_element?(:canary_badge_link)
end
private
def within_top_menu(&block)
......
......@@ -219,6 +219,26 @@ module QA
yield.tap { clear! } if block_given?
end
# To redirect the browser to a canary or non-canary web node
# after loading a subject test page
# @param [Boolean] Send to canary true or false
# @example:
# Runtime::Browser::Session.target_canary(true)
def self.target_canary(enable_canary)
if QA::Runtime::Env.qa_cookies.to_s.include?("gitlab_canary=true")
QA::Runtime::Logger.warn("WARNING: Setting cookie through QA_COOKIES var is incompatible with this method.")
return
end
browser = Capybara.current_session.driver.browser
if enable_canary
browser.manage.add_cookie name: "gitlab_canary", value: "true"
else
browser.manage.delete_cookie("gitlab_canary")
end
end
##
# Selenium allows to reset session cookies for current domain only.
#
......
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