diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /spec/graphql/types/ci/pipeline_counts_type_spec.rb | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) | |
download | gitlab-ce-a7b3560714b4d9cc4ab32dffcd1f74a284b93580.tar.gz |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'spec/graphql/types/ci/pipeline_counts_type_spec.rb')
-rw-r--r-- | spec/graphql/types/ci/pipeline_counts_type_spec.rb | 87 |
1 files changed, 87 insertions, 0 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 |