diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-15 09:10:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-15 09:10:57 +0300 |
commit | 034e7d969a591605267c0e5ddbe6f2228bf8e43d (patch) | |
tree | 408e33f34a634187a765ee7d208a55d27bcbd770 /qa | |
parent | 26c3184b621c4349997b1fade462c3fb480ad976 (diff) |
Add latest changes from gitlab-org/gitlab@master
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. # |