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-02-18 12:45:46 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 12:45:46 +0300
commita7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch)
tree7452bd5c3545c2fa67a28aa013835fb4fa071baf /spec/graphql/types
parentee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff)
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'spec/graphql/types')
-rw-r--r--spec/graphql/types/ci/pipeline_counts_type_spec.rb87
-rw-r--r--spec/graphql/types/ci/runner_type_spec.rb3
-rw-r--r--spec/graphql/types/clusters/agent_activity_event_type_spec.rb2
-rw-r--r--spec/graphql/types/clusters/agent_token_type_spec.rb2
-rw-r--r--spec/graphql/types/clusters/agent_type_spec.rb2
-rw-r--r--spec/graphql/types/global_id_type_spec.rb2
-rw-r--r--spec/graphql/types/group_type_spec.rb1
-rw-r--r--spec/graphql/types/issuable_type_spec.rb6
-rw-r--r--spec/graphql/types/member_interface_spec.rb13
-rw-r--r--spec/graphql/types/project_type_spec.rb12
-rw-r--r--spec/graphql/types/repository/blob_type_spec.rb5
-rw-r--r--spec/graphql/types/root_storage_statistics_type_spec.rb2
-rw-r--r--spec/graphql/types/subscription_type_spec.rb1
-rw-r--r--spec/graphql/types/user_preferences_type_spec.rb15
-rw-r--r--spec/graphql/types/user_type_spec.rb36
15 files changed, 171 insertions, 18 deletions
diff --git a/spec/graphql/types/ci/pipeline_counts_type_spec.rb b/spec/graphql/types/ci/pipeline_counts_type_spec.rb
new file mode 100644
index 00000000000..7fdb286d253
--- /dev/null
+++ b/spec/graphql/types/ci/pipeline_counts_type_spec.rb
@@ -0,0 +1,87 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['PipelineCounts'] do
+ include GraphqlHelpers
+
+ let(:current_user) { create(:user) }
+
+ let_it_be(:project) { create(:project, :private) }
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
+ let_it_be(:failed_pipeline) { create(:ci_pipeline, :failed, project: project) }
+ let_it_be(:success_pipeline) { create(:ci_pipeline, :success, project: project) }
+ let_it_be(:ref_pipeline) { create(:ci_pipeline, project: project, ref: 'awesome-feature') }
+ let_it_be(:sha_pipeline) { create(:ci_pipeline, :running, project: project, sha: 'deadbeef') }
+ let_it_be(:on_demand_dast_scan) { create(:ci_pipeline, :success, project: project, source: 'ondemand_dast_scan') }
+
+ before do
+ project.add_developer(current_user)
+ end
+
+ specify { expect(described_class.graphql_name).to eq('PipelineCounts') }
+
+ it 'has the expected fields' do
+ expected_fields = %w[
+ all
+ finished
+ pending
+ running
+ ]
+
+ expect(described_class).to include_graphql_fields(*expected_fields)
+ end
+
+ shared_examples 'pipeline counts query' do |args: "", expected_counts:|
+ let_it_be(:query) do
+ %(
+ query {
+ project(fullPath: "#{project.full_path}") {
+ pipelineCounts#{args} {
+ all
+ finished
+ pending
+ running
+ }
+ }
+ }
+ )
+ end
+
+ subject { GitlabSchema.execute(query, context: { current_user: current_user }).as_json }
+
+ it 'returns pipeline counts' do
+ actual_counts = subject.dig('data', 'project', 'pipelineCounts')
+
+ expect(actual_counts).to eq(expected_counts)
+ end
+ end
+
+ it_behaves_like "pipeline counts query", args: "", expected_counts: {
+ "all" => 6,
+ "finished" => 3,
+ "pending" => 2,
+ "running" => 1
+ }
+
+ it_behaves_like "pipeline counts query", args: '(ref: "awesome-feature")', expected_counts: {
+ "all" => 1,
+ "finished" => 0,
+ "pending" => 1,
+ "running" => 0
+ }
+
+ it_behaves_like "pipeline counts query", args: '(sha: "deadbeef")', expected_counts: {
+ "all" => 1,
+ "finished" => 0,
+ "pending" => 0,
+ "running" => 1
+ }
+
+ it_behaves_like "pipeline counts query", args: '(source: "ondemand_dast_scan")', expected_counts: {
+ "all" => 1,
+ "finished" => 1,
+ "pending" => 0,
+ "running" => 0
+ }
+end
diff --git a/spec/graphql/types/ci/runner_type_spec.rb b/spec/graphql/types/ci/runner_type_spec.rb
index 43d8b585d6b..7697cd0ef79 100644
--- a/spec/graphql/types/ci/runner_type_spec.rb
+++ b/spec/graphql/types/ci/runner_type_spec.rb
@@ -9,9 +9,10 @@ RSpec.describe GitlabSchema.types['CiRunner'] do
it 'contains attributes related to a runner' do
expected_fields = %w[
- id description created_at contacted_at maximum_timeout access_level active status
+ 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
+ groups projects jobs token_expires_at
]
expect(described_class).to include_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/clusters/agent_activity_event_type_spec.rb b/spec/graphql/types/clusters/agent_activity_event_type_spec.rb
index 7773bad749d..cae75485846 100644
--- a/spec/graphql/types/clusters/agent_activity_event_type_spec.rb
+++ b/spec/graphql/types/clusters/agent_activity_event_type_spec.rb
@@ -6,6 +6,6 @@ RSpec.describe GitlabSchema.types['ClusterAgentActivityEvent'] do
let(:fields) { %i[recorded_at kind level user agent_token] }
it { expect(described_class.graphql_name).to eq('ClusterAgentActivityEvent') }
- it { expect(described_class).to require_graphql_authorizations(:admin_cluster) }
+ it { expect(described_class).to require_graphql_authorizations(:read_cluster) }
it { expect(described_class).to have_graphql_fields(fields) }
end
diff --git a/spec/graphql/types/clusters/agent_token_type_spec.rb b/spec/graphql/types/clusters/agent_token_type_spec.rb
index 3f0720cb4b5..1ca6d690c80 100644
--- a/spec/graphql/types/clusters/agent_token_type_spec.rb
+++ b/spec/graphql/types/clusters/agent_token_type_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['ClusterAgentToken'] do
it { expect(described_class.graphql_name).to eq('ClusterAgentToken') }
- it { expect(described_class).to require_graphql_authorizations(:admin_cluster) }
+ it { expect(described_class).to require_graphql_authorizations(:read_cluster) }
it { expect(described_class).to have_graphql_fields(fields) }
end
diff --git a/spec/graphql/types/clusters/agent_type_spec.rb b/spec/graphql/types/clusters/agent_type_spec.rb
index a1e5952bf73..3f4faccf15d 100644
--- a/spec/graphql/types/clusters/agent_type_spec.rb
+++ b/spec/graphql/types/clusters/agent_type_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe GitlabSchema.types['ClusterAgent'] do
it { expect(described_class.graphql_name).to eq('ClusterAgent') }
- it { expect(described_class).to require_graphql_authorizations(:admin_cluster) }
+ it { expect(described_class).to require_graphql_authorizations(:read_cluster) }
it { expect(described_class).to have_graphql_fields(fields) }
end
diff --git a/spec/graphql/types/global_id_type_spec.rb b/spec/graphql/types/global_id_type_spec.rb
index 4efa3018dad..e7e69cfad9e 100644
--- a/spec/graphql/types/global_id_type_spec.rb
+++ b/spec/graphql/types/global_id_type_spec.rb
@@ -191,7 +191,7 @@ RSpec.describe Types::GlobalIDType do
describe 'executing against the schema' do
let(:query_result) do
- context = { current_user: issue.project.owner }
+ context = { current_user: issue.project.first_owner }
variables = { 'id' => gid }
run_with_clean_state(query, context: context, variables: variables).to_h
diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb
index 0ba322a100a..82703948cea 100644
--- a/spec/graphql/types/group_type_spec.rb
+++ b/spec/graphql/types/group_type_spec.rb
@@ -23,6 +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
]
expect(described_class).to include_graphql_fields(*expected_fields)
diff --git a/spec/graphql/types/issuable_type_spec.rb b/spec/graphql/types/issuable_type_spec.rb
index 992a58f524b..cb18bbe2eab 100644
--- a/spec/graphql/types/issuable_type_spec.rb
+++ b/spec/graphql/types/issuable_type_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe GitlabSchema.types['Issuable'] do
it 'returns possible types' do
- expect(described_class.possible_types).to include(Types::IssueType, Types::MergeRequestType)
+ expect(described_class.possible_types).to include(Types::IssueType, Types::MergeRequestType, Types::WorkItemType)
end
describe '.resolve_type' do
@@ -16,6 +16,10 @@ RSpec.describe GitlabSchema.types['Issuable'] do
expect(described_class.resolve_type(build(:merge_request), {})).to eq(Types::MergeRequestType)
end
+ it 'resolves work items' do
+ expect(described_class.resolve_type(build(:work_item), {})).to eq(Types::WorkItemType)
+ end
+
it 'raises an error for invalid types' do
expect { described_class.resolve_type(build(:user), {}) }.to raise_error 'Unsupported issuable type'
end
diff --git a/spec/graphql/types/member_interface_spec.rb b/spec/graphql/types/member_interface_spec.rb
index 11fd09eb335..8ecaaa46bed 100644
--- a/spec/graphql/types/member_interface_spec.rb
+++ b/spec/graphql/types/member_interface_spec.rb
@@ -12,6 +12,7 @@ RSpec.describe Types::MemberInterface do
updated_at
expires_at
user
+ merge_request_interaction
]
expect(described_class).to have_graphql_fields(*expected_fields)
@@ -40,4 +41,16 @@ RSpec.describe Types::MemberInterface do
end
end
end
+
+ describe '#merge_request_interaction' do
+ subject { described_class.fields['mergeRequestInteraction'] }
+
+ it 'returns the correct type' do
+ is_expected.to have_graphql_type(Types::UserMergeRequestInteractionType)
+ end
+
+ it 'has the correct arguments' do
+ expect(subject.arguments).to have_key('id')
+ end
+ end
end
diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb
index 961e12288d4..7433d465b38 100644
--- a/spec/graphql/types/project_type_spec.rb
+++ b/spec/graphql/types/project_type_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe GitlabSchema.types['Project'] do
only_allow_merge_if_pipeline_succeeds request_access_enabled
only_allow_merge_if_all_discussions_are_resolved printing_merge_request_link_enabled
namespace group statistics repository merge_requests merge_request issues
- issue milestones pipelines removeSourceBranchAfterMerge sentryDetailedError snippets
+ issue milestones pipelines removeSourceBranchAfterMerge pipeline_counts sentryDetailedError snippets
grafanaIntegration autocloseReferencedIssues suggestion_commit_message environments
environment boards jira_import_status jira_imports services releases release
alert_management_alerts alert_management_alert alert_management_alert_status_counts
@@ -35,6 +35,7 @@ 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
]
expect(described_class).to include_graphql_fields(*expected_fields)
@@ -299,6 +300,8 @@ RSpec.describe GitlabSchema.types['Project'] do
:merged_before,
:created_after,
:created_before,
+ :updated_after,
+ :updated_before,
:author_username,
:assignee_username,
:reviewer_username,
@@ -309,6 +312,13 @@ RSpec.describe GitlabSchema.types['Project'] do
end
end
+ describe 'pipelineCounts field' do
+ subject { described_class.fields['pipelineCounts'] }
+
+ it { is_expected.to have_graphql_type(Types::Ci::PipelineCountsType) }
+ it { is_expected.to have_graphql_resolver(Resolvers::Ci::ProjectPipelineCountsResolver) }
+ end
+
describe 'snippets field' do
subject { described_class.fields['snippets'] }
diff --git a/spec/graphql/types/repository/blob_type_spec.rb b/spec/graphql/types/repository/blob_type_spec.rb
index 8d845e5d814..565341d15b9 100644
--- a/spec/graphql/types/repository/blob_type_spec.rb
+++ b/spec/graphql/types/repository/blob_type_spec.rb
@@ -29,6 +29,8 @@ RSpec.describe Types::Repository::BlobType do
:blame_path,
:history_path,
:permalink_path,
+ :environment_formatted_external_url,
+ :environment_external_url_for_route_map,
:code_owners,
:simple_viewer,
:rich_viewer,
@@ -39,7 +41,8 @@ RSpec.describe Types::Repository::BlobType do
:ide_edit_path,
:external_storage_url,
:fork_and_edit_path,
- :ide_fork_and_edit_path
+ :ide_fork_and_edit_path,
+ :language
)
end
end
diff --git a/spec/graphql/types/root_storage_statistics_type_spec.rb b/spec/graphql/types/root_storage_statistics_type_spec.rb
index 4fef8f6eafd..7818be6ee02 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, :uploads_size)
+ :pipeline_artifacts_size, :uploads_size, :dependency_proxy_size)
end
specify { expect(described_class).to require_graphql_authorizations(:read_statistics) }
diff --git a/spec/graphql/types/subscription_type_spec.rb b/spec/graphql/types/subscription_type_spec.rb
index bf933945a31..593795de004 100644
--- a/spec/graphql/types/subscription_type_spec.rb
+++ b/spec/graphql/types/subscription_type_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe GitlabSchema.types['Subscription'] do
expected_fields = %i[
issuable_assignees_updated
issue_crm_contacts_updated
+ issuable_title_updated
]
expect(described_class).to have_graphql_fields(*expected_fields).only
diff --git a/spec/graphql/types/user_preferences_type_spec.rb b/spec/graphql/types/user_preferences_type_spec.rb
new file mode 100644
index 00000000000..fac45443290
--- /dev/null
+++ b/spec/graphql/types/user_preferences_type_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Types::UserPreferencesType do
+ specify { expect(described_class.graphql_name).to eq('UserPreferences') }
+
+ it 'exposes the expected fields' do
+ expected_fields = %i[
+ issues_sort
+ ]
+
+ expect(described_class).to have_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 4e3f442dc71..a2fc8f4c954 100644
--- a/spec/graphql/types/user_type_spec.rb
+++ b/spec/graphql/types/user_type_spec.rb
@@ -67,14 +67,14 @@ RSpec.describe GitlabSchema.types['User'] do
)
end
- subject { GitlabSchema.execute(query, context: { current_user: current_user }).as_json.dig('data', 'user', 'name') }
+ subject(:user_name) { GitlabSchema.execute(query, context: { current_user: current_user }).as_json.dig('data', 'user', 'name') }
context 'user requests' do
let(:current_user) { user }
context 'a user' do
it 'returns name' do
- expect(subject).to eq('John Smith')
+ expect(user_name).to eq('John Smith')
end
end
@@ -85,21 +85,39 @@ RSpec.describe GitlabSchema.types['User'] do
let(:current_user) { nil }
it 'returns `****`' do
- expect(subject).to eq('****')
+ expect(user_name).to eq('****')
end
end
- it 'returns `****` for a regular user' do
- expect(subject).to eq('****')
+ context 'when the requester is not a project member' do
+ it 'returns `Project bot` for a non project member in a public project' do
+ expect(user_name).to eq('Project bot')
+ end
+
+ context 'in a private project' do
+ let(:project) { create(:project, :private) }
+
+ it 'returns `****` for a non project member in a private project' do
+ expect(user_name).to eq('****')
+ end
+ end
end
- context 'when requester is a project maintainer' do
+ context 'with a project member' do
before do
- project.add_maintainer(user)
+ project.add_guest(user)
+ end
+
+ it 'returns `Project bot` for a project member' do
+ expect(user_name).to eq('Project bot')
end
- it 'returns name' do
- expect(subject).to eq('Project bot')
+ context 'in a private project' do
+ let(:project) { create(:project, :private) }
+
+ it 'returns `Project bot` for a project member in a private project' do
+ expect(user_name).to eq('Project bot')
+ end
end
end
end