diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/graphql | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/graphql')
23 files changed, 177 insertions, 30 deletions
diff --git a/spec/graphql/mutations/design_management/delete_spec.rb b/spec/graphql/mutations/design_management/delete_spec.rb index 93fff5e5103..79196d4965d 100644 --- a/spec/graphql/mutations/design_management/delete_spec.rb +++ b/spec/graphql/mutations/design_management/delete_spec.rb @@ -86,9 +86,11 @@ RSpec.describe Mutations::DesignManagement::Delete do end end - it 'runs no more than 29 queries' do + it 'runs no more than 30 queries' do + allow(Gitlab::Tracking).to receive(:event) # rubocop:disable RSpec/ExpectGitlabTracking + filenames.each(&:present?) # ignore setup - # Queries: as of 2021-07-22 + # Queries: as of 2022-06-15 # ------------- # 01. routing query # 02. find project by id @@ -106,20 +108,21 @@ RSpec.describe Mutations::DesignManagement::Delete do # 15. current designs by filename and issue # 16, 17 project.authorizations for user (same query as 5) # 18. find route by id and source_type + # 19. find plan for standard context # ------------- our queries are below: - # 19. start transaction 1 - # 20. start transaction 2 - # 21. find version by sha and issue - # 22. exists version with sha and issue? - # 23. leave transaction 2 - # 24. create version with sha and issue - # 25. create design-version links - # 26. validate version.actions.present? - # 27. validate version.issue.present? - # 28. validate version.sha is unique - # 29. leave transaction 1 + # 20. start transaction 1 + # 21. start transaction 2 + # 22. find version by sha and issue + # 23. exists version with sha and issue? + # 24. leave transaction 2 + # 25. create version with sha and issue + # 26. create design-version links + # 27. validate version.actions.present? + # 28. validate version.issue.present? + # 29. validate version.sha is unique + # 30. leave transaction 1 # - expect { run_mutation }.not_to exceed_query_limit(29) + expect { run_mutation }.not_to exceed_query_limit(30) end end diff --git a/spec/graphql/mutations/pages/mark_onboarding_complete_spec.rb b/spec/graphql/mutations/pages/mark_onboarding_complete_spec.rb new file mode 100644 index 00000000000..c4ceecb9d46 --- /dev/null +++ b/spec/graphql/mutations/pages/mark_onboarding_complete_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Mutations::Pages::MarkOnboardingComplete do + let_it_be(:project) { create(:project, :public, :repository) } + let_it_be(:developer) { create(:user) } + let_it_be(:owner) { create(:user) } + + let(:mutation) { described_class.new(object: nil, context: { current_user: current_user }, field: nil) } + + let(:mutation_arguments) do + { + project_path: project.full_path + } + end + + before_all do + project.add_owner(owner) + project.add_developer(developer) + end + + describe '#resolve' do + subject(:resolve) do + mutation.resolve(**mutation_arguments) + end + + context 'when the current user has access to update pages' do + let(:current_user) { owner } + + it 'calls mark_pages_onboarding_complete on the project' do + allow_next_instance_of(::Project) do |project| + expect(project).to receive(:mark_pages_onboarding_complete) + end + end + + it 'returns onboarding_complete state' do + expect(resolve).to include(onboarding_complete: true) + end + + it 'returns no errors' do + expect(resolve).to include(errors: []) + end + end + + context "when the current user doesn't have access to update pages" do + let(:current_user) { developer } + + it 'raises an error' do + expect { subject }.to raise_error( + Gitlab::Graphql::Errors::ResourceNotAvailable, + Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR + ) + end + end + end +end diff --git a/spec/graphql/resolvers/ci/job_token_scope_resolver_spec.rb b/spec/graphql/resolvers/ci/job_token_scope_resolver_spec.rb index 59616815de0..ac7cef20df4 100644 --- a/spec/graphql/resolvers/ci/job_token_scope_resolver_spec.rb +++ b/spec/graphql/resolvers/ci/job_token_scope_resolver_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Resolvers::Ci::JobTokenScopeResolver do describe '#resolve' do context 'with access to scope' do before do - project.add_user(current_user, :maintainer) + project.add_member(current_user, :maintainer) end it 'returns nil when scope is not enabled' do @@ -51,7 +51,7 @@ RSpec.describe Resolvers::Ci::JobTokenScopeResolver do context 'without access to scope' do before do - project.add_user(current_user, :developer) + project.add_member(current_user, :developer) end it 'generates an error' do diff --git a/spec/graphql/resolvers/ci/runners_resolver_spec.rb b/spec/graphql/resolvers/ci/runners_resolver_spec.rb index b1f5f7b3e43..8586d359336 100644 --- a/spec/graphql/resolvers/ci/runners_resolver_spec.rb +++ b/spec/graphql/resolvers/ci/runners_resolver_spec.rb @@ -52,6 +52,7 @@ RSpec.describe Resolvers::Ci::RunnersResolver do { active: true, status: 'active', + upgrade_status: 'recommended', type: :instance_type, tag_list: ['active_runner'], search: 'abc', @@ -63,6 +64,7 @@ RSpec.describe Resolvers::Ci::RunnersResolver do { active: true, status_status: 'active', + upgrade_status: 'recommended', type_type: :instance_type, tag_name: ['active_runner'], preload: { tag_name: nil }, diff --git a/spec/graphql/resolvers/container_repositories_resolver_spec.rb b/spec/graphql/resolvers/container_repositories_resolver_spec.rb index d7aa761320f..ed922259903 100644 --- a/spec/graphql/resolvers/container_repositories_resolver_spec.rb +++ b/spec/graphql/resolvers/container_repositories_resolver_spec.rb @@ -62,7 +62,7 @@ RSpec.describe Resolvers::ContainerRepositoriesResolver do context 'with authorized user' do before do - group.add_user(user, :maintainer) + group.add_member(user, :maintainer) end context 'when the object is a project' do diff --git a/spec/graphql/resolvers/todo_resolver_spec.rb b/spec/graphql/resolvers/todos_resolver_spec.rb index 0760935a2fe..40ca2de0385 100644 --- a/spec/graphql/resolvers/todo_resolver_spec.rb +++ b/spec/graphql/resolvers/todos_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Resolvers::TodoResolver do +RSpec.describe Resolvers::TodosResolver do include GraphqlHelpers include DesignManagementTestHelpers diff --git a/spec/graphql/resolvers/users/groups_resolver_spec.rb b/spec/graphql/resolvers/users/groups_resolver_spec.rb index bbe9b6371cf..1e0e001fbf7 100644 --- a/spec/graphql/resolvers/users/groups_resolver_spec.rb +++ b/spec/graphql/resolvers/users/groups_resolver_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Resolvers::Users::GroupsResolver do let_it_be(:private_maintainer_group) { create(:group, :private, name: 'b private maintainer', path: 'b-private-maintainer') } let_it_be(:public_developer_group) { create(:group, project_creation_level: nil, name: 'c public developer', path: 'c-public-developer') } let_it_be(:public_maintainer_group) { create(:group, name: 'a public maintainer', path: 'a-public-maintainer') } + let_it_be(:public_owner_group) { create(:group, name: 'a public owner', path: 'a-public-owner') } subject(:resolved_items) { resolve_groups(args: group_arguments, current_user: current_user, obj: resolver_object) } @@ -24,6 +25,7 @@ RSpec.describe Resolvers::Users::GroupsResolver do private_maintainer_group.add_maintainer(user) public_developer_group.add_developer(user) public_maintainer_group.add_maintainer(user) + public_owner_group.add_owner(user) end context 'when resolver object is current user' do @@ -34,6 +36,7 @@ RSpec.describe Resolvers::Users::GroupsResolver do is_expected.to match( [ public_maintainer_group, + public_owner_group, private_maintainer_group, public_developer_group ] @@ -41,10 +44,25 @@ RSpec.describe Resolvers::Users::GroupsResolver do end end + context 'when permission is :transfer_projects' do + let(:group_arguments) { { permission_scope: :transfer_projects } } + + specify do + is_expected.to match( + [ + public_maintainer_group, + public_owner_group, + private_maintainer_group + ] + ) + end + end + specify do is_expected.to match( [ public_maintainer_group, + public_owner_group, private_maintainer_group, public_developer_group, guest_group @@ -82,6 +100,7 @@ RSpec.describe Resolvers::Users::GroupsResolver do is_expected.to match( [ public_maintainer_group, + public_owner_group, private_maintainer_group, public_developer_group, guest_group diff --git a/spec/graphql/types/ci/detailed_status_type_spec.rb b/spec/graphql/types/ci/detailed_status_type_spec.rb index 0c05227aec2..686461cb9a5 100644 --- a/spec/graphql/types/ci/detailed_status_type_spec.rb +++ b/spec/graphql/types/ci/detailed_status_type_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Types::Ci::DetailedStatusType do :label, :text, :tooltip, :action) end - let_it_be(:stage) { create(:ci_stage_entity, status: :skipped) } + let_it_be(:stage) { create(:ci_stage, status: :skipped) } describe 'id field' do it 'correctly renders the field' do 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 43225b2089b..c1a3c4dd54d 100644 --- a/spec/graphql/types/ci/job_token_scope_type_spec.rb +++ b/spec/graphql/types/ci/job_token_scope_type_spec.rb @@ -38,7 +38,7 @@ RSpec.describe GitlabSchema.types['CiJobTokenScopeType'] do context 'with access to scope' do before do - project.add_user(current_user, :maintainer) + project.add_member(current_user, :maintainer) end context 'when multiple projects in the allow list' do @@ -46,7 +46,7 @@ RSpec.describe GitlabSchema.types['CiJobTokenScopeType'] do context 'when linked projects are readable' do before do - link.target_project.add_user(current_user, :developer) + link.target_project.add_member(current_user, :developer) end it 'returns readable projects in scope' do diff --git a/spec/graphql/types/ci/job_type_spec.rb b/spec/graphql/types/ci/job_type_spec.rb index 655c3636883..bc9e64282bc 100644 --- a/spec/graphql/types/ci/job_type_spec.rb +++ b/spec/graphql/types/ci/job_type_spec.rb @@ -23,6 +23,7 @@ RSpec.describe Types::Ci::JobType do id kind manual_job + manual_variables name needs pipeline @@ -33,6 +34,7 @@ RSpec.describe Types::Ci::JobType do refName refPath retryable + retried scheduledAt schedulingType shortSha diff --git a/spec/graphql/types/ci/runner_upgrade_status_type_enum_spec.rb b/spec/graphql/types/ci/runner_upgrade_status_type_enum_spec.rb index 81a852471b9..03c784dcbe7 100644 --- a/spec/graphql/types/ci/runner_upgrade_status_type_enum_spec.rb +++ b/spec/graphql/types/ci/runner_upgrade_status_type_enum_spec.rb @@ -3,11 +3,22 @@ require 'spec_helper' RSpec.describe Types::Ci::RunnerUpgradeStatusTypeEnum 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') } - it 'exposes all upgrade status values' do - expect(described_class.values.keys).to eq( - ['UNKNOWN'] + ::Gitlab::Ci::RunnerUpgradeCheck::STATUSES.map { |sym, _| sym.to_s.upcase } + it 'exposes all upgrade status values except not_processed' do + expect(described_class.values.keys).to match_array( + expected_graphql_source_values + .map(&:upcase) + .map { |v| v == 'INVALID_VERSION' ? 'INVALID' : v } ) end + + it 'exposes all upgrade status values except enum-only values' do + expect(described_class.values.values.map(&:value).map(&:to_s)).to match_array(expected_graphql_source_values) + end end diff --git a/spec/graphql/types/ci/status_action_type_spec.rb b/spec/graphql/types/ci/status_action_type_spec.rb index 4c467bf240e..3f4b52610ae 100644 --- a/spec/graphql/types/ci/status_action_type_spec.rb +++ b/spec/graphql/types/ci/status_action_type_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Types::Ci::StatusActionType do describe 'id field' do it 'correctly renders the field' do - stage = build(:ci_stage_entity, status: :skipped) + stage = build(:ci_stage, status: :skipped) status = stage.detailed_status(stage.pipeline.user) expected_id = "#{stage.class.name}-#{status.id}" diff --git a/spec/graphql/types/ci/variable_type_enum_spec.rb b/spec/graphql/types/ci/variable_type_enum_spec.rb new file mode 100644 index 00000000000..5604caebfff --- /dev/null +++ b/spec/graphql/types/ci/variable_type_enum_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiVariableType'] do + it 'matches the keys of Ci::Variable.variable_types' do + expect(described_class.values.keys).to contain_exactly('ENV_VAR', 'FILE') + end +end diff --git a/spec/graphql/types/ci/variable_type_spec.rb b/spec/graphql/types/ci/variable_type_spec.rb new file mode 100644 index 00000000000..a81e6adbab6 --- /dev/null +++ b/spec/graphql/types/ci/variable_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiVariable'] do + it 'contains attributes related to CI variables' do + expect(described_class).to have_graphql_fields( + :id, :key, :value, :variable_type, :protected, :masked, :raw, :environment_scope + ) + end +end diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index 82703948cea..69c7eaf111f 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -23,7 +23,7 @@ RSpec.describe GitlabSchema.types['Group'] do 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 + recent_issue_boards ci_variables ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/issue_type_enum_spec.rb b/spec/graphql/types/issue_type_enum_spec.rb index 131e92aa5ed..8f4b6f3bf74 100644 --- a/spec/graphql/types/issue_type_enum_spec.rb +++ b/spec/graphql/types/issue_type_enum_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' RSpec.describe Types::IssueTypeEnum do specify { expect(described_class.graphql_name).to eq('IssueType') } - it 'exposes all the existing issue type values except for task' do + it 'exposes all the existing issue type values' do expect(described_class.values.keys).to match_array( - %w[ISSUE INCIDENT TEST_CASE REQUIREMENT] + %w[ISSUE INCIDENT TEST_CASE REQUIREMENT TASK] ) end end diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 2e994bf7820..ed93d31da0f 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -36,7 +36,8 @@ RSpec.describe GitlabSchema.types['Project'] do pipeline_analytics squash_read_only sast_ci_configuration 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 + recent_issue_boards ci_config_path_or_default packages_cleanup_policy ci_variables + recent_issue_boards ci_config_path_or_default ci_variables ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index 8b8c44c10f6..514d24a209e 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -30,6 +30,7 @@ RSpec.describe GitlabSchema.types['Query'] do board_list topics gitpod_enabled + ci_variables ] expect(described_class).to have_graphql_fields(*expected_fields).at_least diff --git a/spec/graphql/types/release_type_spec.rb b/spec/graphql/types/release_type_spec.rb index 0c05a68c5a6..a1dc8850f94 100644 --- a/spec/graphql/types/release_type_spec.rb +++ b/spec/graphql/types/release_type_spec.rb @@ -11,7 +11,8 @@ RSpec.describe GitlabSchema.types['Release'] do description description_html name milestones evidences author commit assets links - created_at released_at + created_at released_at upcoming_release + historical_release ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/work_items/widget_interface_spec.rb b/spec/graphql/types/work_items/widget_interface_spec.rb index ee40bcc10ca..caf986c961f 100644 --- a/spec/graphql/types/work_items/widget_interface_spec.rb +++ b/spec/graphql/types/work_items/widget_interface_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Types::WorkItems::WidgetInterface do 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 end with_them do diff --git a/spec/graphql/types/work_items/widgets/assignees_type_spec.rb b/spec/graphql/types/work_items/widgets/assignees_type_spec.rb new file mode 100644 index 00000000000..816e66f1db1 --- /dev/null +++ b/spec/graphql/types/work_items/widgets/assignees_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::WorkItems::Widgets::AssigneesType do + it 'exposes the expected fields' do + expected_fields = %i[assignees allows_multiple_assignees can_invite_members type] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/work_items/widgets/description_input_type_spec.rb b/spec/graphql/types/work_items/widgets/description_input_type_spec.rb new file mode 100644 index 00000000000..81c64bc38ab --- /dev/null +++ b/spec/graphql/types/work_items/widgets/description_input_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Types::WorkItems::Widgets::DescriptionInputType do + it { expect(described_class.graphql_name).to eq('WorkItemWidgetDescriptionInput') } + + it { expect(described_class.arguments.keys).to match_array(%w[description]) } +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 new file mode 100644 index 00000000000..6221580605e --- /dev/null +++ b/spec/graphql/types/work_items/widgets/hierarchy_update_input_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +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]) } +end |