From 383ec6808b2e5385ccdc0ff7fef8f537635f9bff Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 8 Apr 2021 18:09:32 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../ci/test_report_summary_resolver_spec.rb | 46 ++++++++++++++++++++++ spec/graphql/types/ci/pipeline_type_spec.rb | 1 + .../types/ci/test_report_summary_type_spec.rb | 15 +++++++ .../types/ci/test_report_total_type_spec.rb | 15 +++++++ .../types/ci/test_suite_summary_type_spec.rb | 15 +++++++ 5 files changed, 92 insertions(+) create mode 100644 spec/graphql/resolvers/ci/test_report_summary_resolver_spec.rb create mode 100644 spec/graphql/types/ci/test_report_summary_type_spec.rb create mode 100644 spec/graphql/types/ci/test_report_total_type_spec.rb create mode 100644 spec/graphql/types/ci/test_suite_summary_type_spec.rb (limited to 'spec/graphql') 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 -- cgit v1.2.3