diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/serializers/accessibility_reports_comparer_serializer_spec.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/serializers/accessibility_reports_comparer_serializer_spec.rb')
-rw-r--r-- | spec/serializers/accessibility_reports_comparer_serializer_spec.rb | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/spec/serializers/accessibility_reports_comparer_serializer_spec.rb b/spec/serializers/accessibility_reports_comparer_serializer_spec.rb new file mode 100644 index 00000000000..37dc760fdec --- /dev/null +++ b/spec/serializers/accessibility_reports_comparer_serializer_spec.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe AccessibilityReportsComparerSerializer do + let(:project) { double(:project) } + let(:serializer) { described_class.new(project: project).represent(comparer) } + let(:comparer) { Gitlab::Ci::Reports::AccessibilityReportsComparer.new(base_report, head_report) } + let(:base_report) { Gitlab::Ci::Reports::AccessibilityReports.new } + let(:head_report) { Gitlab::Ci::Reports::AccessibilityReports.new } + let(:url) { "https://gitlab.com" } + let(:single_error) do + [ + { + code: "WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent", + type: "error", + typeCode: 1, + message: "Anchor element found with a valid href attribute, but no link content has been supplied.", + context: "<a href=\"/\" class=\"navbar-brand animated\"><svg height=\"36\" viewBox=\"0 0 1...</a>", + selector: "#main-nav > divnth-child(1) > a", + runner: "htmlcs", + runnerExtras: {} + } + ] + end + let(:different_error) do + [ + { + code: "WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail", + type: "error", + typeCode: 1, + message: "This element has insufficient contrast at this conformance level.", + context: "<a href=\"/stages-devops-lifecycle/\" class=\"main-nav-link\">Product</a>", + selector: "#main-nav > divnth-child(2) > ul > linth-child(1) > a", + runner: "htmlcs", + runnerExtras: {} + } + ] + end + + describe '#to_json' do + subject { serializer.as_json } + + context 'when base report has error and head has a different error' do + before do + base_report.add_url(url, single_error) + head_report.add_url(url, different_error) + end + + it 'matches the schema' do + expect(subject).to match_schema('entities/accessibility_reports_comparer') + end + end + + context 'when base report has no error and head has errors' do + before do + head_report.add_url(url, single_error) + end + + it 'matches the schema' do + expect(subject).to match_schema('entities/accessibility_reports_comparer') + end + end + end +end |