diff --git a/app/assets/javascripts/super_sidebar/components/user_bar.vue b/app/assets/javascripts/super_sidebar/components/user_bar.vue index 88ea4d828b75d5857df0ccf2c224757f017fe91d..3c47245a1a6a4c07d051a1e4d688ea8ffc00b1e9 100644 --- a/app/assets/javascripts/super_sidebar/components/user_bar.vue +++ b/app/assets/javascripts/super_sidebar/components/user_bar.vue @@ -115,6 +115,7 @@ export default { <gl-badge v-if="sidebarData.gitlab_com_and_canary" variant="success" + data-testid="canary-badge-link" :href="sidebarData.canary_toggle_com_url" size="sm" > diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb index 1fd0b5b453c2cfbb935fd9ac1b74c271c9d5893d..e528c29bb87eff1bffc4512bcd9c99bb0cfcdb22 100644 --- a/qa/qa/page/main/login.rb +++ b/qa/qa/page/main/login.rb @@ -5,6 +5,7 @@ module Page module Main class Login < Page::Base include Layout::Flash + include Runtime::Canary view 'app/views/devise/passwords/edit.html.haml' do element :password_field @@ -250,7 +251,11 @@ def sign_in_using_gitlab_credentials(user:, skip_page_validation: false) wait_for_gitlab_to_respond - Page::Main::Menu.validate_elements_present! unless skip_page_validation + return if skip_page_validation + + Page::Main::Menu.validate_elements_present! + + # validate_canary! end def fill_in_credential(user) diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb index 73d48c6fcbf1867dcdd77866d4a5bae1a0a8c831..0a023c757ee9c0e34108f001e5baf22728e53542 100644 --- a/qa/qa/page/main/menu.rb +++ b/qa/qa/page/main/menu.rb @@ -14,6 +14,10 @@ class Menu < Page::Base element :navbar, required: true # TODO: rename to sidebar once it's default implementation end + view 'app/assets/javascripts/super_sidebar/components/user_bar.vue' do + element 'canary-badge-link' + end + view 'app/assets/javascripts/super_sidebar/components/user_menu.vue' do element 'user-dropdown', required: !Runtime::Env.phone_layout? element :user_avatar_content, required: !Runtime::Env.phone_layout? @@ -176,13 +180,13 @@ def click_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 + # @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) + has_element?('canary-badge-link') end private diff --git a/qa/qa/runtime/canary.rb b/qa/qa/runtime/canary.rb new file mode 100644 index 0000000000000000000000000000000000000000..9a6b8c0dc8d9e85092aa042053fbd2ae9b6c4119 --- /dev/null +++ b/qa/qa/runtime/canary.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module QA + module Runtime + module Canary + CanaryValidationError = Class.new(StandardError) + + def validate_canary! + return unless QA::Runtime::Env.qa_cookies.to_s.include?("gitlab_canary=true") + + canary_cookie = Capybara.current_session.driver.browser.manage.all_cookies.find do |cookie| + cookie[:name] == 'gitlab_canary' + end + + unless canary_cookie && canary_cookie[:value] == 'true' + raise Canary::CanaryValidationError, + "gitlab_canary=true cookie was expected but not set in browser. QA_COOKIES: #{QA::Runtime::Env.qa_cookies}" + end + + return if Page::Main::Menu.perform(&:canary?) + + raise Canary::CanaryValidationError, + "gitlab_canary=true cookie was set in browser but 'Next' badge was not shown on UI" + end + end + end +end