2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-04 15:40:29 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2019-07-24 09:20:54 +00:00
|
|
|
describe 'Labels Hierarchy', :js do
|
2018-04-04 15:40:29 +00:00
|
|
|
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
|
|
|
|
grandparent.add_owner(user)
|
|
|
|
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'assigning labels from sidebar' do
|
2019-04-09 11:57:40 +00:00
|
|
|
it 'can assign all ancestors labels', :quarantine do
|
2018-04-04 15:40:29 +00:00
|
|
|
[grandparent_group_label, parent_group_label, project_label_1].each do |label|
|
|
|
|
page.within('.block.labels') do
|
|
|
|
find('.edit-link').click
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
find('a.label-item', text: label.title).click
|
|
|
|
find('.dropdown-menu-close-icon').click
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
2018-06-15 14:39:27 +00:00
|
|
|
expect(page).to have_selector('.badge', text: label.title)
|
2018-04-04 15:40:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not find child group labels on dropdown' do
|
|
|
|
page.within('.block.labels') do
|
|
|
|
find('.edit-link').click
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
2018-06-15 14:39:27 +00:00
|
|
|
expect(page).not_to have_selector('.badge', text: child_group_label.title)
|
2018-04-04 15:40:29 +00:00
|
|
|
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|
|
|
|
|
select_label_on_dropdown(label.title)
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
if board
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card-title') do |card|
|
2018-04-04 15:40:29 +00:00
|
|
|
expect(card).to have_selector('a', text: labeled_issue.title)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
expect_issues_list_count(1)
|
|
|
|
expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not filter by descendant group labels' do
|
2020-01-02 13:03:23 +00:00
|
|
|
filtered_search.set("label=")
|
2018-04-04 15:40:29 +00:00
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.btn-link', text: child_group_label.title)
|
|
|
|
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|
|
|
|
|
select_label_on_dropdown(label.title)
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
if board
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card-title') do |card|
|
2018-04-04 15:40:29 +00:00
|
|
|
expect(card).to have_selector('a', text: labeled_issue.title)
|
|
|
|
end
|
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card-title') do |card|
|
2018-04-04 15:40:29 +00:00
|
|
|
expect(card).to have_selector('a', text: labeled_issue_2.title)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
expect_issues_list_count(3)
|
|
|
|
expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title)
|
|
|
|
expect(page).to have_selector('span.issue-title-text', text: labeled_issue_2.title)
|
|
|
|
expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by descendant group labels' do
|
|
|
|
wait_for_requests
|
|
|
|
|
2018-04-05 15:28:49 +00:00
|
|
|
select_label_on_dropdown(group_label_3.title)
|
2018-04-04 15:40:29 +00:00
|
|
|
|
2018-04-05 15:28:49 +00:00
|
|
|
if board
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card-title') do |card|
|
2018-04-04 21:43:33 +00:00
|
|
|
expect(card).not_to have_selector('a', text: labeled_issue_2.title)
|
|
|
|
end
|
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card-title') do |card|
|
2018-04-04 15:40:29 +00:00
|
|
|
expect(card).to have_selector('a', text: labeled_issue_3.title)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
expect_issues_list_count(1)
|
|
|
|
expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not filter by descendant group project labels' do
|
2020-01-02 13:03:23 +00:00
|
|
|
filtered_search.set("label=")
|
2018-04-04 15:40:29 +00:00
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.btn-link', text: project_label_3.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when creating new issuable' do
|
|
|
|
before do
|
|
|
|
visit new_project_issue_path(project_1)
|
|
|
|
end
|
|
|
|
|
2019-04-05 08:43:27 +00:00
|
|
|
it 'is able to assign ancestor group labels' do
|
2018-04-04 15:40:29 +00:00
|
|
|
fill_in 'issue_title', with: 'new created issue'
|
|
|
|
fill_in 'issue_description', with: 'new issue description'
|
|
|
|
|
|
|
|
find(".js-label-select").click
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
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-09-18 09:58:22 +00:00
|
|
|
find('.btn-success').click
|
2018-04-04 15:40:29 +00:00
|
|
|
|
|
|
|
expect(page.find('.issue-details h2.title')).to have_content('new created issue')
|
2020-02-25 15:08:50 +00:00
|
|
|
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)
|
2018-04-04 15:40:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'issuable sidebar' do
|
|
|
|
let!(:issue) { create(:issue, project: project_1) }
|
|
|
|
|
|
|
|
context 'on issue sidebar' do
|
|
|
|
before do
|
2018-04-23 16:12:26 +00:00
|
|
|
project_1.add_developer(user)
|
|
|
|
|
2018-04-04 15:40:29 +00:00
|
|
|
visit project_issue_path(project_1, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'assigning labels from sidebar'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on project board issue sidebar' do
|
2019-01-16 12:09:29 +00:00
|
|
|
let(:board) { create(:board, project: project_1) }
|
2018-04-04 15:40:29 +00:00
|
|
|
|
|
|
|
before do
|
2018-04-23 16:12:26 +00:00
|
|
|
project_1.add_developer(user)
|
|
|
|
|
2018-04-04 15:40:29 +00:00
|
|
|
visit project_board_path(project_1, board)
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
find('.board-card').click
|
2018-04-04 15:40:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'assigning labels from sidebar'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on group board issue sidebar' do
|
2019-01-16 12:09:29 +00:00
|
|
|
let(:board) { create(:board, group: parent) }
|
2018-04-04 15:40:29 +00:00
|
|
|
|
|
|
|
before do
|
2018-04-23 16:12:26 +00:00
|
|
|
parent.add_developer(user)
|
|
|
|
|
2018-04-04 15:40:29 +00:00
|
|
|
visit group_board_path(parent, board)
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
find('.board-card').click
|
2018-04-04 15:40:29 +00:00
|
|
|
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
|
2018-04-23 16:12:26 +00:00
|
|
|
project_1.add_developer(user)
|
|
|
|
|
2018-04-04 15:40:29 +00:00
|
|
|
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
|
2020-01-02 13:03:23 +00:00
|
|
|
filtered_search.set("label=")
|
2018-04-04 15:40:29 +00:00
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.btn-link', text: child_group_label.title)
|
|
|
|
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
|
|
|
|
|
|
|
|
context 'on project boards filter' do
|
|
|
|
let(:board) { create(:board, project: project_1) }
|
|
|
|
|
|
|
|
before do
|
2018-04-23 16:12:26 +00:00
|
|
|
project_1.add_developer(user)
|
|
|
|
|
2018-04-04 15:40:29 +00:00
|
|
|
visit project_board_path(project_1, board)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'filtering by ancestor labels for projects', true
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on group boards filter' do
|
|
|
|
let(:board) { create(:board, group: parent) }
|
|
|
|
|
|
|
|
before do
|
2018-04-23 16:12:26 +00:00
|
|
|
parent.add_developer(user)
|
|
|
|
|
2018-04-04 15:40:29 +00:00
|
|
|
visit group_board_path(parent, board)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'filtering by ancestor labels for groups', true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'creating boards lists' do
|
|
|
|
context 'on project boards' do
|
|
|
|
let(:board) { create(:board, project: project_1) }
|
|
|
|
|
|
|
|
before do
|
2018-04-23 16:12:26 +00:00
|
|
|
project_1.add_developer(user)
|
2018-04-04 15:40:29 +00:00
|
|
|
visit project_board_path(project_1, board)
|
|
|
|
find('.js-new-board-list').click
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates lists from all ancestor labels' do
|
|
|
|
[grandparent_group_label, parent_group_label, project_label_1].each do |label|
|
|
|
|
find('a', text: label.title).click
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_selector('.board-title-text', text: grandparent_group_label.title)
|
|
|
|
expect(page).to have_selector('.board-title-text', text: parent_group_label.title)
|
|
|
|
expect(page).to have_selector('.board-title-text', text: project_label_1.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on group boards' do
|
|
|
|
let(:board) { create(:board, group: parent) }
|
|
|
|
|
|
|
|
before do
|
2018-04-23 16:12:26 +00:00
|
|
|
parent.add_developer(user)
|
2018-04-04 15:40:29 +00:00
|
|
|
visit group_board_path(parent, board)
|
|
|
|
find('.js-new-board-list').click
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates lists from all ancestor group labels' do
|
|
|
|
[grandparent_group_label, parent_group_label].each do |label|
|
|
|
|
find('a', text: label.title).click
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_selector('.board-title-text', text: grandparent_group_label.title)
|
|
|
|
expect(page).to have_selector('.board-title-text', text: parent_group_label.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not create lists from descendant groups' do
|
|
|
|
expect(page).not_to have_selector('a', text: child_group_label.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|