Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 17:22:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 17:22:11 +0300
commit0c872e02b2c822e3397515ec324051ff540f0cd5 (patch)
treece2fb6ce7030e4dad0f4118d21ab6453e5938cdd /spec/graphql/types
parentf7e05a6853b12f02911494c4b3fe53d9540d74fc (diff)
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'spec/graphql/types')
-rw-r--r--spec/graphql/types/alert_management/alert_type_spec.rb3
-rw-r--r--spec/graphql/types/ci/detailed_status_type_spec.rb4
-rw-r--r--spec/graphql/types/ci/freeze_period_status_enum_spec.rb9
-rw-r--r--spec/graphql/types/ci/freeze_period_type_spec.rb17
-rw-r--r--spec/graphql/types/ci/pipeline_counts_type_spec.rb2
-rw-r--r--spec/graphql/types/ci/pipeline_schedule_type_spec.rb8
-rw-r--r--spec/graphql/types/ci/pipeline_schedule_variable_type_spec.rb17
-rw-r--r--spec/graphql/types/ci/runner_type_spec.rb2
-rw-r--r--spec/graphql/types/commit_signatures/ssh_signature_type_spec.rb17
-rw-r--r--spec/graphql/types/deployment_details_type_spec.rb17
-rw-r--r--spec/graphql/types/deployment_type_spec.rb7
-rw-r--r--spec/graphql/types/environment_type_spec.rb3
-rw-r--r--spec/graphql/types/issue_type_enum_spec.rb4
-rw-r--r--spec/graphql/types/key_type_spec.rb13
-rw-r--r--spec/graphql/types/merge_request_type_spec.rb4
-rw-r--r--spec/graphql/types/permission_types/base_permission_type_spec.rb21
-rw-r--r--spec/graphql/types/permission_types/deployment_spec.rb11
-rw-r--r--spec/graphql/types/permission_types/environment_spec.rb15
-rw-r--r--spec/graphql/types/permission_types/project_spec.rb2
-rw-r--r--spec/graphql/types/project_type_spec.rb2
-rw-r--r--spec/graphql/types/projects/fork_details_type_spec.rb16
-rw-r--r--spec/graphql/types/projects/service_type_enum_spec.rb1
-rw-r--r--spec/graphql/types/snippets/blob_type_spec.rb19
-rw-r--r--spec/graphql/types/subscription_type_spec.rb1
-rw-r--r--spec/graphql/types/todo_type_spec.rb117
-rw-r--r--spec/graphql/types/work_items/notes_filter_type_enum_spec.rb13
-rw-r--r--spec/graphql/types/work_items/widget_interface_spec.rb1
-rw-r--r--spec/graphql/types/work_items/widgets/hierarchy_type_spec.rb4
-rw-r--r--spec/graphql/types/work_items/widgets/notes_type_spec.rb11
29 files changed, 316 insertions, 45 deletions
diff --git a/spec/graphql/types/alert_management/alert_type_spec.rb b/spec/graphql/types/alert_management/alert_type_spec.rb
index 69cbdb998eb..c1df24ccb5c 100644
--- a/spec/graphql/types/alert_management/alert_type_spec.rb
+++ b/spec/graphql/types/alert_management/alert_type_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe GitlabSchema.types['AlertManagementAlert'] do
+RSpec.describe GitlabSchema.types['AlertManagementAlert'], feature_category: :incident_management do
specify { expect(described_class.graphql_name).to eq('AlertManagementAlert') }
specify { expect(described_class).to require_graphql_authorizations(:read_alert_management_alert) }
@@ -11,6 +11,7 @@ RSpec.describe GitlabSchema.types['AlertManagementAlert'] do
it 'exposes the expected fields' do
expected_fields = %i[
+ id
iid
issueIid
issue
diff --git a/spec/graphql/types/ci/detailed_status_type_spec.rb b/spec/graphql/types/ci/detailed_status_type_spec.rb
index 686461cb9a5..81ab1b52552 100644
--- a/spec/graphql/types/ci/detailed_status_type_spec.rb
+++ b/spec/graphql/types/ci/detailed_status_type_spec.rb
@@ -5,6 +5,8 @@ require 'spec_helper'
RSpec.describe Types::Ci::DetailedStatusType do
include GraphqlHelpers
+ let_it_be(:stage) { create(:ci_stage, status: :skipped) }
+
specify { expect(described_class.graphql_name).to eq('DetailedStatus') }
it 'has all fields' do
@@ -13,8 +15,6 @@ RSpec.describe Types::Ci::DetailedStatusType do
:label, :text, :tooltip, :action)
end
- let_it_be(:stage) { create(:ci_stage, status: :skipped) }
-
describe 'id field' do
it 'correctly renders the field' do
status = stage.detailed_status(stage.pipeline.user)
diff --git a/spec/graphql/types/ci/freeze_period_status_enum_spec.rb b/spec/graphql/types/ci/freeze_period_status_enum_spec.rb
new file mode 100644
index 00000000000..2d9c7071392
--- /dev/null
+++ b/spec/graphql/types/ci/freeze_period_status_enum_spec.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['CiFreezePeriodStatus'], feature_category: :release_orchestration do
+ it 'exposes all freeze period statuses' do
+ expect(described_class.values.keys).to contain_exactly(*%w[ACTIVE INACTIVE])
+ end
+end
diff --git a/spec/graphql/types/ci/freeze_period_type_spec.rb b/spec/graphql/types/ci/freeze_period_type_spec.rb
new file mode 100644
index 00000000000..a7f7c2f9dc8
--- /dev/null
+++ b/spec/graphql/types/ci/freeze_period_type_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['CiFreezePeriod'], feature_category: :release_orchestration do
+ specify { expect(described_class.graphql_name).to eq('CiFreezePeriod') }
+
+ it 'has the expected fields' do
+ expected_fields = %w[
+ status start_cron end_cron cron_timezone start_time end_time
+ ]
+
+ expect(described_class).to have_graphql_fields(*expected_fields)
+ end
+
+ specify { expect(described_class).to require_graphql_authorizations(:read_freeze_period) }
+end
diff --git a/spec/graphql/types/ci/pipeline_counts_type_spec.rb b/spec/graphql/types/ci/pipeline_counts_type_spec.rb
index 7fdb286d253..6452827dc7b 100644
--- a/spec/graphql/types/ci/pipeline_counts_type_spec.rb
+++ b/spec/graphql/types/ci/pipeline_counts_type_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe GitlabSchema.types['PipelineCounts'] do
expect(described_class).to include_graphql_fields(*expected_fields)
end
- shared_examples 'pipeline counts query' do |args: "", expected_counts:|
+ shared_examples 'pipeline counts query' do |expected_counts:, args: ""|
let_it_be(:query) do
%(
query {
diff --git a/spec/graphql/types/ci/pipeline_schedule_type_spec.rb b/spec/graphql/types/ci/pipeline_schedule_type_spec.rb
index bf1413ef657..6e6c6c63969 100644
--- a/spec/graphql/types/ci/pipeline_schedule_type_spec.rb
+++ b/spec/graphql/types/ci/pipeline_schedule_type_spec.rb
@@ -14,6 +14,7 @@ RSpec.describe Types::Ci::PipelineScheduleType do
description
owner
active
+ project
lastPipeline
refForDisplay
refPath
@@ -23,6 +24,13 @@ RSpec.describe Types::Ci::PipelineScheduleType do
cron
cronTimezone
userPermissions
+ editPath
+ cron
+ cronTimezone
+ ref
+ variables
+ createdAt
+ updatedAt
]
expect(described_class).to have_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/ci/pipeline_schedule_variable_type_spec.rb b/spec/graphql/types/ci/pipeline_schedule_variable_type_spec.rb
new file mode 100644
index 00000000000..1c98539e308
--- /dev/null
+++ b/spec/graphql/types/ci/pipeline_schedule_variable_type_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::Ci::PipelineScheduleVariableType do
+ specify { expect(described_class.graphql_name).to eq('PipelineScheduleVariable') }
+ specify { expect(described_class.interfaces).to contain_exactly(Types::Ci::VariableInterface) }
+ specify { expect(described_class).to require_graphql_authorizations(:read_pipeline_schedule_variables) }
+
+ it 'contains attributes related to a pipeline message' do
+ expected_fields = %w[
+ id key raw value variable_type
+ ]
+
+ 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 4ec35db13fb..b078d7f5fac 100644
--- a/spec/graphql/types/ci/runner_type_spec.rb
+++ b/spec/graphql/types/ci/runner_type_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe GitlabSchema.types['CiRunner'] do
id description created_at contacted_at 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
+ maintenance_note maintenance_note_html groups projects jobs token_expires_at owner_project job_execution_status
]
expect(described_class).to include_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/commit_signatures/ssh_signature_type_spec.rb b/spec/graphql/types/commit_signatures/ssh_signature_type_spec.rb
new file mode 100644
index 00000000000..4ffb70a0b22
--- /dev/null
+++ b/spec/graphql/types/commit_signatures/ssh_signature_type_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['SshSignature'], feature_category: :source_code_management do
+ specify { expect(described_class.graphql_name).to eq('SshSignature') }
+
+ specify { expect(described_class).to require_graphql_authorizations(:download_code) }
+
+ specify { expect(described_class).to include(Types::CommitSignatureInterface) }
+
+ it 'contains attributes related to SSH signatures' do
+ expect(described_class).to have_graphql_fields(
+ :user, :verification_status, :commit_sha, :project, :key
+ )
+ end
+end
diff --git a/spec/graphql/types/deployment_details_type_spec.rb b/spec/graphql/types/deployment_details_type_spec.rb
deleted file mode 100644
index 7dc0c8f97ac..00000000000
--- a/spec/graphql/types/deployment_details_type_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe GitlabSchema.types['DeploymentDetails'] do
- specify { expect(described_class.graphql_name).to eq('DeploymentDetails') }
-
- it 'has the expected fields' do
- expected_fields = %w[
- id iid ref tag tags sha created_at updated_at finished_at status commit job triggerer
- ]
-
- expect(described_class).to include_graphql_fields(*expected_fields)
- end
-
- specify { expect(described_class).to require_graphql_authorizations(:read_deployment) }
-end
diff --git a/spec/graphql/types/deployment_type_spec.rb b/spec/graphql/types/deployment_type_spec.rb
index bf4be0523c6..4c49391d7a8 100644
--- a/spec/graphql/types/deployment_type_spec.rb
+++ b/spec/graphql/types/deployment_type_spec.rb
@@ -2,15 +2,16 @@
require 'spec_helper'
-RSpec.describe GitlabSchema.types['Deployment'] do
+RSpec.describe GitlabSchema.types['Deployment'], feature_category: :continuous_delivery do
specify { expect(described_class.graphql_name).to eq('Deployment') }
+ specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Deployment) }
it 'has the expected fields' do
expected_fields = %w[
- id iid ref tag sha created_at updated_at finished_at status commit job triggerer
+ id iid ref tag tags sha created_at updated_at finished_at status commit job triggerer userPermissions
]
- expect(described_class).to have_graphql_fields(*expected_fields)
+ expect(described_class).to include_graphql_fields(*expected_fields)
end
specify { expect(described_class).to require_graphql_authorizations(:read_deployment) }
diff --git a/spec/graphql/types/environment_type_spec.rb b/spec/graphql/types/environment_type_spec.rb
index 2605beac95a..4471735876a 100644
--- a/spec/graphql/types/environment_type_spec.rb
+++ b/spec/graphql/types/environment_type_spec.rb
@@ -4,11 +4,12 @@ require 'spec_helper'
RSpec.describe GitlabSchema.types['Environment'] do
specify { expect(described_class.graphql_name).to eq('Environment') }
+ specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Environment) }
it 'includes the expected fields' do
expected_fields = %w[
name id state metrics_dashboard latest_opened_most_severe_alert path external_url deployments
- slug createdAt updatedAt autoStopAt autoDeleteAt tier environmentType lastDeployment
+ slug createdAt updatedAt autoStopAt autoDeleteAt tier environmentType lastDeployment deployFreezes
]
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 cd1737c3ebb..33a3a9cf8ce 100644
--- a/spec/graphql/types/issue_type_enum_spec.rb
+++ b/spec/graphql/types/issue_type_enum_spec.rb
@@ -2,12 +2,12 @@
require 'spec_helper'
-RSpec.describe Types::IssueTypeEnum do
+RSpec.describe Types::IssueTypeEnum, feature_category: :team_planning do
specify { expect(described_class.graphql_name).to eq('IssueType') }
it 'exposes all the existing issue type values except key_result' do
expect(described_class.values.keys).to match_array(
- %w[ISSUE INCIDENT TEST_CASE REQUIREMENT TASK OBJECTIVE]
+ %w[ISSUE INCIDENT TEST_CASE REQUIREMENT TASK OBJECTIVE KEY_RESULT]
)
end
end
diff --git a/spec/graphql/types/key_type_spec.rb b/spec/graphql/types/key_type_spec.rb
new file mode 100644
index 00000000000..78144076467
--- /dev/null
+++ b/spec/graphql/types/key_type_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['Key'], feature_category: :authentication_and_authorization do
+ specify { expect(described_class.graphql_name).to eq('Key') }
+
+ it 'contains attributes for SSH keys' do
+ expect(described_class).to have_graphql_fields(
+ :id, :title, :created_at, :expires_at, :key
+ )
+ end
+end
diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb
index 7ab254238fb..8a4c89fc340 100644
--- a/spec/graphql/types/merge_request_type_spec.rb
+++ b/spec/graphql/types/merge_request_type_spec.rb
@@ -116,12 +116,12 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
describe 'merge_status_enum' do
let(:type) { GitlabSchema.types['MergeStatus'] }
+ let_it_be(:project) { create(:project, :public) }
+
it 'has the type MergeStatus' do
expect(described_class.fields['mergeStatusEnum']).to have_graphql_type(type)
end
- let_it_be(:project) { create(:project, :public) }
-
%i[preparing unchecked cannot_be_merged_recheck checking cannot_be_merged_rechecking can_be_merged cannot_be_merged].each do |state|
context "when the the DB value is #{state}" do
let(:merge_request) { create(:merge_request, :unique_branches, source_project: project, merge_status: state.to_s) }
diff --git a/spec/graphql/types/permission_types/base_permission_type_spec.rb b/spec/graphql/types/permission_types/base_permission_type_spec.rb
index e4726ad0e6e..f437c3778c6 100644
--- a/spec/graphql/types/permission_types/base_permission_type_spec.rb
+++ b/spec/graphql/types/permission_types/base_permission_type_spec.rb
@@ -51,4 +51,25 @@ RSpec.describe Types::PermissionTypes::BasePermissionType do
expect(test_type).to have_graphql_field(:admin_issue)
end
end
+
+ describe 'extensions' do
+ subject(:test_type) do
+ Class.new(described_class) do
+ graphql_name 'TestClass'
+
+ permission_field :read_entity_a do
+ extension ::Gitlab::Graphql::Limit::FieldCallCount, limit: 1
+ end
+
+ ability_field(:read_entity_b) do
+ extension ::Gitlab::Graphql::Limit::FieldCallCount, limit: 1
+ end
+ end
+ end
+
+ it 'has the extension' do
+ expect(test_type.fields['readEntityA'].extensions).to include(a_kind_of(::Gitlab::Graphql::Limit::FieldCallCount))
+ expect(test_type.fields['readEntityB'].extensions).to include(a_kind_of(::Gitlab::Graphql::Limit::FieldCallCount))
+ end
+ end
end
diff --git a/spec/graphql/types/permission_types/deployment_spec.rb b/spec/graphql/types/permission_types/deployment_spec.rb
new file mode 100644
index 00000000000..ccf5798984c
--- /dev/null
+++ b/spec/graphql/types/permission_types/deployment_spec.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::PermissionTypes::Deployment, feature_category: :continuous_delivery do
+ it do
+ expected_permissions = %i[update_deployment destroy_deployment]
+
+ expect(described_class).to include_graphql_fields(*expected_permissions)
+ end
+end
diff --git a/spec/graphql/types/permission_types/environment_spec.rb b/spec/graphql/types/permission_types/environment_spec.rb
new file mode 100644
index 00000000000..944699c972a
--- /dev/null
+++ b/spec/graphql/types/permission_types/environment_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::PermissionTypes::Environment, feature_category: :continuous_delivery do
+ it do
+ expected_permissions = [
+ :update_environment, :destroy_environment, :stop_environment
+ ]
+
+ expected_permissions.each do |permission|
+ expect(described_class).to have_graphql_field(permission)
+ end
+ end
+end
diff --git a/spec/graphql/types/permission_types/project_spec.rb b/spec/graphql/types/permission_types/project_spec.rb
index c6853a0eadc..645fc6c68d1 100644
--- a/spec/graphql/types/permission_types/project_spec.rb
+++ b/spec/graphql/types/permission_types/project_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe Types::PermissionTypes::Project do
:create_merge_request_from, :create_wiki, :push_code, :create_deployment, :push_to_delete_protected_branch,
:admin_wiki, :admin_project, :update_pages, :admin_remote_mirror, :create_label,
:update_wiki, :destroy_wiki, :create_pages, :destroy_pages, :read_pages_content,
- :read_merge_request, :read_design, :create_design, :destroy_design
+ :read_merge_request, :read_design, :create_design, :destroy_design, :read_environment
]
expected_permissions.each do |permission|
diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb
index 30fabb8e9e2..4151789372b 100644
--- a/spec/graphql/types/project_type_spec.rb
+++ b/spec/graphql/types/project_type_spec.rb
@@ -492,7 +492,7 @@ RSpec.describe GitlabSchema.types['Project'] do
subject { described_class.fields['jobs'] }
it { is_expected.to have_graphql_type(Types::Ci::JobType.connection_type) }
- it { is_expected.to have_graphql_arguments(:statuses) }
+ it { is_expected.to have_graphql_arguments(:statuses, :with_artifacts) }
end
describe 'ci_template field' do
diff --git a/spec/graphql/types/projects/fork_details_type_spec.rb b/spec/graphql/types/projects/fork_details_type_spec.rb
new file mode 100644
index 00000000000..8e20e2c8299
--- /dev/null
+++ b/spec/graphql/types/projects/fork_details_type_spec.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['ForkDetails'], feature_category: :source_code_management do
+ specify { expect(described_class.graphql_name).to eq('ForkDetails') }
+
+ it 'has specific fields' do
+ fields = %i[
+ ahead
+ behind
+ ]
+
+ expect(described_class).to have_graphql_fields(*fields)
+ end
+end
diff --git a/spec/graphql/types/projects/service_type_enum_spec.rb b/spec/graphql/types/projects/service_type_enum_spec.rb
index f7256910bb0..8b444a08c3b 100644
--- a/spec/graphql/types/projects/service_type_enum_spec.rb
+++ b/spec/graphql/types/projects/service_type_enum_spec.rb
@@ -23,7 +23,6 @@ RSpec.describe GitlabSchema.types['ServiceType'] do
EMAILS_ON_PUSH_SERVICE
EWM_SERVICE
EXTERNAL_WIKI_SERVICE
- FLOWDOCK_SERVICE
HANGOUTS_CHAT_SERVICE
IRKER_SERVICE
JENKINS_SERVICE
diff --git a/spec/graphql/types/snippets/blob_type_spec.rb b/spec/graphql/types/snippets/blob_type_spec.rb
index e20b001ba7f..9eef6ac4cdc 100644
--- a/spec/graphql/types/snippets/blob_type_spec.rb
+++ b/spec/graphql/types/snippets/blob_type_spec.rb
@@ -5,15 +5,7 @@ require 'spec_helper'
RSpec.describe GitlabSchema.types['SnippetBlob'] do
include GraphqlHelpers
- it 'has the correct fields' do
- expected_fields = [:rich_data, :plain_data, :raw_plain_data,
- :raw_path, :size, :binary, :name, :path,
- :simple_viewer, :rich_viewer, :mode, :external_storage,
- :rendered_as_text]
-
- expect(described_class).to have_graphql_fields(*expected_fields)
- end
-
+ let_it_be(:blob) { create(:snippet, :public, :repository).blobs.first }
let_it_be(:nullity) do
{
'richData' => be_nullable,
@@ -32,7 +24,14 @@ RSpec.describe GitlabSchema.types['SnippetBlob'] do
}
end
- let_it_be(:blob) { create(:snippet, :public, :repository).blobs.first }
+ it 'has the correct fields' do
+ expected_fields = [:rich_data, :plain_data, :raw_plain_data,
+ :raw_path, :size, :binary, :name, :path,
+ :simple_viewer, :rich_viewer, :mode, :external_storage,
+ :rendered_as_text]
+
+ expect(described_class).to have_graphql_fields(*expected_fields)
+ end
shared_examples 'a field from the snippet blob presenter' do |field|
it "resolves using the presenter", :request_store do
diff --git a/spec/graphql/types/subscription_type_spec.rb b/spec/graphql/types/subscription_type_spec.rb
index 04f0c72b06f..a57a8e751ac 100644
--- a/spec/graphql/types/subscription_type_spec.rb
+++ b/spec/graphql/types/subscription_type_spec.rb
@@ -14,6 +14,7 @@ RSpec.describe GitlabSchema.types['Subscription'] do
issuable_milestone_updated
merge_request_reviewers_updated
merge_request_merge_status_updated
+ merge_request_approval_state_updated
]
expect(described_class).to include_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/todo_type_spec.rb b/spec/graphql/types/todo_type_spec.rb
index c7bb7c67959..2118a777a45 100644
--- a/spec/graphql/types/todo_type_spec.rb
+++ b/spec/graphql/types/todo_type_spec.rb
@@ -3,6 +3,11 @@
require 'spec_helper'
RSpec.describe GitlabSchema.types['Todo'] do
+ let_it_be(:current_user) { create(:user) }
+ let_it_be(:author) { create(:user) }
+
+ let(:issue) { create(:issue, project: project) }
+
it 'has the correct fields' do
expected_fields = [
:id,
@@ -22,4 +27,116 @@ RSpec.describe GitlabSchema.types['Todo'] do
end
specify { expect(described_class).to require_graphql_authorizations(:read_todo) }
+
+ subject { GitlabSchema.execute(query, context: { current_user: current_user }).as_json }
+
+ describe 'project field' do
+ let(:todo) do
+ create(:todo,
+ user: current_user,
+ project: project,
+ state: :done,
+ action: Todo::ASSIGNED,
+ author: author,
+ target: issue)
+ end
+
+ let(:query) do
+ %(
+ query {
+ todo(id: "#{todo.to_global_id}") {
+ project {
+ id
+ }
+ }
+ }
+ )
+ end
+
+ context 'when the project is public' do
+ let_it_be(:project) { create(:project, :public) }
+
+ context 'when the user does not have access' do
+ it 'returns the project' do
+ expect(subject.dig('data', 'todo', 'project', 'id')).to eq(project.to_global_id.to_s)
+ end
+ end
+ end
+
+ context 'when the project is not public' do
+ let_it_be(:project) { create(:project) }
+
+ context 'when the user does not have access' do
+ it 'returns null' do
+ expect(subject.dig('data', 'todo', 'project')).to be_nil
+ end
+ end
+
+ context 'when the user does have access' do
+ before do
+ project.add_guest(current_user)
+ end
+
+ it 'returns the project' do
+ expect(subject.dig('data', 'todo', 'project', 'id')).to eq(project.to_global_id.to_s)
+ end
+ end
+ end
+ end
+
+ describe 'group field' do
+ let(:todo) do
+ create(:todo,
+ user: current_user,
+ group: group,
+ state: :done,
+ action: Todo::MENTIONED,
+ author: author,
+ target: issue)
+ end
+
+ let(:query) do
+ %(
+ query {
+ todo(id: "#{todo.to_global_id}") {
+ group {
+ id
+ }
+ }
+ }
+ )
+ end
+
+ context 'when the group is public' do
+ let_it_be(:group) { create(:group, :public) }
+ let_it_be(:project) { create(:project, :public, group: group) }
+
+ context 'when the user does not have access' do
+ it 'returns the group' do
+ expect(subject.dig('data', 'todo', 'group', 'id')).to eq(group.to_global_id.to_s)
+ end
+ end
+ end
+
+ context 'when the group is not public' do
+ let_it_be(:group) { create(:group) }
+ let_it_be(:project) { create(:project, group: group) }
+
+ context 'when the user does not have access' do
+ it 'returns null' do
+ expect(subject.dig('data', 'todo', 'group')).to be_nil
+ end
+ end
+
+ context 'when the user does have access' do
+ before do
+ group.add_guest(current_user)
+ end
+
+ it 'returns the group' do
+ expect(subject.dig('data', 'todo', 'group', 'id')).to eq(group.to_global_id.to_s)
+ end
+ end
+ end
+ end
end
diff --git a/spec/graphql/types/work_items/notes_filter_type_enum_spec.rb b/spec/graphql/types/work_items/notes_filter_type_enum_spec.rb
new file mode 100644
index 00000000000..13ce559c529
--- /dev/null
+++ b/spec/graphql/types/work_items/notes_filter_type_enum_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['NotesFilterType'], feature_category: :team_planning do
+ specify { expect(described_class.graphql_name).to eq('NotesFilterType') }
+
+ it 'exposes all the existing widget type values' do
+ expect(described_class.values.transform_values(&:value)).to include(
+ "ALL_NOTES" => 0, "ONLY_ACTIVITY" => 2, "ONLY_COMMENTS" => 1
+ )
+ 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 b9e8edacf15..a2b12ed52dc 100644
--- a/spec/graphql/types/work_items/widget_interface_spec.rb
+++ b/spec/graphql/types/work_items/widget_interface_spec.rb
@@ -19,6 +19,7 @@ RSpec.describe Types::WorkItems::WidgetInterface do
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
end
with_them do
diff --git a/spec/graphql/types/work_items/widgets/hierarchy_type_spec.rb b/spec/graphql/types/work_items/widgets/hierarchy_type_spec.rb
index 1722a07c5f4..20413a35c58 100644
--- a/spec/graphql/types/work_items/widgets/hierarchy_type_spec.rb
+++ b/spec/graphql/types/work_items/widgets/hierarchy_type_spec.rb
@@ -2,9 +2,9 @@
require 'spec_helper'
-RSpec.describe Types::WorkItems::Widgets::HierarchyType do
+RSpec.describe Types::WorkItems::Widgets::HierarchyType, feature_category: :team_planning do
it 'exposes the expected fields' do
- expected_fields = %i[parent children type]
+ expected_fields = %i[parent children has_children type]
expect(described_class).to have_graphql_fields(*expected_fields)
end
diff --git a/spec/graphql/types/work_items/widgets/notes_type_spec.rb b/spec/graphql/types/work_items/widgets/notes_type_spec.rb
new file mode 100644
index 00000000000..3ac61a59a9c
--- /dev/null
+++ b/spec/graphql/types/work_items/widgets/notes_type_spec.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::WorkItems::Widgets::NotesType, feature_category: :team_planning do
+ it 'exposes the expected fields' do
+ expected_fields = %i[discussions type]
+
+ expect(described_class).to have_graphql_fields(*expected_fields)
+ end
+end