Skip to content
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 integration test helpers for component guide #68

Merged
merged 1 commit into from Sep 18, 2017
Merged

Add integration test helpers for component guide #68

merged 1 commit into from Sep 18, 2017

Conversation

@fofr
Copy link
Contributor

@fofr fofr commented Sep 18, 2017

Allow apps to include a component guide integration test that checks:

  • all component examples render without error
  • there are no accessibility errors on any of the previews

It asserts that the tests are available and have run. Any violations will throw a JS error.

Reviewers note: I wanted to include a test for the minitest test helpers. However, we have an intentionally failing test – a component with known accessibility errors, which I can't easily mock, stub or expect. That work is saved in a gist here: https://gist.github.com/fofr/ea3b60362f1cdf200c3090f6df98bc88

@fofr fofr requested review from andrewgarner and nickcolley Sep 18, 2017
assert_equal 'function', evaluate_script('typeof window.GOVUK.AccessibilityTest'), "AccessibilityTest javascript isn’t available"
assert_equal 'string', evaluate_script('typeof window.axe.version'), "aXe accessibility test library isn’t available"

all(:css, '.component-list a').map { |el| "#{el[:href]}/preview" }.each do |component|

This comment has been minimized.

@nickcolley

nickcolley Sep 18, 2017
Contributor

Since we're now within the Gem, can we do this smarter so we don't have to load the route page and speed up the tests?

This comment has been minimized.

@fofr

fofr Sep 18, 2017
Author Contributor

Considered that to be out of scope. I've written this as a drop-in replacement for what's in government-frontend.

This comment has been minimized.

@nickcolley

nickcolley Sep 18, 2017
Contributor

Fair 👍

README.md Outdated

The gem [includes integration tests](lib/govuk_publishing_components/minitest/component_guide_test.rb) to check that your component guide and examples are error free and that they meet basic accessibility needs.

Automated accessibility tests use [aXe](https://github.com/dequelabs/axe-core). Using our `AccessibilityTest` wrapper the gem runs the aXe suite against each example and throws Javascript errors for any violations. These Javascript errors can be used to fail a build in CI.

This comment has been minimized.

@andrewgarner

andrewgarner Sep 18, 2017
Contributor

Javascript JavaScript

visit '/component-guide'

# Confirm accessibility JS test is available
assert_equal 'function', evaluate_script('typeof window.GOVUK.AccessibilityTest'), "AccessibilityTest javascript isn’t available"

This comment has been minimized.

@andrewgarner

andrewgarner Sep 18, 2017
Contributor

javascript JavaScript

This comment has been minimized.

@fofr

fofr Sep 18, 2017
Author Contributor

👀

Allow apps to include a component guide integration test that checks:

* all component examples render without error
* there are no accessibility errors on any of the previews

It asserts that the tests are available and have run. Any violations
will throw a JS error.
@fofr fofr force-pushed the test-helpers branch from b9e6471 to 6881b3c Sep 18, 2017
@fofr fofr merged commit dd35515 into master Sep 18, 2017
1 check passed
1 check passed
continuous-integration/jenkins/branch This commit looks good
Details
@fofr fofr deleted the test-helpers branch Sep 18, 2017
fofr added a commit that referenced this pull request Sep 18, 2017
* Add integration tests for apps to use when testing their component
guide (PR #68)
@fofr fofr mentioned this pull request Sep 18, 2017
fofr added a commit to alphagov/government-frontend that referenced this pull request Sep 18, 2017
* Bump gem to 1.8.0
* Run component guide integration tests, including automated
accessibility tests
* See: alphagov/govuk_publishing_components#68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.