Skip to content

Commit

Permalink
Merge pull request #1132 from alphagov/accessibility-testing
Browse files Browse the repository at this point in the history
Include integration tests for static component guide
  • Loading branch information
fofr committed Sep 14, 2017
2 parents 312de27 + ce2bcb3 commit 04f6f7f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ GEM
commander (4.4.3)
highline (~> 1.7.2)
concurrent-ruby (1.0.5)
crack (0.4.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
debug_inspector (0.0.2)
domain_name (0.5.20170404)
Expand Down Expand Up @@ -118,6 +118,7 @@ GEM
slimmer
govuk_template (0.22.2)
rails (>= 3.1)
hashdiff (0.3.6)
highline (1.7.8)
htmlentities (4.3.4)
http-cookie (1.0.3)
Expand Down Expand Up @@ -282,9 +283,10 @@ GEM
kgio (~> 2.6)
rack
raindrops (~> 0.7)
webmock (1.21.0)
webmock (3.0.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
Expand Down
38 changes: 38 additions & 0 deletions test/integration/component_guide_test.rb
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

0 comments on commit 04f6f7f

Please sign in to comment.