debian-mirror-gitlab/spec/features/labels_hierarchy_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

271 lines
8.8 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Labels Hierarchy', :js, feature_category: :team_planning do
2018-05-09 12:01:36 +05:30
include FilteredSearchHelpers
let!(:user) { create(:user) }
let!(:grandparent) { create(:group) }
let!(:parent) { create(:group, parent: grandparent) }
let!(:child) { create(:group, parent: parent) }
let!(:project_1) { create(:project, namespace: parent) }
let!(:grandparent_group_label) { create(:group_label, group: grandparent, title: 'Label_1') }
let!(:parent_group_label) { create(:group_label, group: parent, title: 'Label_2') }
let!(:child_group_label) { create(:group_label, group: child, title: 'Label_3') }
let!(:project_label_1) { create(:label, project: project_1, title: 'Label_4') }
before do
2023-03-04 22:38:38 +05:30
stub_feature_flags(or_issuable_queries: false)
2018-05-09 12:01:36 +05:30
grandparent.add_owner(user)
sign_in(user)
end
shared_examples 'assigning labels from sidebar' do
2021-10-27 15:23:28 +05:30
it 'can assign all ancestors labels' do
2018-05-09 12:01:36 +05:30
[grandparent_group_label, parent_group_label, project_label_1].each do |label|
page.within('.block.labels') do
2021-10-27 15:23:28 +05:30
click_on 'Edit'
2018-05-09 12:01:36 +05:30
2022-01-26 12:08:38 +05:30
wait_for_requests
2018-05-09 12:01:36 +05:30
2022-01-26 12:08:38 +05:30
click_on label.title
click_on 'Close'
end
2018-05-09 12:01:36 +05:30
2021-10-27 15:23:28 +05:30
expect(page).to have_selector('.gl-label', text: label.title)
2018-05-09 12:01:36 +05:30
end
end
it 'does not find child group labels on dropdown' do
page.within('.block.labels') do
2020-11-24 15:15:51 +05:30
click_on 'Edit'
2018-05-09 12:01:36 +05:30
2020-11-24 15:15:51 +05:30
expect(page).not_to have_text(child_group_label.title)
end
2018-05-09 12:01:36 +05:30
end
end
shared_examples 'filtering by ancestor labels for projects' do |board = false|
it 'filters by ancestor labels' do
[grandparent_group_label, parent_group_label, project_label_1].each do |label|
if board
2022-07-16 23:28:13 +05:30
select_label_on_dropdown(label.title)
2018-11-08 19:23:39 +05:30
expect(page).to have_selector('.board-card-title') do |card|
2018-05-09 12:01:36 +05:30
expect(card).to have_selector('a', text: labeled_issue.title)
end
else
2022-07-16 23:28:13 +05:30
within '[data-testid="filtered-search-input"]' do
click_filtered_search_bar
click_on 'Label'
click_on '= is'
click_on label.title
send_keys :enter
end
2018-05-09 12:01:36 +05:30
expect_issues_list_count(1)
2022-01-26 12:08:38 +05:30
expect(page).to have_selector('.issue-title', text: labeled_issue.title)
2018-05-09 12:01:36 +05:30
end
end
end
it 'does not filter by descendant group labels' do
2022-07-16 23:28:13 +05:30
if board
filtered_search.set("label=")
else
select_tokens 'Label', '='
end
2018-05-09 12:01:36 +05:30
2022-01-26 12:08:38 +05:30
expect(page).not_to have_link child_group_label.title
2018-05-09 12:01:36 +05:30
end
end
shared_examples 'filtering by ancestor labels for groups' do |board = false|
let(:project_2) { create(:project, namespace: parent) }
let!(:project_label_2) { create(:label, project: project_2, title: 'Label_4') }
let(:project_3) { create(:project, namespace: child) }
let!(:group_label_3) { create(:group_label, group: child, title: 'Label_5') }
let!(:project_label_3) { create(:label, project: project_3, title: 'Label_6') }
let!(:labeled_issue_2) { create(:labeled_issue, project: project_2, labels: [grandparent_group_label, parent_group_label, project_label_2]) }
let!(:labeled_issue_3) { create(:labeled_issue, project: project_3, labels: [grandparent_group_label, parent_group_label, group_label_3]) }
let!(:issue_2) { create(:issue, project: project_2) }
it 'filters by ancestors and current group labels' do
[grandparent_group_label, parent_group_label].each do |label|
if board
2022-07-16 23:28:13 +05:30
select_label_on_dropdown(label.title)
2018-11-08 19:23:39 +05:30
expect(page).to have_selector('.board-card-title') do |card|
2018-05-09 12:01:36 +05:30
expect(card).to have_selector('a', text: labeled_issue.title)
end
2018-11-08 19:23:39 +05:30
expect(page).to have_selector('.board-card-title') do |card|
2018-05-09 12:01:36 +05:30
expect(card).to have_selector('a', text: labeled_issue_2.title)
end
else
2022-07-16 23:28:13 +05:30
within '[data-testid="filtered-search-input"]' do
click_filtered_search_bar
click_on 'Label'
click_on '= is'
click_on label.title
send_keys :enter
end
2018-05-09 12:01:36 +05:30
expect_issues_list_count(3)
2022-01-26 12:08:38 +05:30
expect(page).to have_selector('.issue-title', text: labeled_issue.title)
expect(page).to have_selector('.issue-title', text: labeled_issue_2.title)
expect(page).to have_selector('.issue-title', text: labeled_issue_3.title)
2018-05-09 12:01:36 +05:30
end
end
end
it 'filters by descendant group labels' do
if board
2022-07-16 23:28:13 +05:30
select_label_on_dropdown(group_label_3.title)
2018-11-08 19:23:39 +05:30
expect(page).to have_selector('.board-card-title') do |card|
2018-05-09 12:01:36 +05:30
expect(card).not_to have_selector('a', text: labeled_issue_2.title)
end
2018-11-08 19:23:39 +05:30
expect(page).to have_selector('.board-card-title') do |card|
2018-05-09 12:01:36 +05:30
expect(card).to have_selector('a', text: labeled_issue_3.title)
end
else
2022-07-16 23:28:13 +05:30
select_tokens 'Label', '=', group_label_3.title, submit: true
2018-05-09 12:01:36 +05:30
expect_issues_list_count(1)
2022-01-26 12:08:38 +05:30
expect(page).to have_selector('.issue-title', text: labeled_issue_3.title)
2018-05-09 12:01:36 +05:30
end
end
it 'does not filter by descendant group project labels' do
2022-07-16 23:28:13 +05:30
if board
filtered_search.set("label=")
2018-05-09 12:01:36 +05:30
2022-07-16 23:28:13 +05:30
expect(page).not_to have_selector('.btn-link', text: project_label_3.title)
else
select_tokens 'Label', '='
2018-05-09 12:01:36 +05:30
2022-07-16 23:28:13 +05:30
expect(page).not_to have_link project_label_3.title
end
2018-05-09 12:01:36 +05:30
end
end
2023-07-09 08:55:56 +05:30
context 'with the visible_label_selection_on_metadata feature flag enabled' do
2018-05-09 12:01:36 +05:30
before do
2023-07-09 08:55:56 +05:30
stub_feature_flags(visible_label_selection_on_metadata: true)
2018-05-09 12:01:36 +05:30
end
2023-07-09 08:55:56 +05:30
context 'when creating new issuable' do
before do
visit new_project_issue_path(project_1)
end
it 'is able to assign ancestor group labels' do
fill_in 'issue_title', with: 'new created issue'
fill_in 'issue_description', with: 'new issue description'
click_button _('Select label')
wait_for_all_requests
page.within '[data-testid="sidebar-labels"]' do
click_button grandparent_group_label.title
click_button parent_group_label.title
click_button project_label_1.title
click_button _('Close')
wait_for_requests
end
find('.btn-confirm').click
expect(page.find('.issue-details h1.title')).to have_content('new created issue')
expect(page).to have_selector('span.gl-label-text', text: grandparent_group_label.title)
expect(page).to have_selector('span.gl-label-text', text: parent_group_label.title)
expect(page).to have_selector('span.gl-label-text', text: project_label_1.title)
end
end
end
context 'with the visible_label_selection_on_metadata feature flag disabled' do
before do
stub_feature_flags(visible_label_selection_on_metadata: false)
end
context 'when creating new issuable' do
before do
visit new_project_issue_path(project_1)
end
2018-05-09 12:01:36 +05:30
2023-07-09 08:55:56 +05:30
it 'is able to assign ancestor group labels' do
fill_in 'issue_title', with: 'new created issue'
fill_in 'issue_description', with: 'new issue description'
2018-05-09 12:01:36 +05:30
2023-07-09 08:55:56 +05:30
find(".js-label-select").click
wait_for_requests
2018-05-09 12:01:36 +05:30
2023-07-09 08:55:56 +05:30
find('a.label-item', text: grandparent_group_label.title).click
find('a.label-item', text: parent_group_label.title).click
find('a.label-item', text: project_label_1.title).click
2018-05-09 12:01:36 +05:30
2023-07-09 08:55:56 +05:30
find('.btn-confirm').click
expect(page.find('.issue-details h1.title')).to have_content('new created issue')
expect(page).to have_selector('span.gl-label-text', text: grandparent_group_label.title)
expect(page).to have_selector('span.gl-label-text', text: parent_group_label.title)
expect(page).to have_selector('span.gl-label-text', text: project_label_1.title)
end
2018-05-09 12:01:36 +05:30
end
end
context 'issuable sidebar' do
let!(:issue) { create(:issue, project: project_1) }
context 'on issue sidebar' do
before do
project_1.add_developer(user)
visit project_issue_path(project_1, issue)
end
it_behaves_like 'assigning labels from sidebar'
end
end
context 'issuable filtering' do
let!(:labeled_issue) { create(:labeled_issue, project: project_1, labels: [grandparent_group_label, parent_group_label, project_label_1]) }
let!(:issue) { create(:issue, project: project_1) }
context 'on project issuable list' do
before do
project_1.add_developer(user)
visit project_issues_path(project_1)
end
it_behaves_like 'filtering by ancestor labels for projects'
it 'does not filter by descendant group labels' do
2022-07-16 23:28:13 +05:30
select_tokens 'Label', '='
2018-05-09 12:01:36 +05:30
2022-01-26 12:08:38 +05:30
expect(page).not_to have_link child_group_label.title
2018-05-09 12:01:36 +05:30
end
end
context 'on group issuable list' do
before do
visit issues_group_path(parent)
end
it_behaves_like 'filtering by ancestor labels for groups'
end
end
end