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
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
# doc link
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
end
......
......@@ -30,10 +30,10 @@
= render_if_exists 'shared/issuable/sidebar_item_epic', issuable_sidebar: issuable_sidebar
- 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' } }
= 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?
= milestone[:title]
- else
......@@ -107,10 +107,10 @@
= icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
- 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: "" }
.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?
- 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
%span.no-value
= _('None')
......
......@@ -17,11 +17,11 @@
= render "snippets/actions"
.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)
- if @snippet.description.present?
.description.qa-snippet-description
.description{ data: { qa_selector: 'snippet_description' } }
.md
= markdown_field(@snippet, :description)
%textarea.hidden.js-task-list-field
......
......@@ -2,7 +2,7 @@
module EE
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 = scoped_label_wrapper(content, label) if label.scoped_label?
......
......@@ -6,8 +6,8 @@ module QA
module Snippet
class Show < Page::Base
view 'app/views/shared/snippets/_header.html.haml' do
element :snippet_title
element :snippet_description
element :snippet_title, required: true
element :snippet_description, required: true
element :embed_type
element :snippet_box
end
......@@ -21,15 +21,11 @@ module QA
end
def has_snippet_title?(snippet_title)
within_element(:snippet_title) do
has_text?(snippet_title)
end
has_element? :snippet_title, text: snippet_title
end
def has_snippet_description?(snippet_description)
within_element(:snippet_description) do
has_text?(snippet_description)
end
has_element? :snippet_description, text: snippet_description
end
def has_embed_type?(embed_type)
......
......@@ -5,19 +5,20 @@ module QA
module Issuable
class Sidebar < Page::Base
view 'app/views/shared/issuable/_sidebar.html.haml' do
element :labels_block, ".issuable-show-labels" # rubocop:disable QA/ElementWithPattern
element :milestones_block, '.block.milestone' # rubocop:disable QA/ElementWithPattern
element :labels_block
element :milestone_block
element :milestone_title
end
def has_label?(label)
page.within('.issuable-show-labels') do
!!find('span', text: label)
within_element(:labels_block) do
has_element?(:label, label_name: label)
end
end
def has_milestone?(milestone)
page.within('.block.milestone') do
!!find("[href*='/milestones/']", text: milestone)
within_element(:milestone_block) do
has_element?(:milestone_title, text: milestone)
end
end
end
......
......@@ -122,9 +122,8 @@ module QA
end
def has_label?(label)
page.within(element_selector_css(:labels_block)) do
element = find('span', text: label)
!element.nil?
within_element(:labels_block) do
!!has_element?(:label, label_name: label)
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