diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/graphql/types | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/graphql/types')
39 files changed, 450 insertions, 29 deletions
diff --git a/spec/graphql/types/admin/analytics/instance_statistics/measurement_identifier_enum_spec.rb b/spec/graphql/types/admin/analytics/instance_statistics/measurement_identifier_enum_spec.rb index 625fb17bbf8..8a7408224a2 100644 --- a/spec/graphql/types/admin/analytics/instance_statistics/measurement_identifier_enum_spec.rb +++ b/spec/graphql/types/admin/analytics/instance_statistics/measurement_identifier_enum_spec.rb @@ -6,7 +6,10 @@ RSpec.describe GitlabSchema.types['MeasurementIdentifier'] do specify { expect(described_class.graphql_name).to eq('MeasurementIdentifier') } it 'exposes all the existing identifier values' do - identifiers = Analytics::InstanceStatistics::Measurement.identifiers.keys.map(&:upcase) + ee_only_identifiers = %w[billable_users] + identifiers = Analytics::InstanceStatistics::Measurement.identifiers.keys.reject do |x| + ee_only_identifiers.include?(x) + end.map(&:upcase) expect(described_class.values.keys).to match_array(identifiers) end diff --git a/spec/graphql/types/alert_management/http_integration_type_spec.rb b/spec/graphql/types/alert_management/http_integration_type_spec.rb new file mode 100644 index 00000000000..a4b64e2e37f --- /dev/null +++ b/spec/graphql/types/alert_management/http_integration_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['AlertManagementHttpIntegration'] do + specify { expect(described_class.graphql_name).to eq('AlertManagementHttpIntegration') } + + specify { expect(described_class).to require_graphql_authorizations(:admin_operations) } +end diff --git a/spec/graphql/types/alert_management/integration_type_enum_spec.rb b/spec/graphql/types/alert_management/integration_type_enum_spec.rb new file mode 100644 index 00000000000..0cdd67cb140 --- /dev/null +++ b/spec/graphql/types/alert_management/integration_type_enum_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['AlertManagementIntegrationType'] do + specify { expect(described_class.graphql_name).to eq('AlertManagementIntegrationType') } + + describe 'statuses' do + using RSpec::Parameterized::TableSyntax + + where(:name, :value) do + 'PROMETHEUS' | :prometheus + 'HTTP' | :http + end + + with_them do + it 'exposes a type with the correct value' do + expect(described_class.values[name].value).to eq(value) + end + end + end +end diff --git a/spec/graphql/types/alert_management/integration_type_spec.rb b/spec/graphql/types/alert_management/integration_type_spec.rb new file mode 100644 index 00000000000..5d149e6da6e --- /dev/null +++ b/spec/graphql/types/alert_management/integration_type_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['AlertManagementIntegration'] do + specify { expect(described_class.graphql_name).to eq('AlertManagementIntegration') } + + it 'exposes the expected fields' do + expected_fields = %i[ + id + type + name + active + token + url + api_url + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb b/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb new file mode 100644 index 00000000000..0e9994035d8 --- /dev/null +++ b/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['AlertManagementPrometheusIntegration'] do + include GraphqlHelpers + + specify { expect(described_class.graphql_name).to eq('AlertManagementPrometheusIntegration') } + specify { expect(described_class).to require_graphql_authorizations(:admin_project) } + + describe 'resolvers' do + shared_examples_for 'has field with value' do |field_name| + it 'correctly renders the field' do + expect(resolve_field(field_name, integration)).to eq(value) + end + end + + let_it_be_with_reload(:integration) { create(:prometheus_service) } + + it_behaves_like 'has field with value', 'name' do + let(:value) { integration.title } + end + + it_behaves_like 'has field with value', 'type' do + let(:value) { :prometheus } + end + + it_behaves_like 'has field with value', 'token' do + let(:value) { nil } + end + + it_behaves_like 'has field with value', 'url' do + let(:value) { "http://localhost/#{integration.project.full_path}/prometheus/alerts/notify.json" } + end + + it_behaves_like 'has field with value', 'active' do + let(:value) { integration.manual_configuration? } + end + + context 'with alerting setting' do + let_it_be(:alerting_setting) { create(:project_alerting_setting, project: integration.project) } + + it_behaves_like 'has field with value', 'token' do + let(:value) { alerting_setting.token } + end + end + + context 'without project' do + let_it_be(:integration) { create(:prometheus_service, project: nil, group: create(:group)) } + + it_behaves_like 'has field with value', 'token' do + let(:value) { nil } + end + + it_behaves_like 'has field with value', 'url' do + let(:value) { nil } + end + end + end +end diff --git a/spec/graphql/types/availability_enum_spec.rb b/spec/graphql/types/availability_enum_spec.rb new file mode 100644 index 00000000000..a9bdf5e4da6 --- /dev/null +++ b/spec/graphql/types/availability_enum_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['AvailabilityEnum'] do + specify { expect(described_class.graphql_name).to eq('AvailabilityEnum') } + + it 'exposes all the existing access levels' do + expect(described_class.values.keys).to match_array(%w[NOT_SET BUSY]) + end +end diff --git a/spec/graphql/types/ci/detailed_status_type_spec.rb b/spec/graphql/types/ci/detailed_status_type_spec.rb index ddb3a1450df..9fa3280657a 100644 --- a/spec/graphql/types/ci/detailed_status_type_spec.rb +++ b/spec/graphql/types/ci/detailed_status_type_spec.rb @@ -3,11 +3,30 @@ require 'spec_helper' RSpec.describe Types::Ci::DetailedStatusType do + include GraphqlHelpers + specify { expect(described_class.graphql_name).to eq('DetailedStatus') } - it "has all fields" do + it 'has all fields' do expect(described_class).to have_graphql_fields(:group, :icon, :favicon, :details_path, :has_details, :label, :text, :tooltip, :action) end + + describe 'action field' do + it 'correctly renders the field' do + stage = create(:ci_stage_entity, status: :skipped) + status = stage.detailed_status(stage.pipeline.user) + + expected_status = { + button_title: status.action_button_title, + icon: status.action_icon, + method: status.action_method, + path: status.action_path, + title: status.action_title + } + + expect(resolve_field('action', status)).to eq(expected_status) + end + end end diff --git a/spec/graphql/types/ci/job_type_spec.rb b/spec/graphql/types/ci/job_type_spec.rb index 3a54ed2efed..3dcb81eefbf 100644 --- a/spec/graphql/types/ci/job_type_spec.rb +++ b/spec/graphql/types/ci/job_type_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Types::Ci::JobType do it 'exposes the expected fields' do expected_fields = %i[ + pipeline name needs detailedStatus diff --git a/spec/graphql/types/ci/runner_setup_type_spec.rb b/spec/graphql/types/ci/runner_setup_type_spec.rb new file mode 100644 index 00000000000..197e717e964 --- /dev/null +++ b/spec/graphql/types/ci/runner_setup_type_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Ci::RunnerSetupType do + specify { expect(described_class.graphql_name).to eq('RunnerSetup') } + + it 'exposes the expected fields' do + expected_fields = %i[ + install_instructions + register_instructions + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/commit_type_spec.rb b/spec/graphql/types/commit_type_spec.rb index d222287270d..e9bc7f6bb94 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, :title, :description, :description_html, :message, :title_html, :authored_date, - :author_name, :author_gravatar, :author, :web_url, :web_path, :latest_pipeline, + :author_name, :author_gravatar, :author, :web_url, :web_path, :pipelines, :signature_html ) end diff --git a/spec/graphql/types/container_repository_cleanup_status_enum_spec.rb b/spec/graphql/types/container_repository_cleanup_status_enum_spec.rb new file mode 100644 index 00000000000..36cfc789ee9 --- /dev/null +++ b/spec/graphql/types/container_repository_cleanup_status_enum_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ContainerRepositoryCleanupStatus'] do + it 'exposes all statuses' do + expected_keys = ContainerRepository.expiration_policy_cleanup_statuses + .keys + .map { |k| k.gsub('cleanup_', '') } + .map(&:upcase) + expect(described_class.values.keys).to contain_exactly(*expected_keys) + end +end diff --git a/spec/graphql/types/container_repository_details_type_spec.rb b/spec/graphql/types/container_repository_details_type_spec.rb new file mode 100644 index 00000000000..b5ff460fcf7 --- /dev/null +++ b/spec/graphql/types/container_repository_details_type_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ContainerRepositoryDetails'] do + fields = %i[id name path location created_at updated_at expiration_policy_started_at status tags_count can_delete expiration_policy_cleanup_status tags] + + it { expect(described_class.graphql_name).to eq('ContainerRepositoryDetails') } + + it { expect(described_class.description).to eq('Details of a container repository') } + + it { expect(described_class).to require_graphql_authorizations(:read_container_image) } + + it { expect(described_class).to have_graphql_fields(fields) } + + describe 'tags field' do + subject { described_class.fields['tags'] } + + it 'returns tags connection type' do + is_expected.to have_graphql_type(Types::ContainerRepositoryTagType.connection_type) + end + end +end diff --git a/spec/graphql/types/container_repository_status_enum_spec.rb b/spec/graphql/types/container_repository_status_enum_spec.rb new file mode 100644 index 00000000000..9598879779a --- /dev/null +++ b/spec/graphql/types/container_repository_status_enum_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ContainerRepositoryStatus'] do + it 'exposes all statuses' do + expect(described_class.values.keys).to contain_exactly(*ContainerRepository.statuses.keys.map(&:upcase)) + end +end diff --git a/spec/graphql/types/container_repository_tag_type_spec.rb b/spec/graphql/types/container_repository_tag_type_spec.rb new file mode 100644 index 00000000000..1d1a76d6916 --- /dev/null +++ b/spec/graphql/types/container_repository_tag_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ContainerRepositoryTag'] do + fields = %i[name path location digest revision short_revision total_size created_at can_delete] + + it { expect(described_class.graphql_name).to eq('ContainerRepositoryTag') } + + it { expect(described_class.description).to eq('A tag from a container repository') } + + it { expect(described_class).to require_graphql_authorizations(:read_container_image) } + + it { expect(described_class).to have_graphql_fields(fields) } +end diff --git a/spec/graphql/types/container_repository_type_spec.rb b/spec/graphql/types/container_repository_type_spec.rb new file mode 100644 index 00000000000..3d3445ba5c3 --- /dev/null +++ b/spec/graphql/types/container_repository_type_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ContainerRepository'] do + fields = %i[id name path location created_at updated_at expiration_policy_started_at status tags_count can_delete expiration_policy_cleanup_status] + + it { expect(described_class.graphql_name).to eq('ContainerRepository') } + + it { expect(described_class.description).to eq('A container repository') } + + it { expect(described_class).to require_graphql_authorizations(:read_container_image) } + + it { expect(described_class).to have_graphql_fields(fields) } + + describe 'status field' do + subject { described_class.fields['status'] } + + it 'returns status enum' do + is_expected.to have_graphql_type(Types::ContainerRepositoryStatusEnum) + end + end + + describe 'expiration_policy_cleanup_status field' do + subject { described_class.fields['expirationPolicyCleanupStatus'] } + + it 'returns cleanup status enum' do + is_expected.to have_graphql_type(Types::ContainerRepositoryCleanupStatusEnum) + end + end +end diff --git a/spec/graphql/types/countable_connection_type_spec.rb b/spec/graphql/types/countable_connection_type_spec.rb index af34611ecfe..3b3c02baa5d 100644 --- a/spec/graphql/types/countable_connection_type_spec.rb +++ b/spec/graphql/types/countable_connection_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['IssueConnection'] do +RSpec.describe GitlabSchema.types['MergeRequestConnection'] do it 'has the expected fields' do expected_fields = %i[count page_info edges nodes] diff --git a/spec/graphql/types/custom_emoji_type_spec.rb b/spec/graphql/types/custom_emoji_type_spec.rb new file mode 100644 index 00000000000..7f3c99e4b63 --- /dev/null +++ b/spec/graphql/types/custom_emoji_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CustomEmoji'] do + specify { expect(described_class.graphql_name).to eq('CustomEmoji') } + + specify { expect(described_class).to require_graphql_authorizations(:read_custom_emoji) } + + specify { expect(described_class).to have_graphql_fields(:id, :name, :url, :external) } +end diff --git a/spec/graphql/types/environment_type_spec.rb b/spec/graphql/types/environment_type_spec.rb index 2220f847e4e..3671d35e8a5 100644 --- a/spec/graphql/types/environment_type_spec.rb +++ b/spec/graphql/types/environment_type_spec.rb @@ -44,18 +44,12 @@ RSpec.describe GitlabSchema.types['Environment'] do expect(subject['data']['project']['environment']['name']).to eq(environment.name) end - it 'returns the path when the feature is enabled' do + it 'returns the path to the environment' do expect(subject['data']['project']['environment']['path']).to eq( Gitlab::Routing.url_helpers.project_environment_path(project, environment) ) end - it 'does not return the path when the feature is disabled' do - stub_feature_flags(expose_environment_path_in_alert_details: false) - - expect(subject['data']['project']['environment']['path']).to be_nil - end - context 'when query alert data for the environment' do let_it_be(:query) do %( diff --git a/spec/graphql/types/global_id_type_spec.rb b/spec/graphql/types/global_id_type_spec.rb index 7589b0e285e..cb129868f7e 100644 --- a/spec/graphql/types/global_id_type_spec.rb +++ b/spec/graphql/types/global_id_type_spec.rb @@ -45,8 +45,7 @@ RSpec.describe Types::GlobalIDType do end it 'rejects nil' do - expect { described_class.coerce_isolated_input(nil) } - .to raise_error(GraphQL::CoercionError) + expect(described_class.coerce_isolated_input(nil)).to be_nil end it 'rejects gids from different apps' do diff --git a/spec/graphql/types/grafana_integration_type_spec.rb b/spec/graphql/types/grafana_integration_type_spec.rb index b4658db08d7..816264c36c8 100644 --- a/spec/graphql/types/grafana_integration_type_spec.rb +++ b/spec/graphql/types/grafana_integration_type_spec.rb @@ -7,7 +7,6 @@ RSpec.describe GitlabSchema.types['GrafanaIntegration'] do %i[ id grafana_url - token enabled created_at updated_at diff --git a/spec/graphql/types/group_invitation_type_spec.rb b/spec/graphql/types/group_invitation_type_spec.rb new file mode 100644 index 00000000000..dab2d43fc90 --- /dev/null +++ b/spec/graphql/types/group_invitation_type_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::GroupInvitationType do + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Group) } + + specify { expect(described_class.graphql_name).to eq('GroupInvitation') } + + specify { expect(described_class).to require_graphql_authorizations(:read_group) } + + it 'has the expected fields' do + expected_fields = %w[ + email access_level created_by created_at updated_at expires_at group + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/invitation_interface_spec.rb b/spec/graphql/types/invitation_interface_spec.rb new file mode 100644 index 00000000000..8f345c58ca3 --- /dev/null +++ b/spec/graphql/types/invitation_interface_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::InvitationInterface do + it 'exposes the expected fields' do + expected_fields = %i[ + email + access_level + created_by + created_at + updated_at + expires_at + user + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end + + describe '.resolve_type' do + subject { described_class.resolve_type(object, {}) } + + context 'for project member' do + let(:object) { build(:project_member) } + + it { is_expected.to be Types::ProjectInvitationType } + end + + context 'for group member' do + let(:object) { build(:group_member) } + + it { is_expected.to be Types::GroupInvitationType } + end + + context 'for an unknown type' do + let(:object) { build(:user) } + + it 'raises an error' do + expect { subject }.to raise_error(Gitlab::Graphql::Errors::BaseError) + end + end + end +end diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index c55e624dd11..558fc479af1 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -14,10 +14,10 @@ RSpec.describe GitlabSchema.types['Issue'] do specify { expect(described_class.interfaces).to include(Types::CurrentUserTodos) } it 'has specific fields' do - fields = %i[id iid title description state reference author assignees participants labels milestone due_date - confidential discussion_locked upvotes downvotes user_notes_count web_path web_url relative_position - subscribed time_estimate total_time_spent closed_at created_at updated_at task_completion_status - designs design_collection alert_management_alert severity current_user_todos] + fields = %i[id iid title description state reference author assignees updated_by participants labels milestone due_date + confidential discussion_locked upvotes downvotes 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] fields.each do |field_name| expect(described_class).to have_graphql_field(field_name) diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index 9d901655b7b..8800250b103 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -17,11 +17,11 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do description_html state created_at updated_at source_project target_project project project_id source_project_id target_project_id source_branch target_branch work_in_progress merge_when_pipeline_succeeds diff_head_sha - merge_commit_sha user_notes_count should_remove_source_branch + merge_commit_sha user_notes_count user_discussions_count should_remove_source_branch diff_refs diff_stats diff_stats_summary force_remove_source_branch merge_status in_progress_merge_commit_sha merge_error allow_collaboration should_be_rebased rebase_commit_sha - rebase_in_progress merge_commit_message default_merge_commit_message + rebase_in_progress default_merge_commit_message merge_ongoing mergeable_discussions_state web_url source_branch_exists target_branch_exists upvotes downvotes head_pipeline pipelines task_completion_status diff --git a/spec/graphql/types/permission_types/note_spec.rb b/spec/graphql/types/permission_types/note_spec.rb index 9769c7b3aa3..d75284951c7 100644 --- a/spec/graphql/types/permission_types/note_spec.rb +++ b/spec/graphql/types/permission_types/note_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['NotePermissions'] do it 'has the expected fields' do expected_permissions = [ - :read_note, :create_note, :admin_note, :resolve_note, :award_emoji + :read_note, :create_note, :admin_note, :resolve_note, :reposition_note, :award_emoji ] - expect(described_class).to have_graphql_fields(expected_permissions) + expect(described_class).to have_graphql_fields(expected_permissions).only end end diff --git a/spec/graphql/types/project_invitation_type_spec.rb b/spec/graphql/types/project_invitation_type_spec.rb new file mode 100644 index 00000000000..148a763a5fa --- /dev/null +++ b/spec/graphql/types/project_invitation_type_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::ProjectInvitationType do + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Project) } + + specify { expect(described_class.graphql_name).to eq('ProjectInvitation') } + + specify { expect(described_class).to require_graphql_authorizations(:read_project) } + + it 'has the expected fields' do + expected_fields = %w[ + access_level created_by created_at updated_at expires_at project user + ] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/project_statistics_type_spec.rb b/spec/graphql/types/project_statistics_type_spec.rb index e6cffd407de..407ce82e73a 100644 --- a/spec/graphql/types/project_statistics_type_spec.rb +++ b/spec/graphql/types/project_statistics_type_spec.rb @@ -6,6 +6,6 @@ RSpec.describe GitlabSchema.types['ProjectStatistics'] do it 'has all the required fields' do expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, :build_artifacts_size, :packages_size, :commit_count, - :wiki_size, :snippets_size) + :wiki_size, :snippets_size, :uploads_size) end end diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 8aa9e1138cc..be579e92fb3 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -27,7 +27,8 @@ RSpec.describe GitlabSchema.types['Project'] do environment boards jira_import_status jira_imports services releases release alert_management_alerts alert_management_alert alert_management_alert_status_counts container_expiration_policy service_desk_enabled service_desk_address - issue_status_counts terraform_states + issue_status_counts terraform_states alert_management_integrations + ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/projects/services_enum_spec.rb b/spec/graphql/types/projects/services_enum_spec.rb index dac1213daf3..b8da9305de4 100644 --- a/spec/graphql/types/projects/services_enum_spec.rb +++ b/spec/graphql/types/projects/services_enum_spec.rb @@ -11,5 +11,5 @@ RSpec.describe GitlabSchema.types['ServiceType'] do end def available_services_enum - ::Service.services_types.map(&:underscore).map(&:upcase) + ::Service.available_services_types(include_dev: false).map(&:underscore).map(&:upcase) end diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index 1d9ca8323f8..7a0b3035607 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -80,4 +80,18 @@ RSpec.describe GitlabSchema.types['Query'] do is_expected.to have_graphql_type(Types::Ci::RunnerPlatformType.connection_type) end end + + describe 'runner_setup field' do + subject { described_class.fields['runnerSetup'] } + + it 'returns runner setup instructions' do + is_expected.to have_graphql_type(Types::Ci::RunnerSetupType) + end + end + + describe 'container_repository field' do + subject { described_class.fields['containerRepository'] } + + it { is_expected.to have_graphql_type(Types::ContainerRepositoryDetailsType) } + end end diff --git a/spec/graphql/types/release_asset_link_input_type_spec.rb b/spec/graphql/types/release_asset_link_input_type_spec.rb new file mode 100644 index 00000000000..d97a91b609a --- /dev/null +++ b/spec/graphql/types/release_asset_link_input_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::ReleaseAssetLinkInputType do + specify { expect(described_class.graphql_name).to eq('ReleaseAssetLinkInput') } + + it 'has the correct arguments' do + expect(described_class.arguments.keys).to match_array(%w[name url directAssetPath linkType]) + end + + it 'sets the type of link_type argument to ReleaseAssetLinkTypeEnum' do + expect(described_class.arguments['linkType'].type).to eq(Types::ReleaseAssetLinkTypeEnum) + end +end diff --git a/spec/graphql/types/release_assets_input_type_spec.rb b/spec/graphql/types/release_assets_input_type_spec.rb new file mode 100644 index 00000000000..c44abe1e171 --- /dev/null +++ b/spec/graphql/types/release_assets_input_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::ReleaseAssetsInputType do + specify { expect(described_class.graphql_name).to eq('ReleaseAssetsInput') } + + it 'has the correct arguments' do + expect(described_class.arguments.keys).to match_array(%w[links]) + end + + it 'sets the type of links argument to ReleaseAssetLinkInputType' do + expect(described_class.arguments['links'].type.of_type.of_type).to eq(Types::ReleaseAssetLinkInputType) + end +end diff --git a/spec/graphql/types/release_links_type_spec.rb b/spec/graphql/types/release_links_type_spec.rb index d505f0a4b5c..38c38d58baa 100644 --- a/spec/graphql/types/release_links_type_spec.rb +++ b/spec/graphql/types/release_links_type_spec.rb @@ -8,8 +8,11 @@ RSpec.describe GitlabSchema.types['ReleaseLinks'] do it 'has the expected fields' do expected_fields = %w[ selfUrl - mergeRequestsUrl - issuesUrl + openedMergeRequestsUrl + mergedMergeRequestsUrl + closedMergeRequestsUrl + openedIssuesUrl + closedIssuesUrl editUrl ] diff --git a/spec/graphql/types/root_storage_statistics_type_spec.rb b/spec/graphql/types/root_storage_statistics_type_spec.rb index 79d474f13ad..4fef8f6eafd 100644 --- a/spec/graphql/types/root_storage_statistics_type_spec.rb +++ b/spec/graphql/types/root_storage_statistics_type_spec.rb @@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['RootStorageStatistics'] do it 'has all the required fields' 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) + :pipeline_artifacts_size, :uploads_size) end specify { expect(described_class).to require_graphql_authorizations(:read_statistics) } diff --git a/spec/graphql/types/security/report_types_enum_spec.rb b/spec/graphql/types/security/report_types_enum_spec.rb new file mode 100644 index 00000000000..2da852606c7 --- /dev/null +++ b/spec/graphql/types/security/report_types_enum_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['SecurityReportTypeEnum'] do + it 'exposes all security report types' do + expect(described_class.values.keys).to contain_exactly( + *::Security::SecurityJobsFinder.allowed_job_types.map(&:to_s).map(&:upcase) + ) + end +end diff --git a/spec/graphql/types/terraform/state_type_spec.rb b/spec/graphql/types/terraform/state_type_spec.rb index 51508208046..9f65bb926d7 100644 --- a/spec/graphql/types/terraform/state_type_spec.rb +++ b/spec/graphql/types/terraform/state_type_spec.rb @@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['TerraformState'] do it { expect(described_class).to require_graphql_authorizations(:read_terraform_state) } describe 'fields' do - let(:fields) { %i[id name locked_by_user locked_at created_at updated_at] } + let(:fields) { %i[id name locked_by_user locked_at latest_version created_at updated_at] } it { expect(described_class).to have_graphql_fields(fields) } @@ -17,5 +17,8 @@ RSpec.describe GitlabSchema.types['TerraformState'] do it { expect(described_class.fields['lockedAt'].type).not_to be_non_null } it { expect(described_class.fields['createdAt'].type).to be_non_null } it { expect(described_class.fields['updatedAt'].type).to be_non_null } + + it { expect(described_class.fields['latestVersion'].type).not_to be_non_null } + it { expect(described_class.fields['latestVersion'].complexity).to eq(3) } end end diff --git a/spec/graphql/types/terraform/state_version_type_spec.rb b/spec/graphql/types/terraform/state_version_type_spec.rb new file mode 100644 index 00000000000..1c1e95039dc --- /dev/null +++ b/spec/graphql/types/terraform/state_version_type_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['TerraformStateVersion'] do + it { expect(described_class.graphql_name).to eq('TerraformStateVersion') } + it { expect(described_class).to require_graphql_authorizations(:read_terraform_state) } + + describe 'fields' do + let(:fields) { %i[id created_by_user job created_at updated_at] } + + it { expect(described_class).to have_graphql_fields(fields) } + + it { expect(described_class.fields['id'].type).to be_non_null } + it { expect(described_class.fields['createdByUser'].type).not_to be_non_null } + it { expect(described_class.fields['job'].type).not_to be_non_null } + it { expect(described_class.fields['createdAt'].type).to be_non_null } + it { expect(described_class.fields['updatedAt'].type).to be_non_null } + end +end diff --git a/spec/graphql/types/user_status_type_spec.rb b/spec/graphql/types/user_status_type_spec.rb index c4421a9cc10..ced9c40d552 100644 --- a/spec/graphql/types/user_status_type_spec.rb +++ b/spec/graphql/types/user_status_type_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Types::UserStatusType do emoji message message_html + availability ] 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 1d5af24b3d9..c8953d9ccb7 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -24,6 +24,7 @@ RSpec.describe GitlabSchema.types['User'] do authoredMergeRequests assignedMergeRequests groupMemberships + groupCount projectMemberships starredProjects ] |