diff options
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/page/main/menu.rb | 11 | ||||
-rw-r--r-- | qa/qa/runtime/browser.rb | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb index 760741a9630..ad5cd971afc 100644 --- a/qa/qa/page/main/menu.rb +++ b/qa/qa/page/main/menu.rb @@ -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) diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb index 370c05edb86..f208a93d302 100644 --- a/qa/qa/runtime/browser.rb +++ b/qa/qa/runtime/browser.rb @@ -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. # |