Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed Jun 7, 2018
1 parent 6a2f13b commit cb10480
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/presenters/content_item/organisation_branding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def organisation_logo(organisation = default_organisation)
logo = organisation["details"]["logo"]
logo_component_params = {
organisation: {
name: logo["formatted_title"],
name: logo["formatted_title"].html_safe,
url: organisation["base_path"],
brand: organisation_brand(organisation),
crest: logo["crest"],
Expand Down
22 changes: 2 additions & 20 deletions test/integration/corporate_information_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,12 @@ class CorporateInformationPageTest < ActionDispatch::IntegrationTest

test "renders an organisation logo" do
setup_and_visit_content_item('corporate_information_page')
assert_has_component_organisation_logo(
organisation: {
name: 'Department<br/>of Health',
url: '/government/organisations/department-of-health',
brand: 'department-of-health',
crest: 'single-identity'
}
)
assert_has_component_organisation_logo
end

test "renders a custom organisation logo" do
setup_and_visit_content_item('corporate_information_page_translated_custom_logo')
assert_has_component_organisation_logo(
organisation: {
name: 'Land Registry',
url: '/government/organisations/land-registry',
brand: 'department-for-business-innovation-skills',
crest: nil,
image: {
url: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/organisation/logo/69/LR_logo_265.png',
alt_text: 'Land Registry'
}
}
)
assert_has_component_organisation_logo
end

test 'renders a withdrawal notice on withdrawn page' do
Expand Down
8 changes: 2 additions & 6 deletions test/integration/html_publication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class HtmlPublicationTest < ActionDispatch::IntegrationTest
assert page.has_css?('.gem-c-contents-list')
end

within ".organisation-logos" do
assert page.has_text?(@content_item["links"]["organisations"][0]["title"])
end

assert page.has_text?("The Environment Agency will normally put any responses it receives on the public register. This includes your name and contact details. Tell us if you don’t want your response to be public.")
end

Expand Down Expand Up @@ -78,8 +74,8 @@ class HtmlPublicationTest < ActionDispatch::IntegrationTest
end

def assert_has_component_organisation_logo_with_brand(brand, index = 1)
within("li.organisation-logo:nth-of-type(#{index}) #{shared_component_selector('organisation_logo')}") do
assert_equal brand, JSON.parse(page.text).fetch("organisation").fetch("brand")
within("li.organisation-logo:nth-of-type(#{index})") do
assert page.has_css?(".gem-c-organisation-logo.brand--#{brand}")
end
end

Expand Down
6 changes: 2 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ def assert_has_component_title(title)
assert page.has_css?('h1', text: title)
end

def assert_has_component_organisation_logo(logo, index = 1)
within(shared_component_selector("organisation_logo") + ":nth-of-type(#{index})") do
assert_equal logo, JSON.parse(page.text).deep_symbolize_keys
end
def assert_has_component_organisation_logo
assert page.has_css?(".gem-c-organisation-logo")
end

def assert_has_component_government_navigation_active(active)
Expand Down

0 comments on commit cb10480

Please sign in to comment.