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
ac0c9adb
Commit
ac0c9adb
authored
May 08, 2020
by
Maxime Orefice
Committed by
James Fargher
May 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add AccessibilityReportsComparer API
parent
586aafd7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
306 additions
and
1 deletion
+306
-1
app/serializers/accessibility_error_entity.rb
app/serializers/accessibility_error_entity.rb
+12
-0
app/serializers/accessibility_reports_comparer_entity.rb
app/serializers/accessibility_reports_comparer_entity.rb
+15
-0
app/serializers/accessibility_reports_comparer_serializer.rb
app/serializers/accessibility_reports_comparer_serializer.rb
+5
-0
lib/gitlab/ci/parsers/accessibility/pa11y.rb
lib/gitlab/ci/parsers/accessibility/pa11y.rb
+1
-1
spec/fixtures/api/schemas/entities/accessibility_error.json
spec/fixtures/api/schemas/entities/accessibility_error.json
+40
-0
spec/fixtures/api/schemas/entities/accessibility_reports_comparer.json
.../api/schemas/entities/accessibility_reports_comparer.json
+43
-0
spec/lib/gitlab/ci/parsers/accessibility/pa11y_spec.rb
spec/lib/gitlab/ci/parsers/accessibility/pa11y_spec.rb
+1
-0
spec/serializers/accessibility_error_entity_spec.rb
spec/serializers/accessibility_error_entity_spec.rb
+37
-0
spec/serializers/accessibility_reports_comparer_entity_spec.rb
...serializers/accessibility_reports_comparer_entity_spec.rb
+87
-0
spec/serializers/accessibility_reports_comparer_serializer_spec.rb
...alizers/accessibility_reports_comparer_serializer_spec.rb
+65
-0
No files found.
app/serializers/accessibility_error_entity.rb
0 → 100644
View file @
ac0c9adb
# frozen_string_literal: true
class
AccessibilityErrorEntity
<
Grape
::
Entity
expose
:code
expose
:type
expose
:typeCode
,
as: :type_code
expose
:message
expose
:context
expose
:selector
expose
:runner
expose
:runnerExtras
,
as: :runner_extras
end
app/serializers/accessibility_reports_comparer_entity.rb
0 → 100644
View file @
ac0c9adb
# frozen_string_literal: true
class
AccessibilityReportsComparerEntity
<
Grape
::
Entity
expose
:status
expose
:new_errors
,
using:
AccessibilityErrorEntity
expose
:resolved_errors
,
using:
AccessibilityErrorEntity
expose
:existing_errors
,
using:
AccessibilityErrorEntity
expose
:summary
do
expose
:total_count
,
as: :total
expose
:resolved_count
,
as: :resolved
expose
:errors_count
,
as: :errored
end
end
app/serializers/accessibility_reports_comparer_serializer.rb
0 → 100644
View file @
ac0c9adb
# frozen_string_literal: true
class
AccessibilityReportsComparerSerializer
<
BaseSerializer
entity
AccessibilityReportsComparerEntity
end
lib/gitlab/ci/parsers/accessibility/pa11y.rb
View file @
ac0c9adb
...
...
@@ -6,7 +6,7 @@ module Gitlab
module
Accessibility
class
Pa11y
def
parse!
(
json_data
,
accessibility_report
)
root
=
Gitlab
::
Json
.
parse
(
json_data
)
root
=
Gitlab
::
Json
.
parse
(
json_data
)
.
with_indifferent_access
parse_all
(
root
,
accessibility_report
)
rescue
JSON
::
ParserError
=>
e
...
...
spec/fixtures/api/schemas/entities/accessibility_error.json
0 → 100644
View file @
ac0c9adb
{
"type"
:
"object"
,
"required"
:
[
"code"
,
"type"
,
"type_code"
,
"message"
,
"context"
,
"selector"
,
"runner"
,
"runner_extras"
],
"properties"
:
{
"code"
:
{
"type"
:
"string"
},
"type"
:
{
"type"
:
"string"
},
"type_code"
:
{
"type"
:
"integer"
},
"message"
:
{
"type"
:
"string"
},
"context"
:
{
"type"
:
"string"
},
"selector"
:
{
"type"
:
"string"
},
"runner"
:
{
"type"
:
"string"
},
"runner_extras"
:
{
"type"
:
[
"object"
,
"null"
]
}
},
"additionalProperties"
:
false
}
spec/fixtures/api/schemas/entities/accessibility_reports_comparer.json
0 → 100644
View file @
ac0c9adb
{
"type"
:
"object"
,
"required"
:
[
"status"
,
"summary"
,
"new_errors"
,
"resolved_errors"
,
"existing_errors"
],
"properties"
:
{
"status"
:
{
"type"
:
"string"
},
"summary"
:
{
"type"
:
"object"
,
"properties"
:
{
"total"
:
{
"type"
:
"integer"
},
"resolved"
:
{
"type"
:
"integer"
},
"errored"
:
{
"type"
:
"integer"
}
},
"required"
:
[
"total"
,
"resolved"
,
"errored"
]
},
"new_errors"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"accessibility_error.json"
}
},
"resolved_errors"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"accessibility_error.json"
}
},
"existing_errors"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"accessibility_error.json"
}
}
},
"additionalProperties"
:
false
}
spec/lib/gitlab/ci/parsers/accessibility/pa11y_spec.rb
View file @
ac0c9adb
...
...
@@ -88,6 +88,7 @@ describe Gitlab::Ci::Parsers::Accessibility::Pa11y do
expect
(
accessibility_report
.
passes_count
).
to
eq
(
0
)
expect
(
accessibility_report
.
scans_count
).
to
eq
(
1
)
expect
(
accessibility_report
.
urls
[
'https://about.gitlab.com/'
]).
to
be_present
expect
(
accessibility_report
.
urls
[
'https://about.gitlab.com/'
].
first
[
:code
]).
to
be_present
end
end
end
...
...
spec/serializers/accessibility_error_entity_spec.rb
0 → 100644
View file @
ac0c9adb
# frozen_string_literal: true
require
'spec_helper'
describe
AccessibilityErrorEntity
do
let
(
:entity
)
{
described_class
.
new
(
accessibility_error
)
}
describe
'#as_json'
do
subject
{
entity
.
as_json
}
context
'when accessibility contains an error'
do
let
(
:accessibility_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 > div:nth-child(1) > a"
,
runner:
"htmlcs"
,
runnerExtras:
{}
}
end
it
'contains correct accessibility error details'
,
:aggregate_failures
do
expect
(
subject
[
:code
]).
to
eq
(
"WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent"
)
expect
(
subject
[
:type
]).
to
eq
(
"error"
)
expect
(
subject
[
:type_code
]).
to
eq
(
1
)
expect
(
subject
[
:message
]).
to
eq
(
"Anchor element found with a valid href attribute, but no link content has been supplied."
)
expect
(
subject
[
:context
]).
to
eq
(
"<a href=
\"
/
\"
class=
\"
navbar-brand animated
\"
><svg height=
\"
36
\"
viewBox=
\"
0 0 1...</a>"
)
expect
(
subject
[
:selector
]).
to
eq
(
"#main-nav > div:nth-child(1) > a"
)
expect
(
subject
[
:runner
]).
to
eq
(
"htmlcs"
)
expect
(
subject
[
:runner_extras
]).
to
be_empty
end
end
end
end
spec/serializers/accessibility_reports_comparer_entity_spec.rb
0 → 100644
View file @
ac0c9adb
# frozen_string_literal: true
require
'spec_helper'
describe
AccessibilityReportsComparerEntity
do
let
(
:entity
)
{
described_class
.
new
(
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 > div:nth-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 > div:nth-child(2) > ul > li:nth-child(1) > a"
,
runner:
"htmlcs"
,
runnerExtras:
{}
}
]
end
describe
'#as_json'
do
subject
{
entity
.
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
'contains correct compared accessibility report details'
,
:aggregate_failures
do
expect
(
subject
[
:status
]).
to
eq
(
Gitlab
::
Ci
::
Reports
::
AccessibilityReportsComparer
::
STATUS_FAILED
)
expect
(
subject
[
:resolved_errors
].
first
).
to
include
(
:code
,
:type
,
:type_code
,
:message
,
:context
,
:selector
,
:runner
,
:runner_extras
)
expect
(
subject
[
:new_errors
].
first
).
to
include
(
:code
,
:type
,
:type_code
,
:message
,
:context
,
:selector
,
:runner
,
:runner_extras
)
expect
(
subject
[
:existing_errors
].
first
).
to
include
(
:code
,
:type
,
:type_code
,
:message
,
:context
,
:selector
,
:runner
,
:runner_extras
)
expect
(
subject
[
:summary
]).
to
include
(
total:
2
,
resolved:
1
,
errored:
1
)
end
end
context
'when base report has error and head has the same error'
do
before
do
base_report
.
add_url
(
url
,
single_error
)
head_report
.
add_url
(
url
,
single_error
)
end
it
'contains correct compared accessibility report details'
,
:aggregate_failures
do
expect
(
subject
[
:status
]).
to
eq
(
Gitlab
::
Ci
::
Reports
::
AccessibilityReportsComparer
::
STATUS_FAILED
)
expect
(
subject
[
:new_errors
]).
to
be_empty
expect
(
subject
[
:resolved_errors
]).
to
be_empty
expect
(
subject
[
:existing_errors
].
first
).
to
include
(
:code
,
:type
,
:type_code
,
:message
,
:context
,
:selector
,
:runner
,
:runner_extras
)
expect
(
subject
[
:summary
]).
to
include
(
total:
1
,
resolved:
0
,
errored:
1
)
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
'contains correct compared accessibility report details'
,
:aggregate_failures
do
expect
(
subject
[
:status
]).
to
eq
(
Gitlab
::
Ci
::
Reports
::
AccessibilityReportsComparer
::
STATUS_FAILED
)
expect
(
subject
[
:resolved_errors
]).
to
be_empty
expect
(
subject
[
:existing_errors
]).
to
be_empty
expect
(
subject
[
:new_errors
].
first
).
to
include
(
:code
,
:type
,
:type_code
,
:message
,
:context
,
:selector
,
:runner
,
:runner_extras
)
expect
(
subject
[
:summary
]).
to
include
(
total:
1
,
resolved:
0
,
errored:
1
)
end
end
end
end
spec/serializers/accessibility_reports_comparer_serializer_spec.rb
0 → 100644
View file @
ac0c9adb
# 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
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