diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-08 21:09:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-08 21:09:32 +0300 |
commit | 383ec6808b2e5385ccdc0ff7fef8f537635f9bff (patch) | |
tree | 93977ed73841bf36c8f07020f0d2dfab74162a02 /spec/graphql | |
parent | 7a4a8bd5abf6ed6519f252abd79e5f528b8d29d6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
5 files changed, 92 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/ci/test_report_summary_resolver_spec.rb b/spec/graphql/resolvers/ci/test_report_summary_resolver_spec.rb new file mode 100644 index 00000000000..e78bd06b567 --- /dev/null +++ b/spec/graphql/resolvers/ci/test_report_summary_resolver_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Resolvers::Ci::TestReportSummaryResolver do + include GraphqlHelpers + + describe '#resolve' do + let(:user) { create(:user) } + let(:project) { create(:project, :public, :repository) } + + subject(:resolve_subject) { resolve(described_class, obj: pipeline) } + + context 'when pipeline has build report results' do + let(:pipeline) { create(:ci_pipeline, :with_report_results, project: project) } + + it 'returns test report summary data' do + expect(resolve_subject.keys).to contain_exactly(:total, :test_suites) + expect(resolve_subject[:test_suites][0].keys).to contain_exactly(:build_ids, :name, :total_time, :total_count, :success_count, :failed_count, :skipped_count, :error_count, :suite_error) + expect(resolve_subject[:total][:time]).to eq(0.42) + expect(resolve_subject[:total][:count]).to eq(2) + expect(resolve_subject[:total][:success]).to eq(0) + expect(resolve_subject[:total][:failed]).to eq(0) + expect(resolve_subject[:total][:skipped]).to eq(0) + expect(resolve_subject[:total][:error]).to eq(2) + expect(resolve_subject[:total][:suite_error]).to eq(nil) + end + end + + context 'when pipeline does not have build report results' do + let(:pipeline) { create(:ci_pipeline, project: project) } + + it 'renders test report summary data' do + expect(resolve_subject.keys).to contain_exactly(:total, :test_suites) + expect(resolve_subject[:test_suites]).to eq([]) + expect(resolve_subject[:total][:time]).to eq(0) + expect(resolve_subject[:total][:count]).to eq(0) + expect(resolve_subject[:total][:success]).to eq(0) + expect(resolve_subject[:total][:failed]).to eq(0) + expect(resolve_subject[:total][:skipped]).to eq(0) + expect(resolve_subject[:total][:error]).to eq(0) + expect(resolve_subject[:total][:suite_error]).to eq(nil) + end + end + end +end diff --git a/spec/graphql/types/ci/pipeline_type_spec.rb b/spec/graphql/types/ci/pipeline_type_spec.rb index 0781e84e5ae..56bd1294d5c 100644 --- a/spec/graphql/types/ci/pipeline_type_spec.rb +++ b/spec/graphql/types/ci/pipeline_type_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Types::Ci::PipelineType do coverage created_at updated_at started_at finished_at committed_at stages user retryable cancelable jobs source_job job downstream upstream path project active user_permissions warnings commit_path uses_needs + test_report_summary ] if Gitlab.ee? diff --git a/spec/graphql/types/ci/test_report_summary_type_spec.rb b/spec/graphql/types/ci/test_report_summary_type_spec.rb new file mode 100644 index 00000000000..06974da0b88 --- /dev/null +++ b/spec/graphql/types/ci/test_report_summary_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Ci::TestReportSummaryType do + specify { expect(described_class.graphql_name).to eq('TestReportSummary') } + + it 'contains attributes related to a pipeline test report summary' do + expected_fields = %w[ + total test_suites + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/ci/test_report_total_type_spec.rb b/spec/graphql/types/ci/test_report_total_type_spec.rb new file mode 100644 index 00000000000..e5b7b358edb --- /dev/null +++ b/spec/graphql/types/ci/test_report_total_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Ci::TestReportTotalType do + specify { expect(described_class.graphql_name).to eq('TestReportTotal') } + + it 'contains attributes related to a pipeline test report summary' do + expected_fields = %w[ + time count success failed skipped error suite_error + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/spec/graphql/types/ci/test_suite_summary_type_spec.rb b/spec/graphql/types/ci/test_suite_summary_type_spec.rb new file mode 100644 index 00000000000..e87782037c7 --- /dev/null +++ b/spec/graphql/types/ci/test_suite_summary_type_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Types::Ci::TestSuiteSummaryType do + specify { expect(described_class.graphql_name).to eq('TestSuiteSummary') } + + it 'contains attributes related to a pipeline test report summary' do + expected_fields = %w[ + name total_time total_count success_count failed_count skipped_count error_count suite_error build_ids + ] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end |