-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add axe accessibility testing #33
Conversation
WIP, need to figure out a good way to test this behaviour |
I don't like that jQuery will get included twice. Once from component guide and once from static. |
@fofr I was thinking of not including jQuery at all but was thinking of the cases where we're testing the guide against older browsers, that said might be able to just use the static dependency, will check. |
Trying to add the jasmine tests to the default rake command results in
I'm not currently sure how to resolve this. |
470d52a
to
8ab3503
Compare
64d429b
to
575a364
Compare
locals: { | ||
component_doc: @component_doc, | ||
fixture: fixture, | ||
flush: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "flush" mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in 'flush fit'. It's not so obvious, maybe there's an alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'full_bleed'? https://en.wikipedia.org/wiki/Bleed_(printing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a way to change this so the borders wrap the internal component, will try something.
@NickColley I get the error locally too:
|
70bfd7d
to
807a738
Compare
I'm going to redo this PR to tidy up the commits. |
Actually just gonna squash this one together 👍 |
3d454df
to
36d8a7a
Compare
// http://responsivenews.co.uk/post/18948466399/cutting-the-mustard | ||
if (document.addEventListener) { | ||
document.addEventListener('DOMContentLoaded', function () { | ||
AccessibilityTest('.js-test-a11y', function (err, results) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use data-module="test-a11y"
pattern?
var axeOptions = { | ||
restoreScroll: true, | ||
include: [selector] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace here: run through standardjs linter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some space 👍
restoreScroll: true, | ||
include: [selector] | ||
} | ||
axe.run(axeOptions, function (err, results, blah, boo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blah, boo 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
36d8a7a
to
68b3f78
Compare
}) | ||
|
||
it('should throw if there\'s a contrast issue', function (done) { | ||
addToDom('<a href="#">Low contrast</a>', 'a { background: white; color: #ddd }') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
test/dummy/config/application.rb
Outdated
@@ -7,6 +7,7 @@ | |||
require 'action_cable/engine' | |||
require 'rails/test_unit/railtie' | |||
require 'sprockets/railtie' | |||
require 'jasmine' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the pain caused by this – is it worth adding a comment or more of a length description in commit?
Are the screenshots in the PR still accurate? |
68b3f78
to
cbb8b95
Compare
@fofr screenshots are accurate yes |
These tests will look for '[data-module="test-a11y"]' and run axe against them, it'll then throw an error to be caught in dev tools or better in an applications' integration tests. Adds Jasmine as a development dependency to test this behaviour, we add require jasmine to the dummy application so that the default rake build will execute successfully.
cbb8b95
to
3bd7524
Compare
@@ -0,0 +1,136 @@ | |||
/* global describe, afterEach, it, expect */ | |||
|
|||
var TEST_SELECTOR = '.js-test-a11y' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need updating too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some troubles with using a consistent data attribute, I don't think axe likes it as much when outputting the targeting.
Since this spec test the behaviour rather than how it works in the guide, this is fine.
spec/spec_helper.rb
Outdated
|
||
WebMock.disable_net_connect!(allow_localhost: true) | ||
|
||
# Allow us to test Javascript for example thrown errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"for errors thrown by examples"?
@@ -83,12 +84,18 @@ | |||
end | |||
end | |||
|
|||
it 'guide throws errors if component has a11y issues' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"accessibility"
57e95c1
to
885783f
Compare
@@ -3,6 +3,12 @@ | |||
require 'webmock/rspec' | |||
require 'slimmer/rspec' | |||
require 'capybara/rails' | |||
require 'capybara/poltergeist' | |||
|
|||
WebMock.disable_net_connect!(allow_localhost: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this stop external scripts from loading?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied from government-frontend https://github.com/alphagov/government-frontend/blob/master/test/support/webmock.rb
885783f
to
efc7237
Compare
Makes sure a JavaScript error is thrown on pages where there is an accessibility issue.
efc7237
to
2ecfaac
Compare
Since we're using the alpha release, the help urls generated are not live yet. This commit fixes that by pointing at the 2.3.x release, and adds a message that'll be noticed if someone updated axe in the future.
0f7d1fe
to
50453e5
Compare
Regarding 46c86e3, I'm not sure why CI was running the tests with Ruby 2.4 when 2.3.1 is specified in the .ruby-version file. Edit: We test against 2.2, 2.3 and 2.4: |
This branch fails locally on 2.3.1 and 2.4:
|
Tests were running without running `assets:precompile` and this led javascript to be unavailable in the test app. They passed on CI because we run the assets:precompile task as part of the standard CI suite. They only failed locally.
We want to know if there are any errors in our dummy app.
Fixed local tests in 5636164 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have fixed the issue with local tests.
Top work 👍 💯
* Add aXe accessibility testing javascript to component guide pages (PR #33)
These tests will look for '[data-module="test-a11y"]' and run axe against them,
it'll then throw an error to be caught in dev tools or better in an applications'
integration tests.
Adds Jasmine as a development dependency to test this behaviour, we add require jasmine to the dummy application
so that the default rake build will execute successfully.
government-frontend integration test failure:
Chrome DevTools example: