Commit 839037bf authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'mo-add-accessibility-report-pipeline' into 'master'

Add accessibility report for a pipeline

See merge request gitlab-org/gitlab!30095
parents e2be4012 dd2854c6
...@@ -811,6 +811,14 @@ module Ci ...@@ -811,6 +811,14 @@ module Ci
end end
end end
def accessibility_reports
Gitlab::Ci::Reports::AccessibilityReports.new.tap do |accessibility_reports|
builds.latest.with_reports(Ci::JobArtifact.accessibility_reports).each do |build|
build.collect_accessibility_reports!(accessibility_reports)
end
end
end
def coverage_reports def coverage_reports
Gitlab::Ci::Reports::CoverageReports.new.tap do |coverage_reports| Gitlab::Ci::Reports::CoverageReports.new.tap do |coverage_reports|
builds.latest.with_reports(Ci::JobArtifact.coverage_reports).each do |build| builds.latest.with_reports(Ci::JobArtifact.coverage_reports).each do |build|
......
...@@ -83,6 +83,14 @@ FactoryBot.define do ...@@ -83,6 +83,14 @@ FactoryBot.define do
end end
end end
trait :with_accessibility_reports do
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ci_build, :accessibility_reports, pipeline: pipeline, project: pipeline.project)
end
end
trait :with_coverage_reports do trait :with_coverage_reports do
status { :success } status { :success }
......
...@@ -364,6 +364,16 @@ describe Ci::Pipeline, :mailer do ...@@ -364,6 +364,16 @@ describe Ci::Pipeline, :mailer do
end end
end end
context 'when pipeline has an accessibility report' do
subject { described_class.with_reports(Ci::JobArtifact.accessibility_reports) }
let(:pipeline_with_report) { create(:ci_pipeline, :with_accessibility_reports) }
it 'selects the pipeline' do
is_expected.to eq([pipeline_with_report])
end
end
context 'when pipeline has a terraform report' do context 'when pipeline has a terraform report' do
it 'selects the pipeline' do it 'selects the pipeline' do
pipeline_with_report = create(:ci_pipeline, :with_terraform_reports) pipeline_with_report = create(:ci_pipeline, :with_terraform_reports)
...@@ -2799,6 +2809,42 @@ describe Ci::Pipeline, :mailer do ...@@ -2799,6 +2809,42 @@ describe Ci::Pipeline, :mailer do
end end
end end
describe '#accessibility_reports' do
subject { pipeline.accessibility_reports }
context 'when pipeline has multiple builds with accessibility reports' do
let(:build_rspec) { create(:ci_build, :success, name: 'rspec', pipeline: pipeline, project: project) }
let(:build_golang) { create(:ci_build, :success, name: 'golang', pipeline: pipeline, project: project) }
before do
create(:ci_job_artifact, :accessibility, job: build_rspec, project: project)
create(:ci_job_artifact, :accessibility_without_errors, job: build_golang, project: project)
end
it 'returns accessibility report with collected data' do
expect(subject.urls.keys).to match_array([
"https://pa11y.org/",
"https://about.gitlab.com/"
])
end
context 'when builds are retried' do
let(:build_rspec) { create(:ci_build, :retried, :success, name: 'rspec', pipeline: pipeline, project: project) }
let(:build_golang) { create(:ci_build, :retried, :success, name: 'golang', pipeline: pipeline, project: project) }
it 'returns empty urls for accessibility reports' do
expect(subject.urls).to be_empty
end
end
end
context 'when pipeline does not have any builds with accessibility reports' do
it 'returns empty urls for accessibility reports' do
expect(subject.urls).to be_empty
end
end
end
describe '#coverage_reports' do describe '#coverage_reports' do
subject { pipeline.coverage_reports } subject { pipeline.coverage_reports }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment