diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
commit | 43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch) | |
tree | dceebdc68925362117480a5d672bcff122fb625b /spec/graphql/types | |
parent | 20c84b99005abd1c82101dfeff264ac50d2df211 (diff) |
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'spec/graphql/types')
46 files changed, 348 insertions, 81 deletions
diff --git a/spec/graphql/types/achievements/achievement_type_spec.rb b/spec/graphql/types/achievements/achievement_type_spec.rb index f967dc8e25e..08fadcdff22 100644 --- a/spec/graphql/types/achievements/achievement_type_spec.rb +++ b/spec/graphql/types/achievements/achievement_type_spec.rb @@ -14,6 +14,7 @@ RSpec.describe GitlabSchema.types['Achievement'], feature_category: :user_profil description created_at updated_at + user_achievements ] end diff --git a/spec/graphql/types/achievements/user_achievement_type_spec.rb b/spec/graphql/types/achievements/user_achievement_type_spec.rb new file mode 100644 index 00000000000..b7fe4d815f7 --- /dev/null +++ b/spec/graphql/types/achievements/user_achievement_type_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['UserAchievement'], feature_category: :user_profile do + include GraphqlHelpers + + let(:fields) do + %w[ + id + achievement + user + awarded_by_user + revoked_by_user + created_at + updated_at + revoked_at + ] + end + + it { expect(described_class.graphql_name).to eq('UserAchievement') } + it { expect(described_class).to have_graphql_fields(fields) } + it { expect(described_class).to require_graphql_authorizations(:read_user_achievement) } +end diff --git a/spec/graphql/types/ci/catalog/resource_type_spec.rb b/spec/graphql/types/ci/catalog/resource_type_spec.rb new file mode 100644 index 00000000000..d0bb45a4f1d --- /dev/null +++ b/spec/graphql/types/ci/catalog/resource_type_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Ci::Catalog::ResourceType, feature_category: :pipeline_composition do + specify { expect(described_class.graphql_name).to eq('CiCatalogResource') } + + it 'exposes the expected fields' do + expected_fields = %i[ + id + name + description + icon + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/ci/config/include_type_enum_spec.rb b/spec/graphql/types/ci/config/include_type_enum_spec.rb index a88316ae6f2..a75b9018a2e 100644 --- a/spec/graphql/types/ci/config/include_type_enum_spec.rb +++ b/spec/graphql/types/ci/config/include_type_enum_spec.rb @@ -6,6 +6,6 @@ RSpec.describe GitlabSchema.types['CiConfigIncludeType'] do it { expect(described_class.graphql_name).to eq('CiConfigIncludeType') } it 'exposes all the existing include types' do - expect(described_class.values.keys).to match_array(%w[remote local file template]) + expect(described_class.values.keys).to match_array(%w[remote local file template component]) end end diff --git a/spec/graphql/types/ci/inherited_ci_variable_type_spec.rb b/spec/graphql/types/ci/inherited_ci_variable_type_spec.rb new file mode 100644 index 00000000000..daf80ff9978 --- /dev/null +++ b/spec/graphql/types/ci/inherited_ci_variable_type_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['InheritedCiVariable'], feature_category: :secrets_management do + specify do + expect(described_class).to have_graphql_fields( + :id, + :key, + :raw, + :variable_type, + :environment_scope, + :masked, + :protected, + :group_name, + :group_ci_cd_settings_path + ).at_least + end +end diff --git a/spec/graphql/types/ci/job_trace_type_spec.rb b/spec/graphql/types/ci/job_trace_type_spec.rb new file mode 100644 index 00000000000..71803aa9ece --- /dev/null +++ b/spec/graphql/types/ci/job_trace_type_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiJobTrace'], feature_category: :continuous_integration do + include GraphqlHelpers + + let_it_be(:job) { create(:ci_build) } + + it 'has the correct fields' do + expected_fields = [:html_summary] + + expect(described_class).to have_graphql_fields(*expected_fields) + end + + it 'shows the correct trace contents' do + job.trace.set('BUILD TRACE') + + expect_next_instance_of(Gitlab::Ci::Trace) do |trace| + expect(trace).to receive(:html).with(last_lines: 10).and_call_original + end + + resolved_field = resolve_field(:html_summary, job.trace) + + expect(resolved_field).to eq("<span>BUILD TRACE</span>") + end +end diff --git a/spec/graphql/types/ci/job_type_spec.rb b/spec/graphql/types/ci/job_type_spec.rb index 714eaebfe73..e927bac431c 100644 --- a/spec/graphql/types/ci/job_type_spec.rb +++ b/spec/graphql/types/ci/job_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Types::Ci::JobType do +RSpec.describe Types::Ci::JobType, feature_category: :continuous_integration do include GraphqlHelpers specify { expect(described_class.graphql_name).to eq('CiJob') } @@ -40,6 +40,8 @@ RSpec.describe Types::Ci::JobType do refPath retryable retried + runner + runnerManager scheduledAt schedulingType shortSha @@ -51,6 +53,11 @@ RSpec.describe Types::Ci::JobType do triggered userPermissions webPath + playPath + canPlayJob + scheduled + trace + failure_message ] expect(described_class).to have_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/ci/runner_manager_type_spec.rb b/spec/graphql/types/ci/runner_manager_type_spec.rb new file mode 100644 index 00000000000..240e1edbf78 --- /dev/null +++ b/spec/graphql/types/ci/runner_manager_type_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiRunnerManager'], feature_category: :runner_fleet do + specify { expect(described_class.graphql_name).to eq('CiRunnerManager') } + + specify { expect(described_class).to require_graphql_authorizations(:read_runner_manager) } + + it 'contains attributes related to a runner manager' do + expected_fields = %w[ + architecture_name contacted_at created_at executor_name id ip_address platform_name revision + runner status system_id version + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/ci/runner_type_spec.rb b/spec/graphql/types/ci/runner_type_spec.rb index a2d107ae295..dc664f281b7 100644 --- a/spec/graphql/types/ci/runner_type_spec.rb +++ b/spec/graphql/types/ci/runner_type_spec.rb @@ -9,11 +9,11 @@ RSpec.describe GitlabSchema.types['CiRunner'], feature_category: :runner do it 'contains attributes related to a runner' do expected_fields = %w[ - id description created_at contacted_at maximum_timeout access_level active paused status + id description created_by created_at contacted_at managers maximum_timeout access_level active paused status version short_sha revision locked run_untagged ip_address runner_type tag_list - project_count job_count admin_url edit_admin_url user_permissions executor_name architecture_name platform_name - maintenance_note maintenance_note_html groups projects jobs token_expires_at owner_project job_execution_status - ephemeral_authentication_token + project_count job_count admin_url edit_admin_url register_admin_url user_permissions executor_name + architecture_name platform_name maintenance_note maintenance_note_html groups projects jobs token_expires_at + owner_project job_execution_status ephemeral_authentication_token ephemeral_register_url ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/ci/variable_sort_enum_spec.rb b/spec/graphql/types/ci/variable_sort_enum_spec.rb index 1702360a21f..8bfe6dde915 100644 --- a/spec/graphql/types/ci/variable_sort_enum_spec.rb +++ b/spec/graphql/types/ci/variable_sort_enum_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Types::Ci::VariableSortEnum, feature_category: :pipeline_authoring do +RSpec.describe Types::Ci::VariableSortEnum, feature_category: :secrets_management do it 'exposes the available order methods' do expect(described_class.values).to match( 'KEY_ASC' => have_attributes(value: :key_asc), diff --git a/spec/graphql/types/clusters/agent_activity_event_type_spec.rb b/spec/graphql/types/clusters/agent_activity_event_type_spec.rb index cae75485846..f89bd877920 100644 --- a/spec/graphql/types/clusters/agent_activity_event_type_spec.rb +++ b/spec/graphql/types/clusters/agent_activity_event_type_spec.rb @@ -6,6 +6,6 @@ RSpec.describe GitlabSchema.types['ClusterAgentActivityEvent'] do let(:fields) { %i[recorded_at kind level user agent_token] } it { expect(described_class.graphql_name).to eq('ClusterAgentActivityEvent') } - it { expect(described_class).to require_graphql_authorizations(:read_cluster) } + it { expect(described_class).to require_graphql_authorizations(:read_cluster_agent) } it { expect(described_class).to have_graphql_fields(fields) } end diff --git a/spec/graphql/types/clusters/agent_token_type_spec.rb b/spec/graphql/types/clusters/agent_token_type_spec.rb index 1ca6d690c80..e04b33f92f8 100644 --- a/spec/graphql/types/clusters/agent_token_type_spec.rb +++ b/spec/graphql/types/clusters/agent_token_type_spec.rb @@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['ClusterAgentToken'] do it { expect(described_class.graphql_name).to eq('ClusterAgentToken') } - it { expect(described_class).to require_graphql_authorizations(:read_cluster) } + it { expect(described_class).to require_graphql_authorizations(:read_cluster_agent) } it { expect(described_class).to have_graphql_fields(fields) } end diff --git a/spec/graphql/types/clusters/agent_type_spec.rb b/spec/graphql/types/clusters/agent_type_spec.rb index bb1006c55c0..4bae0ea5602 100644 --- a/spec/graphql/types/clusters/agent_type_spec.rb +++ b/spec/graphql/types/clusters/agent_type_spec.rb @@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['ClusterAgent'] do it { expect(described_class.graphql_name).to eq('ClusterAgent') } - it { expect(described_class).to require_graphql_authorizations(:read_cluster) } + it { expect(described_class).to require_graphql_authorizations(:read_cluster_agent) } it { expect(described_class).to include_graphql_fields(*fields) } end diff --git a/spec/graphql/types/clusters/agents/authorizations/ci_access_type_spec.rb b/spec/graphql/types/clusters/agents/authorizations/ci_access_type_spec.rb new file mode 100644 index 00000000000..17725ec11e0 --- /dev/null +++ b/spec/graphql/types/clusters/agents/authorizations/ci_access_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ClusterAgentAuthorizationCiAccess'], + feature_category: :deployment_management do + let(:fields) { %i[agent config] } + + it { expect(described_class.graphql_name).to eq('ClusterAgentAuthorizationCiAccess') } + it { expect(described_class).to have_graphql_fields(fields) } +end diff --git a/spec/graphql/types/clusters/agents/authorizations/user_access_type_spec.rb b/spec/graphql/types/clusters/agents/authorizations/user_access_type_spec.rb new file mode 100644 index 00000000000..0e798cd1b18 --- /dev/null +++ b/spec/graphql/types/clusters/agents/authorizations/user_access_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ClusterAgentAuthorizationUserAccess'], + feature_category: :deployment_management do + let(:fields) { %i[agent config] } + + it { expect(described_class.graphql_name).to eq('ClusterAgentAuthorizationUserAccess') } + it { expect(described_class).to have_graphql_fields(fields) } +end diff --git a/spec/graphql/types/commit_signature_interface_spec.rb b/spec/graphql/types/commit_signature_interface_spec.rb index 4962131d9b5..d37c0d1b4fa 100644 --- a/spec/graphql/types/commit_signature_interface_spec.rb +++ b/spec/graphql/types/commit_signature_interface_spec.rb @@ -18,6 +18,11 @@ RSpec.describe GitlabSchema.types['CommitSignature'] do Types::CommitSignatures::X509SignatureType) end + it 'resolves SSH signatures' do + expect(described_class.resolve_type(build(:ssh_signature), {})).to eq( + Types::CommitSignatures::SshSignatureType) + end + it 'raises an error when type is not known' do expect { described_class.resolve_type(Class, {}) }.to raise_error('Unsupported commit signature type') end diff --git a/spec/graphql/types/commit_signatures/ssh_signature_type_spec.rb b/spec/graphql/types/commit_signatures/ssh_signature_type_spec.rb index 4ffb70a0b22..c16e29312a3 100644 --- a/spec/graphql/types/commit_signatures/ssh_signature_type_spec.rb +++ b/spec/graphql/types/commit_signatures/ssh_signature_type_spec.rb @@ -11,7 +11,7 @@ RSpec.describe GitlabSchema.types['SshSignature'], feature_category: :source_cod it 'contains attributes related to SSH signatures' do expect(described_class).to have_graphql_fields( - :user, :verification_status, :commit_sha, :project, :key + :user, :verification_status, :commit_sha, :project, :key, :key_fingerprint_sha256 ) end end diff --git a/spec/graphql/types/data_transfer/project_data_transfer_type_spec.rb b/spec/graphql/types/data_transfer/project_data_transfer_type_spec.rb new file mode 100644 index 00000000000..a93da279b7f --- /dev/null +++ b/spec/graphql/types/data_transfer/project_data_transfer_type_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ProjectDataTransfer'], feature_category: :source_code_management do + include GraphqlHelpers + + it 'includes the specific fields' do + expect(described_class).to have_graphql_fields( + :total_egress, :egress_nodes) + end + + describe '#total_egress' do + let_it_be(:project) { create(:project) } + let(:from) { Date.new(2022, 1, 1) } + let(:to) { Date.new(2023, 1, 1) } + let(:finder_result) { 40_000_000 } + + it 'returns mock data' do + expect(resolve_field(:total_egress, { from: from, to: to }, extras: { parent: project }, + arg_style: :internal)).to eq(finder_result) + end + + context 'when data_transfer_monitoring_mock_data is disabled' do + let(:relation) { instance_double(ActiveRecord::Relation) } + + before do + allow(relation).to receive(:sum).and_return(10) + stub_feature_flags(data_transfer_monitoring_mock_data: false) + end + + it 'calls sum on active record relation' do + expect(resolve_field(:total_egress, { egress_nodes: relation }, extras: { parent: project }, + arg_style: :internal)).to eq(10) + end + end + end +end diff --git a/spec/graphql/types/design_management/design_at_version_type_spec.rb b/spec/graphql/types/design_management/design_at_version_type_spec.rb index 4d61ecf62cc..06aefb6fea3 100644 --- a/spec/graphql/types/design_management/design_at_version_type_spec.rb +++ b/spec/graphql/types/design_management/design_at_version_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['DesignAtVersion'] do +RSpec.describe GitlabSchema.types['DesignAtVersion'], feature_category: :portfolio_management do it_behaves_like 'a GraphQL type with design fields' do let(:extra_design_fields) { %i[version design] } let_it_be(:design) { create(:design, :with_versions) } diff --git a/spec/graphql/types/design_management/design_type_spec.rb b/spec/graphql/types/design_management/design_type_spec.rb index 24b007a6b33..a093f785eb7 100644 --- a/spec/graphql/types/design_management/design_type_spec.rb +++ b/spec/graphql/types/design_management/design_type_spec.rb @@ -2,13 +2,16 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['Design'] do +RSpec.describe GitlabSchema.types['Design'], feature_category: :portfolio_management do specify { expect(described_class.interfaces).to include(Types::CurrentUserTodos) } specify { expect(described_class.interfaces).to include(Types::TodoableInterface) } it_behaves_like 'a GraphQL type with design fields' do - let(:extra_design_fields) { %i[notes current_user_todos discussions versions web_url commenters] } + let(:extra_design_fields) do + %i[notes current_user_todos discussions versions web_url commenters description descriptionHtml] + end + let_it_be(:design) { create(:design, :with_versions) } let(:object_id) { GitlabSchema.id_from_object(design) } let_it_be(:object_id_b) { GitlabSchema.id_from_object(create(:design, :with_versions)) } diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index 6820cf2738e..0fbf50fe258 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 merge_requests container_repositories container_repositories_count packages dependency_proxy_setting dependency_proxy_manifests dependency_proxy_blobs dependency_proxy_image_count - dependency_proxy_blob_count dependency_proxy_total_size + dependency_proxy_blob_count dependency_proxy_total_size dependency_proxy_total_size_in_bytes dependency_proxy_image_prefix dependency_proxy_image_ttl_policy shared_runners_setting timelogs organization_state_counts organizations contact_state_counts contacts work_item_types diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index 7c6cf137a1e..a9fe85ac62f 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -265,7 +265,10 @@ RSpec.describe GitlabSchema.types['Issue'] do context 'for an incident' do before do - issue.update!(issue_type: Issue.issue_types[:incident]) + issue.update!( + issue_type: WorkItems::Type.base_types[:incident], + work_item_type: WorkItems::Type.default_by_type(:incident) + ) end it { is_expected.to be_nil } @@ -277,44 +280,4 @@ RSpec.describe GitlabSchema.types['Issue'] do end end end - - describe 'type' do - let_it_be(:issue) { create(:issue, project: project) } - - let(:query) do - %( - query { - issue(id: "#{issue.to_gid}") { - type - } - } - ) - end - - subject(:execute) { GitlabSchema.execute(query, context: { current_user: user }).as_json } - - context 'when the issue_type_uses_work_item_types_table feature flag is enabled' do - it 'gets the type field from the work_item_types table' do - expect_next_instance_of(::IssuePresenter) do |presented_issue| - expect(presented_issue).to receive_message_chain(:work_item_type, :base_type) - end - - execute - end - end - - context 'when the issue_type_uses_work_item_types_table feature flag is disabled' do - before do - stub_feature_flags(issue_type_uses_work_item_types_table: false) - end - - it 'does not get the type field from the work_item_types table' do - expect_next_instance_of(::IssuePresenter) do |presented_issue| - expect(presented_issue).not_to receive(:work_item_type) - end - - execute - end - end - end end diff --git a/spec/graphql/types/key_type_spec.rb b/spec/graphql/types/key_type_spec.rb index 78144076467..13c00d94b37 100644 --- a/spec/graphql/types/key_type_spec.rb +++ b/spec/graphql/types/key_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['Key'], feature_category: :authentication_and_authorization do +RSpec.describe GitlabSchema.types['Key'], feature_category: :system_access do specify { expect(described_class.graphql_name).to eq('Key') } it 'contains attributes for SSH keys' do diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index 8a4c89fc340..bd271da55a9 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['MergeRequest'] do +RSpec.describe GitlabSchema.types['MergeRequest'], feature_category: :code_review_workflow do include GraphqlHelpers specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) } @@ -36,7 +36,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do commit_count current_user_todos conflicts auto_merge_enabled approved_by source_branch_protected squash_on_merge available_auto_merge_strategies has_ci mergeable commits committers commits_without_merge_commits squash security_auto_fix default_squash_commit_message - auto_merge_strategy merge_user + auto_merge_strategy merge_user award_emoji prepared_at ] expect(described_class).to have_graphql_fields(*expected_fields).at_least diff --git a/spec/graphql/types/permission_types/issue_spec.rb b/spec/graphql/types/permission_types/issue_spec.rb index 58c5808cbcc..8f43a4a44a0 100644 --- a/spec/graphql/types/permission_types/issue_spec.rb +++ b/spec/graphql/types/permission_types/issue_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Types::PermissionTypes::Issue do expected_permissions = [ :read_issue, :admin_issue, :update_issue, :reopen_issue, :read_design, :create_design, :destroy_design, - :create_note + :create_note, :update_design ] expected_permissions.each do |permission| diff --git a/spec/graphql/types/permission_types/work_item_spec.rb b/spec/graphql/types/permission_types/work_item_spec.rb index db6d78b1538..7e16b43a12f 100644 --- a/spec/graphql/types/permission_types/work_item_spec.rb +++ b/spec/graphql/types/permission_types/work_item_spec.rb @@ -5,7 +5,8 @@ require 'spec_helper' RSpec.describe Types::PermissionTypes::WorkItem do it do expected_permissions = [ - :read_work_item, :update_work_item, :delete_work_item, :admin_work_item + :read_work_item, :update_work_item, :delete_work_item, :admin_work_item, + :admin_parent_link, :set_work_item_metadata ] expected_permissions.each do |permission| diff --git a/spec/graphql/types/project_member_relation_enum_spec.rb b/spec/graphql/types/project_member_relation_enum_spec.rb index 3c947bf8406..a486844a687 100644 --- a/spec/graphql/types/project_member_relation_enum_spec.rb +++ b/spec/graphql/types/project_member_relation_enum_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Types::ProjectMemberRelationEnum do specify { expect(described_class.graphql_name).to eq('ProjectMemberRelation') } it 'exposes all the existing project member relation type values' do - expect(described_class.values.keys).to contain_exactly('DIRECT', 'INHERITED', 'DESCENDANTS', 'INVITED_GROUPS') + relation_types = %w[DIRECT INHERITED DESCENDANTS INVITED_GROUPS SHARED_INTO_ANCESTORS] + expect(described_class.values.keys).to contain_exactly(*relation_types) end end diff --git a/spec/graphql/types/project_statistics_redirect_type_spec.rb b/spec/graphql/types/project_statistics_redirect_type_spec.rb new file mode 100644 index 00000000000..3600a5b932f --- /dev/null +++ b/spec/graphql/types/project_statistics_redirect_type_spec.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ProjectStatisticsRedirect'], feature_category: :consumables_cost_management do + it 'has all the required fields' do + expect(described_class).to have_graphql_fields(:repository, :build_artifacts, :packages, + :wiki, :snippets, :container_registry) + end +end diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 7f26190830e..bcfdb05ca90 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -24,7 +24,7 @@ RSpec.describe GitlabSchema.types['Project'] do snippets_enabled jobs_enabled public_jobs open_issues_count import_status only_allow_merge_if_pipeline_succeeds request_access_enabled only_allow_merge_if_all_discussions_are_resolved printing_merge_request_link_enabled - namespace group statistics repository merge_requests merge_request issues + namespace group statistics statistics_details_paths repository merge_requests merge_request issues issue milestones pipelines removeSourceBranchAfterMerge pipeline_counts sentryDetailedError snippets grafanaIntegration autocloseReferencedIssues suggestion_commit_message environments environment boards jira_import_status jira_imports services releases release @@ -34,11 +34,11 @@ RSpec.describe GitlabSchema.types['Project'] do issue_status_counts terraform_states alert_management_integrations container_repositories container_repositories_count pipeline_analytics squash_read_only sast_ci_configuration - cluster_agent cluster_agents agent_configurations + cluster_agent cluster_agents agent_configurations ci_access_authorized_agents user_access_authorized_agents ci_template timelogs merge_commit_template squash_commit_template work_item_types recent_issue_boards ci_config_path_or_default packages_cleanup_policy ci_variables timelog_categories fork_targets branch_rules ci_config_variables pipeline_schedules languages - incident_management_timeline_event_tags visible_forks + incident_management_timeline_event_tags visible_forks inherited_ci_variables ] expect(described_class).to include_graphql_fields(*expected_fields) @@ -291,7 +291,7 @@ RSpec.describe GitlabSchema.types['Project'] do let_it_be(:project) { create(:project_empty_repo) } it 'raises an error' do - expect(subject['errors'][0]['message']).to eq('You must <a target="_blank" rel="noopener noreferrer" ' \ + expect(subject['errors'][0]['message']).to eq('UF You must <a target="_blank" rel="noopener noreferrer" ' \ 'href="http://localhost/help/user/project/repository/index.md#' \ 'add-files-to-a-repository">add at least one file to the ' \ 'repository</a> before using Security features.') @@ -333,6 +333,7 @@ RSpec.describe GitlabSchema.types['Project'] do :target_branches, :state, :draft, + :approved, :labels, :before, :after, @@ -676,8 +677,8 @@ RSpec.describe GitlabSchema.types['Project'] do subject { GitlabSchema.execute(query, context: { current_user: user }).as_json } before do - allow(::Gitlab::ServiceDeskEmail).to receive(:enabled?) { true } - allow(::Gitlab::ServiceDeskEmail).to receive(:address_for_key) { 'address-suffix@example.com' } + allow(::Gitlab::Email::ServiceDeskEmail).to receive(:enabled?) { true } + allow(::Gitlab::Email::ServiceDeskEmail).to receive(:address_for_key) { 'address-suffix@example.com' } end context 'when a user can admin issues' do diff --git a/spec/graphql/types/projects/fork_details_type_spec.rb b/spec/graphql/types/projects/fork_details_type_spec.rb index 8e20e2c8299..f79371ce4ca 100644 --- a/spec/graphql/types/projects/fork_details_type_spec.rb +++ b/spec/graphql/types/projects/fork_details_type_spec.rb @@ -9,6 +9,8 @@ RSpec.describe GitlabSchema.types['ForkDetails'], feature_category: :source_code fields = %i[ ahead behind + isSyncing + hasConflicts ] expect(described_class).to have_graphql_fields(*fields) diff --git a/spec/graphql/types/release_asset_link_type_spec.rb b/spec/graphql/types/release_asset_link_type_spec.rb index 0c903b8d27a..57a42a3966f 100644 --- a/spec/graphql/types/release_asset_link_type_spec.rb +++ b/spec/graphql/types/release_asset_link_type_spec.rb @@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['ReleaseAssetLink'] do it 'has the expected fields' do expected_fields = %w[ - id name url external link_type direct_asset_url direct_asset_path + id name url link_type direct_asset_url direct_asset_path ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/root_storage_statistics_type_spec.rb b/spec/graphql/types/root_storage_statistics_type_spec.rb index 07c8378e7a6..5dde6aa8b14 100644 --- a/spec/graphql/types/root_storage_statistics_type_spec.rb +++ b/spec/graphql/types/root_storage_statistics_type_spec.rb @@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['RootStorageStatistics'] do expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, :build_artifacts_size, :packages_size, :wiki_size, :snippets_size, :pipeline_artifacts_size, :uploads_size, :dependency_proxy_size, - :container_registry_size) + :container_registry_size, :registry_size_estimated) end specify { expect(described_class).to require_graphql_authorizations(:read_statistics) } diff --git a/spec/graphql/types/time_tracking/timelog_connection_type_spec.rb b/spec/graphql/types/time_tracking/timelog_connection_type_spec.rb index 5cfe561b42c..db1ffd4f59d 100644 --- a/spec/graphql/types/time_tracking/timelog_connection_type_spec.rb +++ b/spec/graphql/types/time_tracking/timelog_connection_type_spec.rb @@ -37,7 +37,7 @@ RSpec.describe GitlabSchema.types['TimelogConnection'], feature_category: :team_ context 'when requested' do it 'returns the total spent time' do - expect(total_spent_time).to eq(5064) + expect(total_spent_time).to eq('5064') end end end diff --git a/spec/graphql/types/timelog_type_spec.rb b/spec/graphql/types/timelog_type_spec.rb index 59a0e373c5d..aa05c5ffd94 100644 --- a/spec/graphql/types/timelog_type_spec.rb +++ b/spec/graphql/types/timelog_type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['Timelog'], feature_category: :team_planning do - let_it_be(:fields) { %i[id spent_at time_spent user issue merge_request note summary userPermissions] } + let_it_be(:fields) { %i[id spent_at time_spent user issue merge_request note summary userPermissions project] } it { expect(described_class.graphql_name).to eq('Timelog') } it { expect(described_class).to have_graphql_fields(fields) } diff --git a/spec/graphql/types/user_preferences_type_spec.rb b/spec/graphql/types/user_preferences_type_spec.rb index fac45443290..06749dda239 100644 --- a/spec/graphql/types/user_preferences_type_spec.rb +++ b/spec/graphql/types/user_preferences_type_spec.rb @@ -2,12 +2,13 @@ require 'spec_helper' -RSpec.describe Types::UserPreferencesType do +RSpec.describe Types::UserPreferencesType, feature_category: :user_profile do specify { expect(described_class.graphql_name).to eq('UserPreferences') } it 'exposes the expected fields' do expected_fields = %i[ issues_sort + visibility_pipeline_id_type ] expect(described_class).to have_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index a6b5d454b60..0b0dcf2fb6a 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -47,9 +47,10 @@ RSpec.describe GitlabSchema.types['User'], feature_category: :user_profile do profileEnableGitpodPath savedReplies savedReply + user_achievements ] - expect(described_class).to have_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end describe 'name field' do diff --git a/spec/graphql/types/visibility_pipeline_id_type_enum_spec.rb b/spec/graphql/types/visibility_pipeline_id_type_enum_spec.rb new file mode 100644 index 00000000000..f1dc6a79b29 --- /dev/null +++ b/spec/graphql/types/visibility_pipeline_id_type_enum_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::VisibilityPipelineIdTypeEnum, feature_category: :user_profile do + specify { expect(described_class.graphql_name).to eq('VisibilityPipelineIdType') } + + it 'exposes all visibility pipeline id types' do + expect(described_class.values.keys).to contain_exactly( + *UserPreference.visibility_pipeline_id_types.keys.map(&:upcase) + ) + end +end diff --git a/spec/graphql/types/work_item_type_spec.rb b/spec/graphql/types/work_item_type_spec.rb index 42d56598944..328450084c2 100644 --- a/spec/graphql/types/work_item_type_spec.rb +++ b/spec/graphql/types/work_item_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['WorkItem'] do +RSpec.describe GitlabSchema.types['WorkItem'], feature_category: :team_planning do specify { expect(described_class.graphql_name).to eq('WorkItem') } specify { expect(described_class).to require_graphql_authorizations(:read_work_item) } @@ -18,6 +18,7 @@ RSpec.describe GitlabSchema.types['WorkItem'] do id iid lock_version + namespace project state title title_html @@ -28,6 +29,8 @@ RSpec.describe GitlabSchema.types['WorkItem'] do updated_at closed_at web_url + create_note_email + reference ] expect(described_class).to have_graphql_fields(*fields) diff --git a/spec/graphql/types/work_items/available_export_fields_enum_spec.rb b/spec/graphql/types/work_items/available_export_fields_enum_spec.rb new file mode 100644 index 00000000000..9010aabe3cc --- /dev/null +++ b/spec/graphql/types/work_items/available_export_fields_enum_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['AvailableExportFields'], feature_category: :team_planning do + specify { expect(described_class.graphql_name).to eq('AvailableExportFields') } + + describe 'enum values' do + using RSpec::Parameterized::TableSyntax + + where(:field_name, :field_value) do + 'ID' | 'id' + 'TYPE' | 'type' + 'TITLE' | 'title' + 'DESCRIPTION' | 'description' + 'AUTHOR' | 'author' + 'AUTHOR_USERNAME' | 'author username' + 'CREATED_AT' | 'created_at' + end + + with_them do + it 'exposes correct available fields' do + expect(described_class.values[field_name].value).to eq(field_value) + end + end + end +end diff --git a/spec/graphql/types/work_items/widget_interface_spec.rb b/spec/graphql/types/work_items/widget_interface_spec.rb index a2b12ed52dc..d955ec5023e 100644 --- a/spec/graphql/types/work_items/widget_interface_spec.rb +++ b/spec/graphql/types/work_items/widget_interface_spec.rb @@ -15,11 +15,14 @@ RSpec.describe Types::WorkItems::WidgetInterface do using RSpec::Parameterized::TableSyntax where(:widget_class, :widget_type_name) do - WorkItems::Widgets::Description | Types::WorkItems::Widgets::DescriptionType - WorkItems::Widgets::Hierarchy | Types::WorkItems::Widgets::HierarchyType - WorkItems::Widgets::Assignees | Types::WorkItems::Widgets::AssigneesType - WorkItems::Widgets::Labels | Types::WorkItems::Widgets::LabelsType - WorkItems::Widgets::Notes | Types::WorkItems::Widgets::NotesType + WorkItems::Widgets::Description | Types::WorkItems::Widgets::DescriptionType + WorkItems::Widgets::Hierarchy | Types::WorkItems::Widgets::HierarchyType + WorkItems::Widgets::Assignees | Types::WorkItems::Widgets::AssigneesType + WorkItems::Widgets::Labels | Types::WorkItems::Widgets::LabelsType + WorkItems::Widgets::Notes | Types::WorkItems::Widgets::NotesType + WorkItems::Widgets::Notifications | Types::WorkItems::Widgets::NotificationsType + WorkItems::Widgets::CurrentUserTodos | Types::WorkItems::Widgets::CurrentUserTodosType + WorkItems::Widgets::AwardEmoji | Types::WorkItems::Widgets::AwardEmojiType end with_them do diff --git a/spec/graphql/types/work_items/widgets/award_emoji_type_spec.rb b/spec/graphql/types/work_items/widgets/award_emoji_type_spec.rb new file mode 100644 index 00000000000..493e628ac83 --- /dev/null +++ b/spec/graphql/types/work_items/widgets/award_emoji_type_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::WorkItems::Widgets::AwardEmojiType, feature_category: :team_planning do + it 'exposes the expected fields' do + expected_fields = %i[award_emoji downvotes upvotes type] + + expect(described_class.graphql_name).to eq('WorkItemWidgetAwardEmoji') + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/work_items/widgets/current_user_todos_input_type_spec.rb b/spec/graphql/types/work_items/widgets/current_user_todos_input_type_spec.rb new file mode 100644 index 00000000000..0ae660ffac0 --- /dev/null +++ b/spec/graphql/types/work_items/widgets/current_user_todos_input_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Types::WorkItems::Widgets::CurrentUserTodosInputType, feature_category: :team_planning do + it { expect(described_class.graphql_name).to eq('WorkItemWidgetCurrentUserTodosInput') } + + it { expect(described_class.arguments.keys).to match_array(%w[action todoId]) } +end diff --git a/spec/graphql/types/work_items/widgets/current_user_todos_type_spec.rb b/spec/graphql/types/work_items/widgets/current_user_todos_type_spec.rb new file mode 100644 index 00000000000..b39adefbd87 --- /dev/null +++ b/spec/graphql/types/work_items/widgets/current_user_todos_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::WorkItems::Widgets::CurrentUserTodosType, feature_category: :team_planning do + it 'exposes the expected fields' do + expected_fields = %i[current_user_todos type] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/work_items/widgets/hierarchy_update_input_type_spec.rb b/spec/graphql/types/work_items/widgets/hierarchy_update_input_type_spec.rb index 6221580605e..0d4d31faee1 100644 --- a/spec/graphql/types/work_items/widgets/hierarchy_update_input_type_spec.rb +++ b/spec/graphql/types/work_items/widgets/hierarchy_update_input_type_spec.rb @@ -5,5 +5,11 @@ require 'spec_helper' RSpec.describe ::Types::WorkItems::Widgets::HierarchyUpdateInputType do it { expect(described_class.graphql_name).to eq('WorkItemWidgetHierarchyUpdateInput') } - it { expect(described_class.arguments.keys).to match_array(%w[parentId childrenIds]) } + it 'accepts documented arguments' do + expect(described_class.arguments.keys).to match_array(%w[parentId childrenIds adjacentWorkItemId relativePosition]) + end + + it 'sets the type of relative_position argument to RelativePositionTypeEnum' do + expect(described_class.arguments['relativePosition'].type).to eq(Types::RelativePositionTypeEnum) + end end diff --git a/spec/graphql/types/work_items/widgets/notifications_type_spec.rb b/spec/graphql/types/work_items/widgets/notifications_type_spec.rb new file mode 100644 index 00000000000..4f457a24710 --- /dev/null +++ b/spec/graphql/types/work_items/widgets/notifications_type_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::WorkItems::Widgets::NotificationsType, feature_category: :team_planning do + it 'exposes the expected fields' do + expected_fields = %i[subscribed type] + + expect(described_class.graphql_name).to eq('WorkItemWidgetNotifications') + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/work_items/widgets/notifications_update_input_type_spec.rb b/spec/graphql/types/work_items/widgets/notifications_update_input_type_spec.rb new file mode 100644 index 00000000000..db0d02c597c --- /dev/null +++ b/spec/graphql/types/work_items/widgets/notifications_update_input_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Types::WorkItems::Widgets::NotificationsUpdateInputType, feature_category: :team_planning do + it { expect(described_class.graphql_name).to eq('WorkItemWidgetNotificationsUpdateInput') } + + it { expect(described_class.arguments.keys).to contain_exactly('subscribed') } +end |