Skip to content
代码片段 群组 项目
提交 f5a19b7c 编辑于 作者: Tiffany Rea's avatar Tiffany Rea
浏览文件

Merge branch 'qa-shl-add-validation-for-canary' into 'master'

No related branches found
No related tags found
无相关合并请求
...@@ -115,6 +115,7 @@ export default { ...@@ -115,6 +115,7 @@ export default {
<gl-badge <gl-badge
v-if="sidebarData.gitlab_com_and_canary" v-if="sidebarData.gitlab_com_and_canary"
variant="success" variant="success"
data-testid="canary-badge-link"
:href="sidebarData.canary_toggle_com_url" :href="sidebarData.canary_toggle_com_url"
size="sm" size="sm"
> >
......
...@@ -5,6 +5,7 @@ module Page ...@@ -5,6 +5,7 @@ module Page
module Main module Main
class Login < Page::Base class Login < Page::Base
include Layout::Flash include Layout::Flash
include Runtime::Canary
view 'app/views/devise/passwords/edit.html.haml' do view 'app/views/devise/passwords/edit.html.haml' do
element :password_field element :password_field
...@@ -250,7 +251,11 @@ def sign_in_using_gitlab_credentials(user:, skip_page_validation: false) ...@@ -250,7 +251,11 @@ def sign_in_using_gitlab_credentials(user:, skip_page_validation: false)
wait_for_gitlab_to_respond 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 end
def fill_in_credential(user) def fill_in_credential(user)
......
...@@ -14,6 +14,10 @@ class Menu < Page::Base ...@@ -14,6 +14,10 @@ class Menu < Page::Base
element :navbar, required: true # TODO: rename to sidebar once it's default implementation element :navbar, required: true # TODO: rename to sidebar once it's default implementation
end 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 view 'app/assets/javascripts/super_sidebar/components/user_menu.vue' do
element 'user-dropdown', required: !Runtime::Env.phone_layout? element 'user-dropdown', required: !Runtime::Env.phone_layout?
element :user_avatar_content, required: !Runtime::Env.phone_layout? element :user_avatar_content, required: !Runtime::Env.phone_layout?
...@@ -176,13 +180,13 @@ def click_stop_impersonation_link ...@@ -176,13 +180,13 @@ def click_stop_impersonation_link
end end
# To verify whether the user has been directed to a canary web node # 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: # @example:
# Menu.perform do |menu| # Menu.perform do |menu|
# expect(menu.canary?).to be(true) # expect(menu.canary?).to be(true)
# end # end
def canary? def canary?
has_element?(:canary_badge_link) has_element?('canary-badge-link')
end end
private private
......
# 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
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册