Skip to content

Commit

Permalink
Add test for custom_css_exclude_list
Browse files Browse the repository at this point in the history
- scenarios don't seem to reset config,
  so we also need to explicitly set this
  to nil in other tests.
  • Loading branch information
KludgeKML committed Feb 26, 2025
1 parent 8cca674 commit 4be7861
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/features/asset_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,21 @@
expect(page).to have_selector('link[href^="/assets/govuk_publishing_components/components/_heading-"][rel="stylesheet"]', visible: false)
end
end

scenario "request only unexcluded stylesheets when custom_css_exclude_list is set" do
GovukPublishingComponents.configure do |config|
config.custom_css_exclude_list = %w[notice details]
end

visit "/asset_helper"

within(:xpath, "//head", visible: false) do
expect(page).to have_xpath("//link", visible: false, count: 2)

expect(page).to have_selector('link[href^="/assets/application-"][rel="stylesheet"]', visible: false)
expect(page).not_to have_selector('link[href^="/assets/govuk_publishing_components/components/_notice-"][rel="stylesheet"]', visible: false)
expect(page).not_to have_selector('link[href^="/assets/govuk_publishing_components/components/_details-"][rel="stylesheet"]', visible: false)
expect(page).to have_selector('link[href^="/assets/govuk_publishing_components/components/_title-"][rel="stylesheet"]', visible: false)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
it "exclude stylesheets already in static when exclude_css_from_static is true and the request object is not available" do
GovukPublishingComponents.configure do |config|
config.exclude_css_from_static = true
config.custom_css_exclude_list = nil
end

add_gem_component_stylesheet("button")
Expand Down Expand Up @@ -35,6 +36,7 @@ def request
it "initialize asset helper then add multiple stylesheets but exclude 'button' stylesheet since it's already in static" do
GovukPublishingComponents.configure do |config|
config.exclude_css_from_static = true
config.custom_css_exclude_list = nil
end

add_gem_component_stylesheet("accordion")
Expand Down

0 comments on commit 4be7861

Please sign in to comment.