1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'getting a work_item list for a group', feature_category: :team_planning do
include GraphqlHelpers
let_it_be(:group) { create(:group, :public) }
let_it_be(:sub_group) { create(:group, parent: group) }
let_it_be(:project) { create(:project, :repository, :public, group: group) }
let_it_be(:user) { create(:user) }
let_it_be(:reporter) { create(:user).tap { |user| group.add_reporter(user) } }
let_it_be(:project_work_item) { create(:work_item, project: project) }
let_it_be(:sub_group_work_item) do
create(
:work_item,
namespace: sub_group,
author: reporter
)
end
let_it_be(:group_work_item) do
create(
:work_item,
namespace: group,
author: reporter
)
end
let_it_be(:confidential_work_item) do
create(:work_item, :confidential, namespace: group, author: reporter)
end
let_it_be(:other_work_item) { create(:work_item) }
let(:work_items_data) { graphql_data['group']['workItems']['nodes'] }
let(:item_filter_params) { {} }
let(:current_user) { user }
let(:query_group) { group }
let(:fields) do
<<~QUERY
nodes {
#{all_graphql_fields_for('workItems'.classify, max_depth: 2)}
}
QUERY
end
it_behaves_like 'graphql work item list request spec' do
let_it_be(:container_build_params) { { namespace: group } }
let(:work_item_node_path) { %w[group workItems nodes] }
def post_query(request_user = current_user)
post_graphql(query, current_user: request_user)
end
end
context 'when filtering by search' do
let(:item_filter_params) { { search: 'search_term', in: [:DESCRIPTION] } }
# TODO: https://gitlab.com/gitlab-org/gitlab/-/work_items/393126
it 'returns an error since search is not implemented at the group level yet' do
post_graphql(query, current_user: current_user)
expect(graphql_errors).to contain_exactly(
hash_including('message' => 'Searching is not available for work items at the namespace level yet')
)
end
end
context 'when the user can not see confidential work_items' do
it_behaves_like 'a working graphql query' do
before do
post_graphql(query, current_user: current_user)
end
end
it 'does not return confidential issues' do
post_graphql(query, current_user: current_user)
expect(work_item_ids).to contain_exactly(
group_work_item.to_global_id.to_s
)
end
end
context 'when the user can see confidential work_items' do
let(:current_user) { reporter }
it 'returns also confidential work_items' do
post_graphql(query, current_user: current_user)
expect(work_item_ids).to eq([
confidential_work_item.to_global_id.to_s, group_work_item.to_global_id.to_s
])
end
context 'when the namespace_level_work_items feature flag is disabled' do
before do
stub_feature_flags(namespace_level_work_items: false)
post_graphql(query, current_user: current_user)
end
it 'returns null in the workItems field' do
expect(graphql_data['group']['workItems']).to be_nil
end
end
end
def work_item_ids
graphql_dig_at(work_items_data, :id)
end
def query(params = item_filter_params)
graphql_query_for(
'group',
{ 'fullPath' => query_group.full_path },
query_graphql_field('workItems', params, fields)
)
end
end
|