debian-mirror-gitlab/spec/requests/api/graphql/project/issues_spec.rb

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

145 lines
4.8 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2019-02-15 15:39:39 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'getting an issue list for a project', feature_category: :team_planning do
2019-02-15 15:39:39 +05:30
include GraphqlHelpers
2021-11-18 22:05:49 +05:30
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, :repository, :public, group: group) }
2020-11-24 15:15:51 +05:30
let_it_be(:current_user) { create(:user) }
2023-01-13 00:05:48 +05:30
let_it_be(:another_user) { create(:user).tap { |u| group.add_reporter(u) } }
2023-03-04 22:38:38 +05:30
let_it_be(:milestone1) { create(:milestone, project: project, due_date: 10.days.from_now) }
let_it_be(:milestone2) { create(:milestone, project: project, due_date: 20.days.from_now) }
let_it_be(:milestone3) { create(:milestone, project: project, due_date: 30.days.from_now) }
let_it_be(:milestone4) { create(:milestone, project: project, due_date: 40.days.from_now) }
2023-01-13 00:05:48 +05:30
let_it_be(:priority1) { create(:label, project: project, priority: 1) }
let_it_be(:priority2) { create(:label, project: project, priority: 5) }
let_it_be(:priority3) { create(:label, project: project, priority: 10) }
2023-03-04 22:38:38 +05:30
let_it_be(:issue_a) do
create(
:issue,
project: project,
discussion_locked: true,
labels: [priority3],
relative_position: 1000,
milestone: milestone4
)
end
2020-10-24 23:57:45 +05:30
2023-03-04 22:38:38 +05:30
let_it_be(:issue_b) do
create(
:issue,
:with_alert,
project: project,
title: 'title matching issue i',
due_date: 3.days.ago,
relative_position: 3000,
labels: [priority2, priority3],
milestone: milestone1
)
end
2021-04-29 21:17:54 +05:30
2023-03-04 22:38:38 +05:30
let_it_be(:issue_c) do
create(
:issue,
project: project,
labels: [priority1],
milestone: milestone2,
due_date: 1.day.ago,
relative_position: nil
)
end
let_it_be(:issue_d) do
create(:issue,
project: project,
labels: [priority2],
due_date: 3.days.from_now,
relative_position: 5000,
milestone: milestone3
)
end
let_it_be(:issue_e) do
create(
:issue,
:confidential,
project: project,
due_date: 1.day.from_now,
relative_position: nil
)
2019-02-15 15:39:39 +05:30
end
2023-03-04 22:38:38 +05:30
let_it_be(:issues, reload: true) { [issue_a, issue_b, issue_c, issue_d, issue_e] }
let(:issue_nodes_path) { %w[project issues nodes] }
let(:issue_filter_params) { {} }
2023-01-13 00:05:48 +05:30
# All new specs should be added to the shared example if the change also
# affects the `issues` query at the root level of the API.
# Shared example also used in spec/requests/api/graphql/issues_spec.rb
it_behaves_like 'graphql issue list request spec' do
2023-03-04 22:38:38 +05:30
let_it_be(:external_user) { create(:user) }
let(:public_projects) { [project] }
before_all do
group.add_developer(current_user)
end
2023-01-13 00:05:48 +05:30
# filters
let(:expected_negated_assignee_issues) { [issue_b, issue_c, issue_d, issue_e] }
let(:voted_issues) { [issue_a] }
let(:no_award_issues) { [issue_b, issue_c, issue_d, issue_e] }
let(:locked_discussion_issues) { [issue_a] }
let(:unlocked_discussion_issues) { [issue_b, issue_c, issue_d, issue_e] }
let(:search_title_term) { 'matching issue' }
let(:title_search_issue) { issue_b }
2023-03-04 22:38:38 +05:30
let(:confidential_issues) { [issue_e] }
let(:non_confidential_issues) { [issue_a, issue_b, issue_c, issue_d] }
let(:public_non_confidential_issues) { non_confidential_issues }
2023-01-13 00:05:48 +05:30
# sorting
let(:data_path) { [:project, :issues] }
2023-03-04 22:38:38 +05:30
let(:expected_priority_sorted_asc) { [issue_b, issue_c, issue_d, issue_a, issue_e] }
let(:expected_priority_sorted_desc) { [issue_a, issue_d, issue_c, issue_b, issue_e] }
let(:expected_due_date_sorted_desc) { [issue_d, issue_e, issue_c, issue_b, issue_a] }
let(:expected_due_date_sorted_asc) { [issue_b, issue_c, issue_e, issue_d, issue_a] }
let(:expected_relative_position_sorted_asc) { [issue_a, issue_b, issue_d, issue_c, issue_e] }
let(:expected_label_priority_sorted_asc) { [issue_c, issue_d, issue_b, issue_a, issue_e] }
let(:expected_label_priority_sorted_desc) { [issue_a, issue_d, issue_b, issue_c, issue_e] }
let(:expected_milestone_sorted_asc) { [issue_b, issue_c, issue_d, issue_a, issue_e] }
let(:expected_milestone_sorted_desc) { [issue_a, issue_d, issue_c, issue_b, issue_e] }
# N+1 queries
let(:same_project_issue1) { issue_a }
let(:same_project_issue2) { issue_b }
2023-01-13 00:05:48 +05:30
before_all do
create(:award_emoji, :upvote, user: current_user, awardable: issue_a)
2021-11-11 11:23:49 +05:30
end
2023-01-13 00:05:48 +05:30
def pagination_query(params)
graphql_query_for(
:project,
{ full_path: project.full_path },
query_graphql_field(:issues, params, "#{page_info} nodes { id }")
)
2022-10-11 01:57:18 +05:30
end
2019-12-26 22:10:19 +05:30
2023-03-04 22:38:38 +05:30
def post_query(request_user = current_user)
post_graphql(query, current_user: request_user)
2020-05-24 23:13:21 +05:30
end
2021-11-18 22:05:49 +05:30
end
2022-10-11 01:57:18 +05:30
def query(params = issue_filter_params)
graphql_query_for(
'project',
{ 'fullPath' => project.full_path },
query_graphql_field('issues', params, fields)
)
end
2019-02-15 15:39:39 +05:30
end