blob: 5469fd80a4f144c3d74a3066c2413f04e4b501e6 (
plain)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# frozen_string_literal: true
RSpec.shared_examples 'graphql issue list request spec' do
it_behaves_like 'a working graphql query' do
before do
post_query
end
end
describe 'filters' do
context 'when filtering by assignees' do
context 'when both assignee_username filters are provided' do
let(:issue_filter_params) do
{ assignee_username: current_user.username, assignee_usernames: [current_user.username] }
end
it 'returns a mutually exclusive param error' do
post_query
expect_graphql_errors_to_include(
'only one of [assigneeUsernames, assigneeUsername] arguments is allowed at the same time.'
)
end
end
context 'when filtering by a negated argument' do
let(:issue_filter_params) { { not: { assignee_usernames: [current_user.username] } } }
it 'returns correctly filtered issues' do
post_query
expect(issue_ids).to match_array(expected_negated_assignee_issues.map { |i| i.to_gid.to_s })
end
end
end
context 'when filtering by unioned arguments' do
let(:issue_filter_params) { { or: { assignee_usernames: [current_user.username, another_user.username] } } }
it 'returns correctly filtered issues' do
post_query
expect(issue_ids).to match_array(expected_unioned_assignee_issues.map { |i| i.to_gid.to_s })
end
context 'when argument is blank' do
let(:issue_filter_params) { { or: {} } }
it 'does not raise an error' do
post_query
expect_graphql_errors_to_be_empty
end
end
context 'when feature flag is disabled' do
it 'returns an error' do
stub_feature_flags(or_issuable_queries: false)
post_query
expect_graphql_errors_to_include(
"'or' arguments are only allowed when the `or_issuable_queries` feature flag is enabled."
)
end
end
end
context 'when filtering by a blank negated argument' do
let(:issue_filter_params) { { not: {} } }
it 'does not raise an error' do
post_query
expect_graphql_errors_to_be_empty
end
end
context 'when filtering by reaction emoji' do
using RSpec::Parameterized::TableSyntax
where(:value, :issue_list) do
'thumbsup' | lazy { voted_issues }
'ANY' | lazy { voted_issues }
'any' | lazy { voted_issues }
'AnY' | lazy { voted_issues }
'NONE' | lazy { no_award_issues }
'thumbsdown' | lazy { [] }
end
with_them do
let(:issue_filter_params) { { my_reaction_emoji: value } }
let(:gids) { to_gid_list(issue_list) }
it 'returns correctly filtered issues' do
post_query
expect(issue_ids).to match_array(gids)
end
end
end
context 'when filtering by search' do
it_behaves_like 'query with a search term', [:TITLE] do
let(:search_term) { search_title_term }
let(:issuable_data) { issues_data }
let(:user) { current_user }
let(:issuable) { title_search_issue }
let(:ids) { issue_ids }
end
end
end
describe 'sorting and pagination' do
context 'when sorting by severity' do
context 'when ascending' do
it_behaves_like 'sorted paginated query' do
let(:sort_param) { :SEVERITY_ASC }
let(:first_param) { 2 }
let(:all_records) { to_gid_list(expected_severity_sorted_asc) }
end
end
context 'when descending' do
it_behaves_like 'sorted paginated query' do
let(:sort_param) { :SEVERITY_DESC }
let(:first_param) { 2 }
let(:all_records) { to_gid_list(expected_severity_sorted_asc.reverse) }
end
end
end
context 'when sorting by priority' do
context 'when ascending' do
it_behaves_like 'sorted paginated query' do
let(:sort_param) { :PRIORITY_ASC }
let(:first_param) { 2 }
let(:all_records) { to_gid_list(expected_priority_sorted_asc) }
end
end
context 'when descending' do
it_behaves_like 'sorted paginated query' do
let(:sort_param) { :PRIORITY_DESC }
let(:first_param) { 2 }
let(:all_records) { to_gid_list(expected_priority_sorted_desc) }
end
end
end
end
it 'includes a web_url' do
post_query
expect(issues_data[0]['webUrl']).to be_present
end
it 'includes discussion locked' do
post_query
expect(issues_data).to contain_exactly(
*locked_discussion_issues.map { |i| hash_including('id' => i.to_gid.to_s, 'discussionLocked' => true) },
*unlocked_discussion_issues.map { |i| hash_including('id' => i.to_gid.to_s, 'discussionLocked' => false) }
)
end
def to_gid_list(instance_list)
instance_list.map { |instance| instance.to_gid.to_s }
end
end
|