Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9933aa99
Commit
9933aa99
authored
Apr 21, 2020
by
Maxime Orefice
Committed by
Robert Speicher
Apr 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add AccessibilityReports class
parent
3c1182f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
0 deletions
+94
-0
lib/gitlab/ci/reports/accessibility_reports.rb
lib/gitlab/ci/reports/accessibility_reports.rb
+25
-0
spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb
spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb
+69
-0
No files found.
lib/gitlab/ci/reports/accessibility_reports.rb
0 → 100644
View file @
9933aa99
# frozen_string_literal: true
module
Gitlab
module
Ci
module
Reports
class
AccessibilityReports
attr_accessor
:total
,
:passes
,
:errors
attr_reader
:urls
def
initialize
@urls
=
{}
@total
=
0
@passes
=
0
@errors
=
0
end
def
add_url
(
url
,
data
)
return
if
url
.
empty?
urls
[
url
]
=
data
end
end
end
end
end
spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb
0 → 100644
View file @
9933aa99
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Ci
::
Reports
::
AccessibilityReports
do
let
(
:accessibility_report
)
{
described_class
.
new
}
describe
'#add_url'
do
subject
{
accessibility_report
.
add_url
(
url
,
data
)
}
context
'when data has errors'
do
let
(
:url
)
{
'https://gitlab.com'
}
let
(
:data
)
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=
\"
/customers/worldline
\"
>
\n
<svg viewBox=
\"
0 0 509 89
\"
xmln...</a>"
,
"selector"
:
"html > body > div:nth-child(9) > div:nth-child(2) > a:nth-child(17)"
,
"runner"
:
"htmlcs"
,
"runnerExtras"
:
{}
},
{
"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=
\"
/customers/equinix
\"
>
\n
<svg xmlns=
\"
http://www.w3.org/...</a>"
,
"selector"
:
"html > body > div:nth-child(9) > div:nth-child(2) > a:nth-child(18)"
,
"runner"
:
"htmlcs"
,
"runnerExtras"
:
{}
}
]
end
it
'adds urls and data to accessibility report'
do
expect
{
subject
}.
not_to
raise_error
expect
(
accessibility_report
.
urls
.
keys
).
to
eq
([
url
])
expect
(
accessibility_report
.
urls
.
values
.
flatten
.
size
).
to
eq
(
2
)
end
end
context
'when data does not have errors'
do
let
(
:url
)
{
'https://gitlab.com'
}
let
(
:data
)
{
[]
}
it
'adds data to accessibility report'
do
expect
{
subject
}.
not_to
raise_error
expect
(
accessibility_report
.
urls
.
keys
).
to
eq
([
url
])
expect
(
accessibility_report
.
urls
.
values
.
flatten
.
size
).
to
eq
(
0
)
end
end
context
'when url does not exist'
do
let
(
:url
)
{
''
}
let
(
:data
)
{
[{
message:
"Protocol error (Page.navigate): Cannot navigate to invalid URL"
}]
}
it
'do not add data to accessibility report'
do
expect
{
subject
}.
not_to
raise_error
expect
(
accessibility_report
.
urls
).
to
be_empty
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment