Commit 47b68e87 authored by Dan Davison's avatar Dan Davison

Merge branch 'qa-fix-label-selectors-for-vue' into 'master'

Updates e2e tests to use vue selectors for labels

See merge request gitlab-org/gitlab!43214
parents 0137ae41 7a992607
...@@ -89,6 +89,7 @@ export default { ...@@ -89,6 +89,7 @@ export default {
:labels-select-in-progress="labelsSelectInProgress" :labels-select-in-progress="labelsSelectInProgress"
:selected-labels="selectedLabels" :selected-labels="selectedLabels"
:variant="$options.sidebar" :variant="$options.sidebar"
data-qa-selector="labels_block"
@onDropdownClose="handleDropdownClose" @onDropdownClose="handleDropdownClose"
@updateSelectedLabels="handleUpdateSelectedLabels" @updateSelectedLabels="handleUpdateSelectedLabels"
> >
......
...@@ -38,6 +38,7 @@ export default { ...@@ -38,6 +38,7 @@ export default {
<template> <template>
<div <div
class="labels-select-dropdown-contents w-100 mt-1 mb-3 py-2 rounded-top rounded-bottom position-absolute" class="labels-select-dropdown-contents w-100 mt-1 mb-3 py-2 rounded-top rounded-bottom position-absolute"
data-qa-selector="labels_dropdown_content"
:style="directionStyle" :style="directionStyle"
> >
<component :is="dropdownContentsView" /> <component :is="dropdownContentsView" />
......
...@@ -156,7 +156,11 @@ export default { ...@@ -156,7 +156,11 @@ export default {
/> />
</div> </div>
<div class="dropdown-input" @click.stop="() => {}"> <div class="dropdown-input" @click.stop="() => {}">
<gl-search-box-by-type v-model="searchKey" :autofocus="true" /> <gl-search-box-by-type
v-model="searchKey"
:autofocus="true"
data-qa-selector="dropdown_input_field"
/>
</div> </div>
<div <div
v-show="showListContainer" v-show="showListContainer"
......
...@@ -35,6 +35,8 @@ export default { ...@@ -35,6 +35,8 @@ export default {
<template v-for="label in selectedLabels" v-else> <template v-for="label in selectedLabels" v-else>
<gl-label <gl-label
:key="label.id" :key="label.id"
data-qa-selector="selected_label_content"
:data-qa-label-name="label.title"
:title="label.title" :title="label.title"
:description="label.description" :description="label.description"
:background-color="label.color" :background-color="label.color"
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
selected_labels: issuable_sidebar[:labels].to_json } } selected_labels: issuable_sidebar[:labels].to_json } }
- else - else
- selected_labels = issuable_sidebar[:labels] - selected_labels = issuable_sidebar[:labels]
.block.labels .block.labels{ data: { qa_selector: 'labels_block' } }
.sidebar-collapsed-icon.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(selected_labels), data: { placement: "left", container: "body", boundary: 'viewport' } } .sidebar-collapsed-icon.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(selected_labels), data: { placement: "left", container: "body", boundary: 'viewport' } }
= sprite_icon('labels') = sprite_icon('labels')
%span %span
...@@ -125,11 +125,11 @@ ...@@ -125,11 +125,11 @@
= _('Labels') = _('Labels')
= loading_icon(css_class: 'gl-vertical-align-text-bottom hidden block-loading') = loading_icon(css_class: 'gl-vertical-align-text-bottom hidden block-loading')
- if can_edit_issuable - if can_edit_issuable
= link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link float-right', data: { qa_selector: "edit_labels_link", track_label: "right_sidebar", track_property: "labels", track_event: "click_edit_button", track_value: "" } = link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link float-right', data: { qa_selector: "labels_edit_button", track_label: "right_sidebar", track_property: "labels", track_event: "click_edit_button", track_value: "" }
.value.issuable-show-labels.dont-hide.hide-collapsed{ class: ("has-labels" if selected_labels.any?), data: { qa_selector: 'labels_block' } } .value.issuable-show-labels.dont-hide.hide-collapsed{ class: ("has-labels" if selected_labels.any?) }
- 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]), dataset: { qa_selector: 'label', qa_label_name: 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: 'selected_label_content', qa_label_name: label_hash[:title] })
- else - else
%span.no-value %span.no-value
= _('None') = _('None')
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
%span.dropdown-toggle-text{ class: ("is-default" if selected_labels.empty?) } %span.dropdown-toggle-text{ class: ("is-default" if selected_labels.empty?) }
= multi_label_name(selected_labels, "Labels") = multi_label_name(selected_labels, "Labels")
= icon('chevron-down', 'aria-hidden': 'true') = icon('chevron-down', 'aria-hidden': 'true')
.dropdown-menu.dropdown-select.dropdown-menu-paging.qa-dropdown-menu-labels.dropdown-menu-labels.dropdown-menu-selectable.dropdown-extended-height .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable.dropdown-extended-height{ data: { qa_selector: "labels_dropdown_content"} }
= render partial: "shared/issuable/label_page_default" = render partial: "shared/issuable/label_page_default"
- if issuable_sidebar.dig(:current_user, :can_admin_label) - if issuable_sidebar.dig(:current_user, :can_admin_label)
= render partial: "shared/issuable/label_page_create" = render partial: "shared/issuable/label_page_create"
......
...@@ -18,16 +18,29 @@ module QA ...@@ -18,16 +18,29 @@ module QA
element :more_assignees_link element :more_assignees_link
end end
base.view 'app/helpers/dropdowns_helper.rb' do base.view 'app/assets/javascripts/sidebar/components/labels/sidebar_labels.vue' do
element :labels_block
end
base.view 'app/assets/javascripts/vue_shared/components/sidebar/labels_select_vue/dropdown_value.vue' do
element :selected_label_content
end
base.view 'app/assets/javascripts/vue_shared/components/sidebar/labels_select_vue/dropdown_contents.vue' do
element :labels_dropdown_content
end
base.view 'app/assets/javascripts/vue_shared/components/sidebar/labels_select/dropdown_title.vue' do
element :labels_edit_button
end
base.view 'app/assets/javascripts/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view.vue' do
element :dropdown_input_field element :dropdown_input_field
end end
base.view 'app/views/shared/issuable/_sidebar.html.haml' do base.view 'app/views/shared/issuable/_sidebar.html.haml' do
element :assignee_block element :assignee_block
element :dropdown_menu_labels
element :edit_labels_link
element :edit_milestone_link element :edit_milestone_link
element :labels_block
element :milestone_block element :milestone_block
element :milestone_link element :milestone_link
end end
...@@ -64,7 +77,7 @@ module QA ...@@ -64,7 +77,7 @@ module QA
def has_label?(label) def has_label?(label)
within_element(:labels_block) do within_element(:labels_block) do
!!has_element?(:label, label_name: label) !!has_element?(:selected_label_content, label_name: label)
end end
end end
...@@ -80,23 +93,25 @@ module QA ...@@ -80,23 +93,25 @@ module QA
def select_labels_and_refresh(labels) def select_labels_and_refresh(labels)
Support::Retrier.retry_until do Support::Retrier.retry_until do
click_element(:edit_labels_link) click_element(:labels_edit_button)
has_element?(:dropdown_menu_labels, text: labels.first) has_element?(:labels_dropdown_content, text: labels.first)
end end
labels.each do |label| labels.each do |label|
within_element(:dropdown_menu_labels, text: label) do within_element(:labels_dropdown_content) do
send_keys_to_element(:dropdown_input_field, [label, :enter]) send_keys_to_element(:dropdown_input_field, [label, :enter])
end end
end end
click_element(:edit_labels_link) click_element(:labels_edit_button)
labels.each do |label| labels.each do |label|
has_element?(:labels_block, text: label, wait: 0) has_element?(:labels_block, text: label, wait: 0)
end end
refresh refresh
wait_for_requests
end end
def toggle_more_assignees_link def toggle_more_assignees_link
......
...@@ -29,7 +29,7 @@ module QA ...@@ -29,7 +29,7 @@ module QA
end end
end end
it 'creates a merge request with a milestone and label', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/514', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/254988', type: :stale } do it 'creates a merge request with a milestone and label', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/514' do
gitlab_account_username = "@#{Runtime::User.username}" gitlab_account_username = "@#{Runtime::User.username}"
milestone = Resource::ProjectMilestone.fabricate_via_api! do |milestone| milestone = Resource::ProjectMilestone.fabricate_via_api! do |milestone|
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
RSpec.describe 'Plan', :reliable do RSpec.describe 'Plan' do
describe 'Editing scoped labels on issues' do describe 'Editing scoped labels on issues' do
let(:initial_label) { 'animal::fox' } let(:initial_label) { 'animal::fox' }
let(:new_label_same_scope) { 'animal::dolphin' } let(:new_label_same_scope) { 'animal::dolphin' }
...@@ -33,7 +33,7 @@ module QA ...@@ -33,7 +33,7 @@ module QA
issue.visit! issue.visit!
end end
it 'correctly applies simple and multiple colon scoped pairs labels', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/595', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/254960', type: :stale } do it 'correctly applies simple and multiple colon scoped pairs labels', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/595' do
Page::Project::Issue::Show.perform do |show| Page::Project::Issue::Show.perform do |show|
show.select_labels_and_refresh([ show.select_labels_and_refresh([
new_label_same_scope, new_label_same_scope,
...@@ -42,15 +42,15 @@ module QA ...@@ -42,15 +42,15 @@ module QA
new_label_different_scope_multi_colon new_label_different_scope_multi_colon
]) ])
show.select_all_activities_filter aggregate_failures do
expect(show).to have_label(new_label_same_scope)
expect(show).to have_label(new_label_different_scope)
expect(show).to have_label(new_label_same_scope_multi_colon)
expect(show).to have_label(new_label_different_scope_multi_colon)
expect(show).to have_label(new_label_same_scope) expect(show).not_to have_label(initial_label)
expect(show).to have_label(new_label_different_scope) expect(show).not_to have_label(initial_label_multi_colon)
expect(show).to have_label('group::car::porsche') end
expect(show).to have_label('group::truck::mercedes-bens')
expect(show).not_to have_label(initial_label)
expect(show).not_to have_label('group::car::ferrari')
end end
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