-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1132 from alphagov/accessibility-testing
Include integration tests for static component guide
- Loading branch information
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'integration_test_helper' | ||
require 'webmock/minitest' | ||
require 'slimmer/test_helpers/govuk_components' | ||
|
||
module GovukPublishingComponentsSkipSlimmer | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action :skip_slimmer | ||
end | ||
|
||
def skip_slimmer | ||
response.headers[Slimmer::Headers::SKIP_HEADER] = "true" unless ENV['USE_SLIMMER'] == "true" | ||
end | ||
end | ||
|
||
GovukPublishingComponents::ApplicationController.include(GovukPublishingComponentsSkipSlimmer) | ||
|
||
class ComponentGuideTest < ActionDispatch::IntegrationTest | ||
include Slimmer::TestHelpers::GovukComponents | ||
|
||
def setup | ||
stub_shared_component_locales | ||
end | ||
|
||
context "component guide" do | ||
should "render an index" do | ||
visit "/component-guide" | ||
assert page.has_selector? "title", text: 'Static Component Guide', visible: false | ||
assert page.has_selector? shared_component_selector('title') | ||
end | ||
|
||
should "render all component previews without erroring" do | ||
visit '/component-guide' | ||
all(:css, '.component-list a').map { |el| "#{el[:href]}/preview" }.each { |component| visit component } | ||
end | ||
end | ||
end |