diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
commit | b39512ed755239198a9c294b6a45e65c05900235 (patch) | |
tree | d234a3efade1de67c46b9e5a38ce813627726aa7 /spec/graphql/types | |
parent | d31474cf3b17ece37939d20082b07f6657cc79a9 (diff) |
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'spec/graphql/types')
28 files changed, 247 insertions, 21 deletions
diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index 439678e7e16..b85716e4d21 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -209,7 +209,7 @@ RSpec.describe Types::BaseField do describe '#visible?' do context 'and has a feature_flag' do let(:flag) { :test_feature } - let(:field) { described_class.new(name: 'test', type: GraphQL::Types::String, feature_flag: flag, null: false) } + let(:field) { described_class.new(name: 'test', type: GraphQL::Types::String, _deprecated_feature_flag: flag, null: false) } let(:context) { {} } before do @@ -253,7 +253,7 @@ RSpec.describe Types::BaseField do describe '#description' do context 'feature flag given' do - let(:field) { described_class.new(name: 'test', type: GraphQL::Types::String, feature_flag: flag, null: false, description: 'Test description.') } + let(:field) { described_class.new(name: 'test', type: GraphQL::Types::String, _deprecated_feature_flag: flag, null: false, description: 'Test description.') } let(:flag) { :test_flag } it 'prepends the description' do @@ -299,7 +299,7 @@ RSpec.describe Types::BaseField do end it 'returns the correct availability in the description' do - expect(field.description). to eq expected_description + expect(field.description).to eq expected_description end end end @@ -313,11 +313,11 @@ RSpec.describe Types::BaseField do described_class.new(**base_args.merge(args)) end - it 'interacts well with the `feature_flag` property' do + it 'interacts well with the `_deprecated_feature_flag` property' do field = subject( deprecated: { milestone: '1.10', reason: 'Deprecation reason' }, description: 'Field description.', - feature_flag: 'foo_flag' + _deprecated_feature_flag: 'foo_flag' ) expect(field.description).to start_with('Field description. Available only when feature flag `foo_flag` is enabled.') diff --git a/spec/graphql/types/ci/group_variable_type_spec.rb b/spec/graphql/types/ci/group_variable_type_spec.rb new file mode 100644 index 00000000000..106935642f2 --- /dev/null +++ b/spec/graphql/types/ci/group_variable_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiGroupVariable'] do + specify { expect(described_class.interfaces).to contain_exactly(Types::Ci::VariableInterface) } + + specify { expect(described_class).to have_graphql_fields(:environment_scope, :masked, :protected).at_least } +end diff --git a/spec/graphql/types/ci/instance_variable_type_spec.rb b/spec/graphql/types/ci/instance_variable_type_spec.rb new file mode 100644 index 00000000000..cf4aaed31f1 --- /dev/null +++ b/spec/graphql/types/ci/instance_variable_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiInstanceVariable'] do + specify { expect(described_class.interfaces).to contain_exactly(Types::Ci::VariableInterface) } + + specify { expect(described_class).to have_graphql_fields(:masked, :protected).at_least } +end diff --git a/spec/graphql/types/ci/job_token_scope_type_spec.rb b/spec/graphql/types/ci/job_token_scope_type_spec.rb index c1a3c4dd54d..457d46b6896 100644 --- a/spec/graphql/types/ci/job_token_scope_type_spec.rb +++ b/spec/graphql/types/ci/job_token_scope_type_spec.rb @@ -34,7 +34,7 @@ RSpec.describe GitlabSchema.types['CiJobTokenScopeType'] do subject { GitlabSchema.execute(query, context: { current_user: current_user }).as_json } let(:projects_field) { subject.dig('data', 'project', 'ciJobTokenScope', 'projects', 'nodes') } - let(:returned_project_paths) { projects_field.map { |project| project['path']} } + let(:returned_project_paths) { projects_field.map { |project| project['path'] } } context 'with access to scope' do before do diff --git a/spec/graphql/types/ci/manual_variable_type_spec.rb b/spec/graphql/types/ci/manual_variable_type_spec.rb new file mode 100644 index 00000000000..2884c818a52 --- /dev/null +++ b/spec/graphql/types/ci/manual_variable_type_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiManualVariable'] do + specify { expect(described_class.interfaces).to contain_exactly(Types::Ci::VariableInterface) } +end diff --git a/spec/graphql/types/ci/project_variable_type_spec.rb b/spec/graphql/types/ci/project_variable_type_spec.rb new file mode 100644 index 00000000000..e6e045b2bca --- /dev/null +++ b/spec/graphql/types/ci/project_variable_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiProjectVariable'] do + specify { expect(described_class.interfaces).to contain_exactly(Types::Ci::VariableInterface) } + + specify { expect(described_class).to have_graphql_fields(:environment_scope, :masked, :protected).at_least } +end diff --git a/spec/graphql/types/ci/runner_upgrade_status_type_enum_spec.rb b/spec/graphql/types/ci/runner_upgrade_status_enum_spec.rb index 03c784dcbe7..ef378f3fc5a 100644 --- a/spec/graphql/types/ci/runner_upgrade_status_type_enum_spec.rb +++ b/spec/graphql/types/ci/runner_upgrade_status_enum_spec.rb @@ -2,13 +2,13 @@ require 'spec_helper' -RSpec.describe Types::Ci::RunnerUpgradeStatusTypeEnum do +RSpec.describe Types::Ci::RunnerUpgradeStatusEnum do let(:model_only_enum_values) { %w[not_processed] } let(:expected_graphql_source_values) do Ci::RunnerVersion.statuses.keys - model_only_enum_values end - specify { expect(described_class.graphql_name).to eq('CiRunnerUpgradeStatusType') } + specify { expect(described_class.graphql_name).to eq('CiRunnerUpgradeStatus') } it 'exposes all upgrade status values except not_processed' do expect(described_class.values.keys).to match_array( diff --git a/spec/graphql/types/ci/variable_input_type_spec.rb b/spec/graphql/types/ci/variable_input_type_spec.rb new file mode 100644 index 00000000000..a56b6287dee --- /dev/null +++ b/spec/graphql/types/ci/variable_input_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiVariableInput'] do + include GraphqlHelpers + + it 'has the correct arguments' do + expect(described_class.arguments.keys).to match_array(%w[key value]) + end +end diff --git a/spec/graphql/types/ci/variable_type_spec.rb b/spec/graphql/types/ci/variable_interface_spec.rb index a81e6adbab6..8cef0ac2a14 100644 --- a/spec/graphql/types/ci/variable_type_spec.rb +++ b/spec/graphql/types/ci/variable_interface_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['CiVariable'] do - it 'contains attributes related to CI variables' do + specify do expect(described_class).to have_graphql_fields( - :id, :key, :value, :variable_type, :protected, :masked, :raw, :environment_scope - ) + :id, :key, :value, :variable_type, :raw + ).at_least end end diff --git a/spec/graphql/types/customer_relations/contact_sort_enum_spec.rb b/spec/graphql/types/customer_relations/contact_sort_enum_spec.rb new file mode 100644 index 00000000000..5b0538042c8 --- /dev/null +++ b/spec/graphql/types/customer_relations/contact_sort_enum_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ContactSort'] do + specify { expect(described_class.graphql_name).to eq('ContactSort') } + + it_behaves_like 'common sort values' + + it 'exposes all the contact sort values' do + expect(described_class.values.keys).to include( + *%w[ + FIRST_NAME_ASC + FIRST_NAME_DESC + LAST_NAME_ASC + LAST_NAME_DESC + EMAIL_ASC + EMAIL_DESC + PHONE_ASC + PHONE_DESC + DESCRIPTION_ASC + DESCRIPTION_DESC + ORGANIZATION_ASC + ORGANIZATION_DESC + ] + ) + end +end diff --git a/spec/graphql/types/customer_relations/contact_state_counts_type_spec.rb b/spec/graphql/types/customer_relations/contact_state_counts_type_spec.rb new file mode 100644 index 00000000000..b022febb90f --- /dev/null +++ b/spec/graphql/types/customer_relations/contact_state_counts_type_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['ContactStateCounts'] do + let(:fields) do + %w[ + all + active + inactive + ] + end + + it { expect(described_class.graphql_name).to eq('ContactStateCounts') } + it { expect(described_class).to have_graphql_fields(fields) } + it { expect(described_class).to require_graphql_authorizations(:read_crm_contact) } +end diff --git a/spec/graphql/types/global_id_type_spec.rb b/spec/graphql/types/global_id_type_spec.rb index a57db9234f1..fa0b34113bc 100644 --- a/spec/graphql/types/global_id_type_spec.rb +++ b/spec/graphql/types/global_id_type_spec.rb @@ -114,7 +114,11 @@ RSpec.describe Types::GlobalIDType do end before do - deprecation = Gitlab::GlobalId::Deprecations::Deprecation.new(old_model_name: 'OldIssue', new_model_name: 'Issue', milestone: '10.0') + deprecation = Gitlab::GlobalId::Deprecations::NameDeprecation.new( + old_name: 'OldIssue', + new_name: 'Issue', + milestone: '10.0' + ) stub_global_id_deprecations(deprecation) end diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index 69c7eaf111f..72b3bb90194 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['Group'] do + include GraphqlHelpers + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Group) } specify { expect(described_class.graphql_name).to eq('Group') } @@ -22,8 +24,8 @@ 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 work_item_types - recent_issue_boards ci_variables + shared_runners_setting timelogs organizations contacts contact_state_counts + work_item_types recent_issue_boards ci_variables ] expect(described_class).to include_graphql_fields(*expected_fields) @@ -53,7 +55,52 @@ RSpec.describe GitlabSchema.types['Group'] do end end + describe 'contact_state_counts field' do + subject { described_class.fields['contactStateCounts'] } + + it { is_expected.to have_graphql_type(Types::CustomerRelations::ContactStateCountsType) } + it { is_expected.to have_graphql_resolver(Resolvers::Crm::ContactStateCountsResolver) } + end + it_behaves_like 'a GraphQL type with labels' do let(:labels_resolver_arguments) { [:search_term, :includeAncestorGroups, :includeDescendantGroups, :onlyGroupLabels] } end + + describe 'milestones' do + let(:user) { create(:user) } + let(:subgroup) { create(:group, parent: create(:group)) } + let(:query) do + %( + query { + group(fullPath: "#{subgroup.full_path}") { + milestones { + nodes { + id + title + projectMilestone + groupMilestone + subgroupMilestone + } + } + } + } + ) + end + + def clean_state_query + run_with_clean_state(query, context: { current_user: user }) + end + + it 'avoids N+1 queries' do + subgroup.add_reporter(user) + + create(:milestone, group: subgroup) + + control = ActiveRecord::QueryRecorder.new(skip_cached: false) { clean_state_query } + + create_list(:milestone, 2, group: subgroup) + + expect { clean_state_query }.not_to exceed_all_query_limit(control) + end + end end diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index e7454b85357..2a0ae79b2c4 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -167,7 +167,7 @@ RSpec.describe GitlabSchema.types['Issue'] do shared_examples_for 'does not include private notes' do it "does not return private notes" do notes = subject.dig("data", "project", "issue", "notes", 'edges') - notes_body = notes.map {|n| n.dig('node', 'body')} + notes_body = notes.map { |n| n.dig('node', 'body') } expect(notes.size).to eq 1 expect(notes_body).not_to include(private_note_body) @@ -178,7 +178,7 @@ RSpec.describe GitlabSchema.types['Issue'] do shared_examples_for 'includes private notes' do it "returns all notes" do notes = subject.dig("data", "project", "issue", "notes", 'edges') - notes_body = notes.map {|n| n.dig('node', 'body')} + notes_body = notes.map { |n| n.dig('node', 'body') } expect(notes.size).to eq 2 expect(notes_body).to include(private_note_body) @@ -209,7 +209,7 @@ RSpec.describe GitlabSchema.types['Issue'] do end describe 'hidden', :enable_admin_mode do - let_it_be(:admin) { create(:user, :admin)} + let_it_be(:admin) { create(:user, :admin) } let_it_be(:banned_user) { create(:user, :banned) } let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public) } diff --git a/spec/graphql/types/namespace_type_spec.rb b/spec/graphql/types/namespace_type_spec.rb index 3b7f7e65e4b..168a6ba4eaa 100644 --- a/spec/graphql/types/namespace_type_spec.rb +++ b/spec/graphql/types/namespace_type_spec.rb @@ -9,6 +9,7 @@ RSpec.describe GitlabSchema.types['Namespace'] do expected_fields = %w[ id name path full_name full_path description description_html visibility lfs_enabled request_access_enabled projects root_storage_statistics shared_runners_setting + timelog_categories ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/notes/note_type_spec.rb b/spec/graphql/types/notes/note_type_spec.rb index 03ff7828cf5..cbf7f086dbe 100644 --- a/spec/graphql/types/notes/note_type_spec.rb +++ b/spec/graphql/types/notes/note_type_spec.rb @@ -9,6 +9,7 @@ RSpec.describe GitlabSchema.types['Note'] do body body_html confidential + internal created_at discussion id diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index ed93d31da0f..5ff7653ce39 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -37,7 +37,7 @@ RSpec.describe GitlabSchema.types['Project'] do cluster_agent cluster_agents agent_configurations 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 - recent_issue_boards ci_config_path_or_default ci_variables + timelog_categories fork_targets ] expect(described_class).to include_graphql_fields(*expected_fields) @@ -195,8 +195,8 @@ RSpec.describe GitlabSchema.types['Project'] do expect(secure_analyzers['type']).to eq('string') expect(secure_analyzers['field']).to eq('SECURE_ANALYZERS_PREFIX') expect(secure_analyzers['label']).to eq('Image prefix') - expect(secure_analyzers['defaultValue']).to eq(secure_analyzers_prefix) - expect(secure_analyzers['value']).to eq(secure_analyzers_prefix) + expect(secure_analyzers['defaultValue']).to eq('$CI_TEMPLATE_REGISTRY_HOST/security-products') + expect(secure_analyzers['value']).to eq('$CI_TEMPLATE_REGISTRY_HOST/security-products') expect(secure_analyzers['size']).to eq('LARGE') expect(secure_analyzers['options']).to be_nil end diff --git a/spec/graphql/types/projects/service_type_enum_spec.rb b/spec/graphql/types/projects/service_type_enum_spec.rb index ead69e60f6c..f7256910bb0 100644 --- a/spec/graphql/types/projects/service_type_enum_spec.rb +++ b/spec/graphql/types/projects/service_type_enum_spec.rb @@ -35,6 +35,7 @@ RSpec.describe GitlabSchema.types['ServiceType'] do PIPELINES_EMAIL_SERVICE PIVOTALTRACKER_SERVICE PROMETHEUS_SERVICE + PUMBLE_SERVICE PUSHOVER_SERVICE REDMINE_SERVICE SHIMO_SERVICE diff --git a/spec/graphql/types/subscription_type_spec.rb b/spec/graphql/types/subscription_type_spec.rb index 1a2629ed422..9b043fa52cf 100644 --- a/spec/graphql/types/subscription_type_spec.rb +++ b/spec/graphql/types/subscription_type_spec.rb @@ -9,6 +9,7 @@ RSpec.describe GitlabSchema.types['Subscription'] do issue_crm_contacts_updated issuable_title_updated issuable_labels_updated + issuable_dates_updated ] expect(described_class).to have_graphql_fields(*expected_fields).only diff --git a/spec/graphql/types/time_tracking/timelog_category_type_spec.rb b/spec/graphql/types/time_tracking/timelog_category_type_spec.rb new file mode 100644 index 00000000000..a14069e8b58 --- /dev/null +++ b/spec/graphql/types/time_tracking/timelog_category_type_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['TimeTrackingTimelogCategory'] do + let(:fields) do + %w[ + id + name + description + color + billable + billing_rate + created_at + updated_at + ] + end + + it { expect(described_class.graphql_name).to eq('TimeTrackingTimelogCategory') } + it { expect(described_class).to have_graphql_fields(fields) } + it { expect(described_class).to require_graphql_authorizations(:read_timelog_category) } +end diff --git a/spec/graphql/types/upload_type_spec.rb b/spec/graphql/types/upload_type_spec.rb new file mode 100644 index 00000000000..2b959fbf105 --- /dev/null +++ b/spec/graphql/types/upload_type_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['FileUpload'] do + it { expect(described_class).to require_graphql_authorizations(:read_upload) } + + it 'has the expected fields' do + expected_fields = %w[id size path] + + expect(described_class).to include_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index fec6a771640..dcf25ff0667 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -49,7 +49,7 @@ RSpec.describe GitlabSchema.types['User'] do end describe 'name field' do - let_it_be(:admin) { create(:user, :admin)} + let_it_be(:admin) { create(:user, :admin) } let_it_be(:user) { create(:user) } let_it_be(:requested_user) { create(:user, name: 'John Smith') } let_it_be(:requested_project_bot) { create(:user, :project_bot, name: 'Project bot') } diff --git a/spec/graphql/types/work_item_type_spec.rb b/spec/graphql/types/work_item_type_spec.rb index 7ed58786b5b..c556424b0b4 100644 --- a/spec/graphql/types/work_item_type_spec.rb +++ b/spec/graphql/types/work_item_type_spec.rb @@ -11,16 +11,21 @@ RSpec.describe GitlabSchema.types['WorkItem'] do it 'has specific fields' do fields = %i[ + confidential description description_html id iid lock_version + project state title title_html userPermissions widgets work_item_type + created_at + updated_at + closed_at ] fields.each do |field_name| diff --git a/spec/graphql/types/work_items/widget_interface_spec.rb b/spec/graphql/types/work_items/widget_interface_spec.rb index caf986c961f..b9e8edacf15 100644 --- a/spec/graphql/types/work_items/widget_interface_spec.rb +++ b/spec/graphql/types/work_items/widget_interface_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Types::WorkItems::WidgetInterface 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 end with_them do diff --git a/spec/graphql/types/work_items/widgets/assignees_input_type_spec.rb b/spec/graphql/types/work_items/widgets/assignees_input_type_spec.rb new file mode 100644 index 00000000000..2fcda2a43be --- /dev/null +++ b/spec/graphql/types/work_items/widgets/assignees_input_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Types::WorkItems::Widgets::AssigneesInputType do + it { expect(described_class.graphql_name).to eq('WorkItemWidgetAssigneesInput') } + + it { expect(described_class.arguments.keys).to match_array(%w[assigneeIds]) } +end diff --git a/spec/graphql/types/work_items/widgets/labels_type_spec.rb b/spec/graphql/types/work_items/widgets/labels_type_spec.rb new file mode 100644 index 00000000000..028ebe979f3 --- /dev/null +++ b/spec/graphql/types/work_items/widgets/labels_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::WorkItems::Widgets::LabelsType do + it 'exposes the expected fields' do + expected_fields = %i[labels allowsScopedLabels type] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/work_items/widgets/start_and_due_date_type_spec.rb b/spec/graphql/types/work_items/widgets/start_and_due_date_type_spec.rb new file mode 100644 index 00000000000..ddc26d964be --- /dev/null +++ b/spec/graphql/types/work_items/widgets/start_and_due_date_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::WorkItems::Widgets::StartAndDueDateType do + it 'exposes the expected fields' do + expected_fields = %i[due_date start_date type] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/work_items/widgets/start_and_due_date_update_input_type_spec.rb b/spec/graphql/types/work_items/widgets/start_and_due_date_update_input_type_spec.rb new file mode 100644 index 00000000000..91631093e4e --- /dev/null +++ b/spec/graphql/types/work_items/widgets/start_and_due_date_update_input_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Types::WorkItems::Widgets::StartAndDueDateUpdateInputType do + it { expect(described_class.graphql_name).to eq('WorkItemWidgetStartAndDueDateUpdateInput') } + + it { expect(described_class.arguments.keys).to contain_exactly('startDate', 'dueDate') } +end |