Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-kirwan committed Dec 2, 2024
1 parent b1da197 commit f602401
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/views/content_items/document_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<% if @content_item.important_metadata.any? %>
<%= content_tag :div, class: "inverse-background responsive-bottom-margin" do %>
<%= content_tag :div, class: "important-metadata inverse-background responsive-bottom-margin" do %>
<%= render "govuk_publishing_components/components/metadata", {
inverse: true,
other: @content_item.important_metadata,
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/fatality_notice.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div class="content-bottom-margin">
<div class="responsive-bottom-margin">
<% if @content_item.important_metadata.any? %>
<%= content_tag :div, class: "inverse-background responsive-bottom-margin" do %>
<%= content_tag :div, class: "important-metadata inverse-background responsive-bottom-margin" do %>
<%= render "govuk_publishing_components/components/metadata", {
inverse: true,
other: @content_item.important_metadata,
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/specialist_document.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<% if @content_item.important_metadata.any? %>
<%= content_tag :div, class: "inverse-background responsive-bottom-margin" do %>
<%= content_tag :div, class: "important-metadata inverse-background responsive-bottom-margin" do %>
<%= render "govuk_publishing_components/components/metadata", {
inverse: true,
other: @content_item.important_metadata,
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/speech.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="content-bottom-margin">
<div class="responsive-bottom-margin">
<% if @content_item.important_metadata.any? %>
<%= content_tag :div, class: "inverse-background responsive-bottom-margin" do %>
<%= content_tag :div, class: "important-metadata inverse-background responsive-bottom-margin" do %>
<%= render "govuk_publishing_components/components/metadata", {
inverse: true,
other: @content_item.important_metadata,
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/statistical_data_set.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<% if @content_item.important_metadata.any? %>
<%= content_tag :div, class: "inverse-background responsive-bottom-margin" do %>
<%= content_tag :div, class: "important-metadata inverse-background responsive-bottom-margin" do %>
<%= render "govuk_publishing_components/components/metadata", {
inverse: true,
other: @content_item.important_metadata,
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/statistics_announcement.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<% if @content_item.important_metadata.any? %>
<%= content_tag :div, class: "inverse-background" do %>
<%= content_tag :div, class: "important-metadata inverse-background" do %>
<%= render "govuk_publishing_components/components/metadata", {
inverse: true,
other: @content_item.important_metadata,
Expand Down
4 changes: 2 additions & 2 deletions test/integration/fatality_notice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FatalityNoticeTest < ActionDispatch::IntegrationTest
from: {
"Ministry of Defence": "/government/organisations/ministry-of-defence",
},
})
}, context_selector: ".metadata-column")

assert_has_important_metadata(
"Field of operation": { "Zululand": "/government/fields-of-operation/zululand" },
Expand Down Expand Up @@ -60,7 +60,7 @@ class FatalityNoticeTest < ActionDispatch::IntegrationTest
assert_has_metadata({ from: {
"Ministry of Defence": "/government/organisations/ministry-of-defence",
"The Rt Hon Sir Eric Pickles MP": "/government/people/eric-pickles",
} })
} }, context_selector: ".metadata-column")
end

test "fatality notice with withdrawn notice" do
Expand Down
2 changes: 1 addition & 1 deletion test/integration/publication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PublicationTest < ActionDispatch::IntegrationTest
"Environment Agency": "/government/organisations/environment-agency",
"The Rt Hon Sir Eric Pickles MP": "/government/people/eric-pickles",
},
})
}, context_selector: ".metadata-column")

assert_has_structured_data(page, "Article")

Expand Down
2 changes: 1 addition & 1 deletion test/integration/specialist_document_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SpecialistDocumentTest < ActionDispatch::IntegrationTest
"Air Accidents Investigation Branch":
"/government/organisations/air-accidents-investigation-branch",
},
})
}, context_selector: ".metadata-column")
end

test "renders published and updated in metadata" do
Expand Down
2 changes: 1 addition & 1 deletion test/integration/speech_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SpeechTest < ActionDispatch::IntegrationTest
"The Rt Hon Andrea Leadsom MP": "/government/people/andrea-leadsom",
},
published: "8 March 2016",
})
}, context_selector: ".metadata-column")

assert_has_important_metadata(
"Delivered on":
Expand Down
3 changes: 2 additions & 1 deletion test/integration/statistical_data_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class StatisticalDataSetTest < ActionDispatch::IntegrationTest
assert_has_metadata({
published: "13 December 2012",
from: { "Department for Transport": "/government/organisations/department-for-transport" },
})
}, context_selector: ".metadata-column")

assert_footer_has_published_dates("Published 13 December 2012")
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/statistics_announcement_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class StatisticsAnnouncementTest < ActionDispatch::IntegrationTest
assert page.has_text?(@content_item["description"])
assert page.has_css?('img[alt="Accredited official statistics"]')

within ".app-c-important-metadata" do
within ".important-metadata .gem-c-metadata" do
assert page.has_text?(:all, "Release date: January 2016 (provisional)")
end
end
Expand Down Expand Up @@ -45,7 +45,7 @@ class StatisticsAnnouncementTest < ActionDispatch::IntegrationTest
assert page.has_text?(@content_item["description"])
assert page.has_text?(:all, "Release date: 20 January 2016 9:30am (confirmed)")

within ".release-date-changed .app-c-important-metadata" do
within ".release-date-changed .gem-c-metadata" do
assert page.has_text?("The release date has been changed")
assert page.has_text?("Previous date")
assert page.has_text?("19 January 2016 9:30am")
Expand Down
8 changes: 4 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def assert_has_publisher_metadata_other(any_args)
assert_has_metadata(any_args)
end

def assert_has_metadata(any_args, extra_metadata_classes: nil)
within ".gem-c-metadata#{extra_metadata_classes}" do
def assert_has_metadata(any_args, context_selector: nil, extra_metadata_classes: nil)
within "#{context_selector} .gem-c-metadata#{extra_metadata_classes}" do
any_args.each_value do |value|
value = { value => nil } if value.is_a?(String)
value.each do |text, href|
Expand Down Expand Up @@ -138,9 +138,9 @@ def assert_has_metadata_local(metadata, term_selector, definition_selector)
end

def assert_has_important_metadata(metadata)
within(".app-c-important-metadata") do
within(".important-metadata .gem-c-metadata") do
assert_has_metadata_local(
metadata, ".app-c-important-metadata__term", ".app-c-important-metadata__definition"
metadata, ".gem-c-metadata__term", ".gem-c-metadata__definition"
)
end
end
Expand Down

0 comments on commit f602401

Please sign in to comment.