diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/graphql | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/graphql')
30 files changed, 359 insertions, 50 deletions
diff --git a/spec/graphql/mutations/ci/runner/delete_spec.rb b/spec/graphql/mutations/ci/runner/delete_spec.rb index 27e8236d593..9f30c95edd5 100644 --- a/spec/graphql/mutations/ci/runner/delete_spec.rb +++ b/spec/graphql/mutations/ci/runner/delete_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' RSpec.describe Mutations::Ci::Runner::Delete do include GraphqlHelpers - let_it_be(:user) { create(:user) } let_it_be(:runner) { create(:ci_runner) } + let(:user) { create(:user) } let(:current_ctx) { { current_user: user } } let(:mutation_params) do @@ -46,10 +46,10 @@ RSpec.describe Mutations::Ci::Runner::Delete do end context 'when user can delete owned runner' do - let_it_be(:project) { create(:project, creator_id: user.id) } - let_it_be(:project_runner, reload: true) { create(:ci_runner, :project, description: 'Project runner', projects: [project]) } + let!(:project) { create(:project, creator_id: user.id) } + let!(:project_runner) { create(:ci_runner, :project, description: 'Project runner', projects: [project]) } - before_all do + before do project.add_maintainer(user) end @@ -63,10 +63,10 @@ RSpec.describe Mutations::Ci::Runner::Delete do end context 'with more than one associated project' do - let_it_be(:project2) { create(:project, creator_id: user.id) } - let_it_be(:two_projects_runner) { create(:ci_runner, :project, description: 'Two projects runner', projects: [project, project2]) } + let!(:project2) { create(:project, creator_id: user.id) } + let!(:two_projects_runner) { create(:ci_runner, :project, description: 'Two projects runner', projects: [project, project2]) } - before_all do + before do project2.add_maintainer(user) end diff --git a/spec/graphql/mutations/clusters/agent_tokens/revoke_spec.rb b/spec/graphql/mutations/clusters/agent_tokens/revoke_spec.rb new file mode 100644 index 00000000000..f5f4c0cefad --- /dev/null +++ b/spec/graphql/mutations/clusters/agent_tokens/revoke_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Mutations::Clusters::AgentTokens::Revoke do + let_it_be(:token) { create(:cluster_agent_token) } + let_it_be(:user) { create(:user) } + + let(:mutation) do + described_class.new( + object: double, + context: { current_user: user }, + field: double + ) + end + + it { expect(described_class.graphql_name).to eq('ClusterAgentTokenRevoke') } + it { expect(described_class).to require_graphql_authorizations(:admin_cluster) } + + describe '#resolve' do + let(:global_id) { token.to_global_id } + + subject { mutation.resolve(id: global_id) } + + context 'user does not have permission' do + it 'does not revoke the token' do + expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) + + expect(token.reload).not_to be_revoked + end + end + + context 'user has permission' do + before do + token.agent.project.add_maintainer(user) + end + + it 'revokes the token' do + subject + + expect(token.reload).to be_revoked + end + + context 'supplied ID is invalid' do + let(:global_id) { token.id } + + it 'raises a coercion error' do + expect { subject }.to raise_error(::GraphQL::CoercionError) + + expect(token.reload).not_to be_revoked + end + end + end + end +end diff --git a/spec/graphql/mutations/customer_relations/contacts/create_spec.rb b/spec/graphql/mutations/customer_relations/contacts/create_spec.rb index 0f05504d4f2..d17d11305b1 100644 --- a/spec/graphql/mutations/customer_relations/contacts/create_spec.rb +++ b/spec/graphql/mutations/customer_relations/contacts/create_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' RSpec.describe Mutations::CustomerRelations::Contacts::Create do let_it_be(:user) { create(:user) } - let_it_be(:group) { create(:group) } + let(:group) { create(:group, :crm_enabled) } let(:not_found_or_does_not_belong) { 'The specified organization was not found or does not belong to this group' } let(:valid_params) do attributes_for(:contact, @@ -34,11 +34,11 @@ RSpec.describe Mutations::CustomerRelations::Contacts::Create do end context 'when the user has permission' do - before_all do + before do group.add_developer(user) end - context 'when the feature is disabled' do + context 'when the feature flag is disabled' do before do stub_feature_flags(customer_relations: false) end @@ -49,6 +49,15 @@ RSpec.describe Mutations::CustomerRelations::Contacts::Create do end end + context 'when crm_enabled is false' do + let(:group) { create(:group) } + + it 'raises an error' do + expect { resolve_mutation }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) + .with_message("The resource that you are attempting to access does not exist or you don't have permission to perform this action") + end + end + context 'when the params are invalid' do it 'returns the validation error' do valid_params[:first_name] = nil diff --git a/spec/graphql/mutations/customer_relations/contacts/update_spec.rb b/spec/graphql/mutations/customer_relations/contacts/update_spec.rb index 4f59de194fd..c8206eca442 100644 --- a/spec/graphql/mutations/customer_relations/contacts/update_spec.rb +++ b/spec/graphql/mutations/customer_relations/contacts/update_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe Mutations::CustomerRelations::Contacts::Update do let_it_be(:user) { create(:user) } - let_it_be(:group) { create(:group) } + let_it_be(:group) { create(:group, :crm_enabled) } let(:first_name) { 'Lionel' } let(:last_name) { 'Smith' } diff --git a/spec/graphql/mutations/customer_relations/organizations/create_spec.rb b/spec/graphql/mutations/customer_relations/organizations/create_spec.rb index 9be0f5d4289..ee78d2b16f6 100644 --- a/spec/graphql/mutations/customer_relations/organizations/create_spec.rb +++ b/spec/graphql/mutations/customer_relations/organizations/create_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe Mutations::CustomerRelations::Organizations::Create do let_it_be(:user) { create(:user) } - let_it_be(:group) { create(:group) } + let_it_be(:group) { create(:group, :crm_enabled) } let(:valid_params) do attributes_for(:organization, diff --git a/spec/graphql/mutations/customer_relations/organizations/update_spec.rb b/spec/graphql/mutations/customer_relations/organizations/update_spec.rb index e3aa8eafe0c..90fd7a0a9f1 100644 --- a/spec/graphql/mutations/customer_relations/organizations/update_spec.rb +++ b/spec/graphql/mutations/customer_relations/organizations/update_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe Mutations::CustomerRelations::Organizations::Update do let_it_be(:user) { create(:user) } - let_it_be(:group) { create(:group) } + let_it_be(:group) { create(:group, :crm_enabled) } let(:name) { 'GitLab' } let(:default_rate) { 1000.to_f } @@ -56,7 +56,7 @@ RSpec.describe Mutations::CustomerRelations::Organizations::Update do expect(resolve_mutation[:organization]).to have_attributes(attributes) end - context 'when the feature is disabled' do + context 'when the feature flag is disabled' do before do stub_feature_flags(customer_relations: false) end @@ -66,6 +66,15 @@ RSpec.describe Mutations::CustomerRelations::Organizations::Update do .with_message("The resource that you are attempting to access does not exist or you don't have permission to perform this action") end end + + context 'when the feature is disabled' do + let_it_be(:group) { create(:group) } + + it 'raises an error' do + expect { resolve_mutation }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) + .with_message("The resource that you are attempting to access does not exist or you don't have permission to perform this action") + end + end end end diff --git a/spec/graphql/mutations/issues/set_escalation_status_spec.rb b/spec/graphql/mutations/issues/set_escalation_status_spec.rb new file mode 100644 index 00000000000..d41118b1812 --- /dev/null +++ b/spec/graphql/mutations/issues/set_escalation_status_spec.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Mutations::Issues::SetEscalationStatus do + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project) } + let_it_be(:issue, reload: true) { create(:incident, project: project) } + let_it_be(:escalation_status, reload: true) { create(:incident_management_issuable_escalation_status, issue: issue) } + + let(:status) { :acknowledged } + let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } + + describe '#resolve' do + let(:args) { { status: status } } + let(:mutated_issue) { result[:issue] } + + subject(:result) { mutation.resolve(project_path: issue.project.full_path, iid: issue.iid, **args) } + + it_behaves_like 'permission level for issue mutation is correctly verified', true + + context 'when the user can update the issue' do + before_all do + project.add_reporter(user) + end + + it_behaves_like 'permission level for issue mutation is correctly verified', true + + context 'when the user can update the escalation status' do + before_all do + project.add_developer(user) + end + + it 'returns the issue with the escalation policy' do + expect(mutated_issue).to eq(issue) + expect(mutated_issue.escalation_status.status_name).to eq(status) + expect(result[:errors]).to be_empty + end + + it 'returns errors when issue update fails' do + issue.update_column(:author_id, nil) + + expect(result[:errors]).not_to be_empty + end + + context 'with non-incident issue is provided' do + let_it_be(:issue) { create(:issue, project: project) } + + it 'raises an error' do + expect { result }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature unavailable for provided issue') + end + end + + context 'with feature disabled' do + before do + stub_feature_flags(incident_escalations: false) + end + + it 'raises an error' do + expect { result }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature unavailable for provided issue') + end + end + end + end + end +end diff --git a/spec/graphql/resolvers/clusters/agent_tokens_resolver_spec.rb b/spec/graphql/resolvers/clusters/agent_tokens_resolver_spec.rb index 6b8b88928d8..9b54d466681 100644 --- a/spec/graphql/resolvers/clusters/agent_tokens_resolver_spec.rb +++ b/spec/graphql/resolvers/clusters/agent_tokens_resolver_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Resolvers::Clusters::AgentTokensResolver do it { expect(described_class.type).to eq(Types::Clusters::AgentTokenType) } it { expect(described_class.null).to be_truthy } + it { expect(described_class.arguments.keys).to contain_exactly('status') } describe '#resolve' do let(:agent) { create(:cluster_agent) } @@ -23,6 +24,14 @@ RSpec.describe Resolvers::Clusters::AgentTokensResolver do expect(subject).to eq([matching_token2, matching_token1]) end + context 'token status is specified' do + let!(:revoked_token) { create(:cluster_agent_token, :revoked, agent: agent) } + + subject { resolve(described_class, obj: agent, ctx: ctx, args: { status: 'revoked' }) } + + it { is_expected.to contain_exactly(revoked_token) } + end + context 'user does not have permission' do let(:user) { create(:user, developer_projects: [agent.project]) } diff --git a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb index 3fcfa967452..9fe4c78f551 100644 --- a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb +++ b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb @@ -62,24 +62,12 @@ RSpec.describe ResolvesPipelines do context 'filtering by source' do let_it_be(:source_pipeline) { create(:ci_pipeline, project: project, source: 'web') } - context 'when `dast_view_scans` feature flag is disabled' do - before do - stub_feature_flags(dast_view_scans: false) - end - - it 'does not filter by source' do - expect(resolve_pipelines(source: 'web')).to contain_exactly(*all_pipelines, source_pipeline) - end + it 'does filter by source' do + expect(resolve_pipelines(source: 'web')).to contain_exactly(source_pipeline) end - context 'when `dast_view_scans` feature flag is enabled' do - it 'does filter by source' do - expect(resolve_pipelines(source: 'web')).to contain_exactly(source_pipeline) - end - - it 'returns all the pipelines' do - expect(resolve_pipelines).to contain_exactly(*all_pipelines, source_pipeline) - end + it 'returns all the pipelines' do + expect(resolve_pipelines).to contain_exactly(*all_pipelines, source_pipeline) end end diff --git a/spec/graphql/resolvers/merge_requests_resolver_spec.rb b/spec/graphql/resolvers/merge_requests_resolver_spec.rb index a931b0a3f77..1d0eac30a23 100644 --- a/spec/graphql/resolvers/merge_requests_resolver_spec.rb +++ b/spec/graphql/resolvers/merge_requests_resolver_spec.rb @@ -172,6 +172,28 @@ RSpec.describe Resolvers::MergeRequestsResolver do end end + context 'with draft argument' do + before do + merge_request_4.update!(title: MergeRequest.wip_title(merge_request_4.title)) + end + + context 'with draft: true argument' do + it 'takes one argument' do + result = resolve_mr(project, draft: true) + + expect(result).to contain_exactly(merge_request_4) + end + end + + context 'with draft: false argument' do + it 'takes one argument' do + result = resolve_mr(project, draft: false) + + expect(result).not_to contain_exactly(merge_request_1, merge_request_2, merge_request_3, merge_request_5, merge_request_6) + end + end + end + context 'with label argument' do let_it_be(:label) { merge_request_6.labels.first } let_it_be(:with_label) { create(:labeled_merge_request, :closed, labels: [label], **common_attrs) } diff --git a/spec/graphql/resolvers/users/groups_resolver_spec.rb b/spec/graphql/resolvers/users/groups_resolver_spec.rb index 0fdb6da5ae9..5ac7aac4898 100644 --- a/spec/graphql/resolvers/users/groups_resolver_spec.rb +++ b/spec/graphql/resolvers/users/groups_resolver_spec.rb @@ -26,14 +26,6 @@ RSpec.describe Resolvers::Users::GroupsResolver do public_maintainer_group.add_maintainer(user) end - context 'when paginatable_namespace_drop_down_for_project_creation feature flag is disabled' do - before do - stub_feature_flags(paginatable_namespace_drop_down_for_project_creation: false) - end - - it { is_expected.to be_nil } - end - context 'when resolver object is current user' do context 'when permission is :create_projects' do let(:group_arguments) { { permission_scope: :create_projects } } diff --git a/spec/graphql/resolvers/work_items/types_resolver_spec.rb b/spec/graphql/resolvers/work_items/types_resolver_spec.rb new file mode 100644 index 00000000000..b85989256b5 --- /dev/null +++ b/spec/graphql/resolvers/work_items/types_resolver_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Resolvers::WorkItems::TypesResolver do + include GraphqlHelpers + + let_it_be(:current_user) { create(:user) } + let_it_be(:group) { create(:group) } + + before_all do + group.add_developer(current_user) + end + + describe '#resolve' do + it 'returns all default work item types' do + result = resolve(described_class, obj: group) + + expect(result.to_a).to match(WorkItems::Type.default.order_by_name_asc) + end + end +end diff --git a/spec/graphql/types/ci/config/config_type_spec.rb b/spec/graphql/types/ci/config/config_type_spec.rb index edd190a4365..0012ae9f51f 100644 --- a/spec/graphql/types/ci/config/config_type_spec.rb +++ b/spec/graphql/types/ci/config/config_type_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Types::Ci::Config::ConfigType do mergedYaml stages status + warnings ] expect(described_class).to have_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/ci/job_type_spec.rb b/spec/graphql/types/ci/job_type_spec.rb index e3cb56c2ad5..47d697ab8b8 100644 --- a/spec/graphql/types/ci/job_type_spec.rb +++ b/spec/graphql/types/ci/job_type_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Types::Ci::JobType do created_by_tag detailedStatus duration + downstreamPipeline finished_at id manual_job diff --git a/spec/graphql/types/ci/pipeline_message_type_spec.rb b/spec/graphql/types/ci/pipeline_message_type_spec.rb new file mode 100644 index 00000000000..f5c20cd9bf6 --- /dev/null +++ b/spec/graphql/types/ci/pipeline_message_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Ci::PipelineMessageType do + specify { expect(described_class.graphql_name).to eq('PipelineMessage') } + + it 'contains attributes related to a pipeline message' do + expected_fields = %w[ + id content + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/ci/pipeline_type_spec.rb b/spec/graphql/types/ci/pipeline_type_spec.rb index 58724524785..94d1b42da37 100644 --- a/spec/graphql/types/ci/pipeline_type_spec.rb +++ b/spec/graphql/types/ci/pipeline_type_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Types::Ci::PipelineType do coverage created_at updated_at started_at finished_at committed_at stages user retryable cancelable jobs source_job job job_artifacts downstream upstream path project active user_permissions warnings commit commit_path uses_needs - test_report_summary test_suite ref + test_report_summary test_suite ref ref_path warning_messages ] if Gitlab.ee? diff --git a/spec/graphql/types/ci/runner_type_spec.rb b/spec/graphql/types/ci/runner_type_spec.rb index cf8650a4a03..43d8b585d6b 100644 --- a/spec/graphql/types/ci/runner_type_spec.rb +++ b/spec/graphql/types/ci/runner_type_spec.rb @@ -9,9 +9,9 @@ RSpec.describe GitlabSchema.types['CiRunner'] do it 'contains attributes related to a runner' do expected_fields = %w[ - id description contacted_at maximum_timeout access_level active status + id description created_at contacted_at maximum_timeout access_level active status version short_sha revision locked run_untagged ip_address runner_type tag_list - project_count job_count admin_url user_permissions + project_count job_count admin_url edit_admin_url user_permissions executor_name ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/clusters/agent_token_status_enum_spec.rb b/spec/graphql/types/clusters/agent_token_status_enum_spec.rb new file mode 100644 index 00000000000..071e4050cfb --- /dev/null +++ b/spec/graphql/types/clusters/agent_token_status_enum_spec.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Clusters::AgentTokenStatusEnum do + it { expect(described_class.graphql_name).to eq('AgentTokenStatus') } + it { expect(described_class.values.keys).to match_array(Clusters::AgentToken.statuses.keys.map(&:upcase)) } +end diff --git a/spec/graphql/types/clusters/agent_token_type_spec.rb b/spec/graphql/types/clusters/agent_token_type_spec.rb index c872d201fd9..3f0720cb4b5 100644 --- a/spec/graphql/types/clusters/agent_token_type_spec.rb +++ b/spec/graphql/types/clusters/agent_token_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['ClusterAgentToken'] do - let(:fields) { %i[cluster_agent created_at created_by_user description id last_used_at name] } + let(:fields) { %i[cluster_agent created_at created_by_user description id last_used_at name status] } it { expect(described_class.graphql_name).to eq('ClusterAgentToken') } diff --git a/spec/graphql/types/commit_type_spec.rb b/spec/graphql/types/commit_type_spec.rb index 2f74ce81761..c1d838c3117 100644 --- a/spec/graphql/types/commit_type_spec.rb +++ b/spec/graphql/types/commit_type_spec.rb @@ -10,7 +10,7 @@ RSpec.describe GitlabSchema.types['Commit'] do it 'contains attributes related to commit' do expect(described_class).to have_graphql_fields( :id, :sha, :short_id, :title, :full_title, :full_title_html, :description, :description_html, :message, :title_html, :authored_date, - :author_name, :author_gravatar, :author, :web_url, :web_path, + :author_name, :author_email, :author_gravatar, :author, :web_url, :web_path, :pipelines, :signature_html ) end diff --git a/spec/graphql/types/group_member_relation_enum_spec.rb b/spec/graphql/types/group_member_relation_enum_spec.rb index 315809ef75e..89ee8c574c4 100644 --- a/spec/graphql/types/group_member_relation_enum_spec.rb +++ b/spec/graphql/types/group_member_relation_enum_spec.rb @@ -6,6 +6,6 @@ RSpec.describe Types::GroupMemberRelationEnum do specify { expect(described_class.graphql_name).to eq('GroupMemberRelation') } it 'exposes all the existing group member relation type values' do - expect(described_class.values.keys).to contain_exactly('DIRECT', 'INHERITED', 'DESCENDANTS') + expect(described_class.values.keys).to contain_exactly('DIRECT', 'INHERITED', 'DESCENDANTS', 'SHARED_FROM_GROUPS') end end diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index dca2c930eea..0ba322a100a 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -22,7 +22,7 @@ RSpec.describe GitlabSchema.types['Group'] do dependency_proxy_blobs dependency_proxy_image_count dependency_proxy_blob_count dependency_proxy_total_size dependency_proxy_image_prefix dependency_proxy_image_ttl_policy - shared_runners_setting timelogs organizations contacts + shared_runners_setting timelogs organizations contacts work_item_types ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/incident_management/escalation_status_enum_spec.rb b/spec/graphql/types/incident_management/escalation_status_enum_spec.rb new file mode 100644 index 00000000000..b39d4d9324e --- /dev/null +++ b/spec/graphql/types/incident_management/escalation_status_enum_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['IssueEscalationStatus'] do + specify { expect(described_class.graphql_name).to eq('IssueEscalationStatus') } + + describe 'statuses' do + using RSpec::Parameterized::TableSyntax + + where(:status_name, :status_value) do + 'TRIGGERED' | :triggered + 'ACKNOWLEDGED' | :acknowledged + 'RESOLVED' | :resolved + 'IGNORED' | :ignored + 'INVALID' | nil + end + + with_them do + it 'exposes a status with the correct value' do + expect(described_class.values[status_name]&.value).to eq(status_value) + end + end + end +end diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index 1b8bf007a73..1d4590cbb4e 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -18,7 +18,7 @@ RSpec.describe GitlabSchema.types['Issue'] do confidential hidden discussion_locked upvotes downvotes merge_requests_count user_notes_count user_discussions_count web_path web_url relative_position emails_disabled subscribed time_estimate total_time_spent human_time_estimate human_total_time_spent closed_at created_at updated_at task_completion_status design_collection alert_management_alert severity current_user_todos moved moved_to - create_note_email timelogs project_id customer_relations_contacts] + create_note_email timelogs project_id customer_relations_contacts escalation_status] fields.each do |field_name| expect(described_class).to have_graphql_field(field_name) @@ -257,4 +257,49 @@ RSpec.describe GitlabSchema.types['Issue'] do end end end + + describe 'escalation_status' do + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, :public) } + let_it_be(:issue, reload: true) { create(:issue, project: project) } + + let(:execute) { GitlabSchema.execute(query, context: { current_user: user }).as_json } + let(:query) do + %( + query { + project(fullPath: "#{project.full_path}") { + issue(iid: "#{issue.iid}") { + escalationStatus + } + } + } + ) + end + + subject(:status) { execute.dig('data', 'project', 'issue', 'escalationStatus') } + + it { is_expected.to be_nil } + + context 'for an incident' do + before do + issue.update!(issue_type: Issue.issue_types[:incident]) + end + + it { is_expected.to be_nil } + + context 'with an escalation status record' do + let!(:escalation_status) { create(:incident_management_issuable_escalation_status, issue: issue) } + + it { is_expected.to eq(escalation_status.status_name.to_s.upcase) } + + context 'with feature disabled' do + before do + stub_feature_flags(incident_escalations: false) + end + + it { is_expected.to be_nil } + end + end + end + end end diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index b17b7c32289..5ab8845246a 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -33,7 +33,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do total_time_spent human_time_estimate human_total_time_spent reference author merged_at commit_count current_user_todos conflicts auto_merge_enabled approved_by source_branch_protected default_merge_commit_message_with_description squash_on_merge available_auto_merge_strategies - has_ci mergeable commits_without_merge_commits squash security_auto_fix default_squash_commit_message + has_ci mergeable commits commits_without_merge_commits squash security_auto_fix default_squash_commit_message auto_merge_strategy merge_user ] @@ -133,4 +133,28 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do end end end + + describe '#merge_user' do + let_it_be(:project) { create(:project, :public) } + + context 'when MR is merged' do + let(:merge_request) { create(:merge_request, :with_merged_metrics, target_project: project, source_project: project) } + + it 'is not nil' do + value = resolve_field(:merge_user, merge_request) + + expect(value).not_to be_nil + end + end + + context 'when MR is set to merge when pipeline succeeds' do + let(:merge_request) { create(:merge_request, :merge_when_pipeline_succeeds, target_project: project, source_project: project) } + + it 'is not nil' do + value = resolve_field(:merge_user, merge_request) + + expect(value).not_to be_nil + end + end + end end diff --git a/spec/graphql/types/mutation_type_spec.rb b/spec/graphql/types/mutation_type_spec.rb index 95d835c88cf..1fc46f2d511 100644 --- a/spec/graphql/types/mutation_type_spec.rb +++ b/spec/graphql/types/mutation_type_spec.rb @@ -7,6 +7,14 @@ RSpec.describe Types::MutationType do expect(described_class).to have_graphql_mutation(Mutations::MergeRequests::SetDraft) end + describe 'deprecated mutations' do + describe 'clusterAgentTokenDelete' do + let(:field) { get_field('clusterAgentTokenDelete') } + + it { expect(field.deprecation_reason).to eq('Tokens must be revoked with ClusterAgentTokenRevoke. Deprecated in 14.7.') } + end + end + def get_field(name) described_class.fields[GraphqlHelpers.fieldnamerize(name)] end diff --git a/spec/graphql/types/packages/package_details_type_spec.rb b/spec/graphql/types/packages/package_details_type_spec.rb index f0b684d6b07..ceeb000ff85 100644 --- a/spec/graphql/types/packages/package_details_type_spec.rb +++ b/spec/graphql/types/packages/package_details_type_spec.rb @@ -5,7 +5,10 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['PackageDetailsType'] do it 'includes all the package fields' do expected_fields = %w[ - id name version created_at updated_at package_type tags project pipelines versions package_files dependency_links + id name version created_at updated_at package_type tags project + pipelines versions package_files dependency_links + npm_url maven_url conan_url nuget_url pypi_url pypi_setup_url + composer_url composer_config_repository_url ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index adf5507571b..cd216232569 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -34,7 +34,7 @@ RSpec.describe GitlabSchema.types['Project'] do container_repositories container_repositories_count pipeline_analytics squash_read_only sast_ci_configuration cluster_agent cluster_agents agent_configurations - ci_template timelogs merge_commit_template squash_commit_template + ci_template timelogs merge_commit_template squash_commit_template work_item_types ] expect(described_class).to include_graphql_fields(*expected_fields) @@ -289,6 +289,7 @@ RSpec.describe GitlabSchema.types['Project'] do :source_branches, :target_branches, :state, + :draft, :labels, :before, :after, diff --git a/spec/graphql/types/projects/service_type_spec.rb b/spec/graphql/types/projects/service_type_spec.rb index cb09f1ca6cc..0bffdfd629d 100644 --- a/spec/graphql/types/projects/service_type_spec.rb +++ b/spec/graphql/types/projects/service_type_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Types::Projects::ServiceType do describe ".resolve_type" do it 'resolves the corresponding type for objects' do expect(described_class.resolve_type(build(:jira_integration), {})).to eq(Types::Projects::Services::JiraServiceType) - expect(described_class.resolve_type(build(:service), {})).to eq(Types::Projects::Services::BaseServiceType) + expect(described_class.resolve_type(build(:integration), {})).to eq(Types::Projects::Services::BaseServiceType) expect(described_class.resolve_type(build(:drone_ci_integration), {})).to eq(Types::Projects::Services::BaseServiceType) expect(described_class.resolve_type(build(:custom_issue_tracker_integration), {})).to eq(Types::Projects::Services::BaseServiceType) end diff --git a/spec/graphql/types/repository/blob_type_spec.rb b/spec/graphql/types/repository/blob_type_spec.rb index 21bc88e34c0..8d845e5d814 100644 --- a/spec/graphql/types/repository/blob_type_spec.rb +++ b/spec/graphql/types/repository/blob_type_spec.rb @@ -21,15 +21,21 @@ RSpec.describe Types::Repository::BlobType do :file_type, :edit_blob_path, :stored_externally, + :external_storage, :raw_path, :replace_path, :pipeline_editor_path, + :find_file_path, + :blame_path, + :history_path, + :permalink_path, :code_owners, :simple_viewer, :rich_viewer, :plain_data, :can_modify_blob, :can_current_user_push_to_branch, + :archived, :ide_edit_path, :external_storage_url, :fork_and_edit_path, |