Commit 11fd204f authored by Dan Davison's avatar Dan Davison

Add dataset argument for render_label

General refactor of QA tests
Favor data-qa selector
Add requirements to Snippet::Show page
parent 2302ca66
...@@ -47,11 +47,11 @@ module LabelsHelper ...@@ -47,11 +47,11 @@ module LabelsHelper
end end
end end
def render_label(label, tooltip: true, link: nil, css: nil) def render_label(label, tooltip: true, link: nil, css: nil, dataset: nil)
# if scoped label is used then EE wraps label tag with scoped label # if scoped label is used then EE wraps label tag with scoped label
# doc link # doc link
html = render_colored_label(label, tooltip: tooltip) html = render_colored_label(label, tooltip: tooltip)
html = link_to(html, link, class: css) if link html = link_to(html, link, class: css, data: dataset) if link
html html
end end
......
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
= render_if_exists 'shared/issuable/sidebar_item_epic', issuable_sidebar: issuable_sidebar = render_if_exists 'shared/issuable/sidebar_item_epic', issuable_sidebar: issuable_sidebar
- milestone = issuable_sidebar[:milestone] || {} - milestone = issuable_sidebar[:milestone] || {}
.block.milestone .block.milestone{ data: { qa_selector: 'milestone_block' } }
.sidebar-collapsed-icon.has-tooltip{ title: sidebar_milestone_tooltip_label(milestone), data: { container: 'body', html: 'true', placement: 'left', boundary: 'viewport' } } .sidebar-collapsed-icon.has-tooltip{ title: sidebar_milestone_tooltip_label(milestone), data: { container: 'body', html: 'true', placement: 'left', boundary: 'viewport' } }
= icon('clock-o', 'aria-hidden': 'true') = icon('clock-o', 'aria-hidden': 'true')
%span.milestone-title.collapse-truncated-title %span.milestone-title.collapse-truncated-title{ data: { qa_selector: 'milestone_title' } }
- if milestone.present? - if milestone.present?
= milestone[:title] = milestone[:title]
- else - else
...@@ -107,10 +107,10 @@ ...@@ -107,10 +107,10 @@
= icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true') = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
- if can_edit_issuable - if can_edit_issuable
= link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link qa-edit-link-labels float-right', data: { track_label: "right_sidebar", track_property: "labels", track_event: "click_edit_button", track_value: "" } = link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link qa-edit-link-labels float-right', data: { track_label: "right_sidebar", track_property: "labels", track_event: "click_edit_button", track_value: "" }
.value.issuable-show-labels.dont-hide.hide-collapsed.qa-labels-block{ class: ("has-labels" if selected_labels.any?) } .value.issuable-show-labels.dont-hide.hide-collapsed{ class: ("has-labels" if selected_labels.any?), data: { qa_selector: 'labels_block' } }
- if selected_labels.any? - if selected_labels.any?
- selected_labels.each do |label_hash| - selected_labels.each do |label_hash|
= render_label(label_from_hash(label_hash).present(issuable_subject: nil), link: sidebar_label_filter_path(issuable_sidebar[:project_issuables_path], label_hash[:title])) = render_label(label_from_hash(label_hash).present(issuable_subject: nil), link: sidebar_label_filter_path(issuable_sidebar[:project_issuables_path], label_hash[:title]), dataset: { qa_selector: 'label', qa_label_name: label_hash[:title] })
- else - else
%span.no-value %span.no-value
= _('None') = _('None')
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
= render "snippets/actions" = render "snippets/actions"
.snippet-header.limited-header-width .snippet-header.limited-header-width
%h2.snippet-title.prepend-top-0.mb-3.qa-snippet-title %h2.snippet-title.prepend-top-0.mb-3{ data: { qa_selector: 'snippet_title' } }
= markdown_field(@snippet, :title) = markdown_field(@snippet, :title)
- if @snippet.description.present? - if @snippet.description.present?
.description.qa-snippet-description .description{ data: { qa_selector: 'snippet_description' } }
.md .md
= markdown_field(@snippet, :description) = markdown_field(@snippet, :description)
%textarea.hidden.js-task-list-field %textarea.hidden.js-task-list-field
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module EE module EE
module LabelsHelper module LabelsHelper
def render_label(label, tooltip: true, link: nil, css: nil) def render_label(label, tooltip: true, link: nil, css: nil, dataset: nil)
content = super content = super
content = scoped_label_wrapper(content, label) if label.scoped_label? content = scoped_label_wrapper(content, label) if label.scoped_label?
......
...@@ -6,8 +6,8 @@ module QA ...@@ -6,8 +6,8 @@ module QA
module Snippet module Snippet
class Show < Page::Base class Show < Page::Base
view 'app/views/shared/snippets/_header.html.haml' do view 'app/views/shared/snippets/_header.html.haml' do
element :snippet_title element :snippet_title, required: true
element :snippet_description element :snippet_description, required: true
element :embed_type element :embed_type
element :snippet_box element :snippet_box
end end
...@@ -21,15 +21,11 @@ module QA ...@@ -21,15 +21,11 @@ module QA
end end
def has_snippet_title?(snippet_title) def has_snippet_title?(snippet_title)
within_element(:snippet_title) do has_element? :snippet_title, text: snippet_title
has_text?(snippet_title)
end
end end
def has_snippet_description?(snippet_description) def has_snippet_description?(snippet_description)
within_element(:snippet_description) do has_element? :snippet_description, text: snippet_description
has_text?(snippet_description)
end
end end
def has_embed_type?(embed_type) def has_embed_type?(embed_type)
......
...@@ -5,19 +5,20 @@ module QA ...@@ -5,19 +5,20 @@ module QA
module Issuable module Issuable
class Sidebar < Page::Base class Sidebar < Page::Base
view 'app/views/shared/issuable/_sidebar.html.haml' do view 'app/views/shared/issuable/_sidebar.html.haml' do
element :labels_block, ".issuable-show-labels" # rubocop:disable QA/ElementWithPattern element :labels_block
element :milestones_block, '.block.milestone' # rubocop:disable QA/ElementWithPattern element :milestone_block
element :milestone_title
end end
def has_label?(label) def has_label?(label)
page.within('.issuable-show-labels') do within_element(:labels_block) do
!!find('span', text: label) has_element?(:label, label_name: label)
end end
end end
def has_milestone?(milestone) def has_milestone?(milestone)
page.within('.block.milestone') do within_element(:milestone_block) do
!!find("[href*='/milestones/']", text: milestone) has_element?(:milestone_title, text: milestone)
end end
end end
end end
......
...@@ -122,9 +122,8 @@ module QA ...@@ -122,9 +122,8 @@ module QA
end end
def has_label?(label) def has_label?(label)
page.within(element_selector_css(:labels_block)) do within_element(:labels_block) do
element = find('span', text: label) !!has_element?(:label, label_name: label)
!element.nil?
end end
end end
......
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