Skip to content

Commit

Permalink
Test that all components render without error
Browse files Browse the repository at this point in the history
* Require webmock minitest for `stub_request` in
stub_shared_component_locales
* Add an ActiveSupport concern to avoid hitting Slimmer for component
guide requests (this matches the way we avoid hitting Slimmer when
using Jasmine)
* This doesn’t explicitly run Javascript, accessibility tests will not
yet be running
  • Loading branch information
fofr committed Sep 6, 2017
1 parent df2249a commit ce2bcb3
Showing 1 changed file with 38 additions and 0 deletions.
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 ce2bcb3

Please sign in to comment.