From 2c2a0e185eab2dca76986d30a88944124f7d69f1 Mon Sep 17 00:00:00 2001 From: Hanna Laakso Date: Mon, 20 May 2024 17:44:14 +0100 Subject: [PATCH 1/4] Differentiate search results for places page title from index page title --- app/views/place/_place.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/place/_place.html.erb b/app/views/place/_place.html.erb index 2b54ad8fe..4950d4151 100644 --- a/app/views/place/_place.html.erb +++ b/app/views/place/_place.html.erb @@ -1,3 +1,7 @@ +<% + content_for :title, "#{publication.title}: #{t('formats.local_transaction.search_result')} - GOV.UK" +%> + <% places.each do |place| %>
  • From 58ac33841e1c705440d5f5a2d7de2f60ff2c2460 Mon Sep 17 00:00:00 2001 From: Hanna Laakso Date: Mon, 20 May 2024 17:45:17 +0100 Subject: [PATCH 2/4] Differentiate multiple auths places page title from index page title --- app/views/place/multiple_authorities.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/place/multiple_authorities.html.erb b/app/views/place/multiple_authorities.html.erb index 5b53de7f4..d7edd94f1 100644 --- a/app/views/place/multiple_authorities.html.erb +++ b/app/views/place/multiple_authorities.html.erb @@ -1,3 +1,5 @@ +<% content_for :title, "#{publication.title}: #{t('formats.local_transaction.select_address').downcase} - GOV.UK" %> + <%= render layout: "shared/base_page", locals: { title: publication.title, publication: publication, From bb9c56929d94c8b750f1eadbf8c98a8177b7cba1 Mon Sep 17 00:00:00 2001 From: Hanna Laakso Date: Mon, 20 May 2024 18:04:08 +0100 Subject: [PATCH 3/4] Fix bug that created a location error for multiple authorities This line was creating a location error when the search result contained multiple authorities. You could see this on live on the multiple authorities search result page page title eg. "Error: Find a Disabled Students' Allowance assessment provider - GOV.UK" This PR already adds the correct page title for search result pages, but the location error would still get appended to that eg. "Find a Disabled Students' Allowance assessment provider: select an address - GOV.UKError: Find a Disabled Students' Allowance assessment provider - GOV.UK" The check added in this commit is the same as the check on line 17 to check if the multiple authorities template should be rendered (that line also checks if postcode is provided, but we already check for that on line 55 here). However, I'm not sure if my "fix" is the best way to handle this or if bypassing multiple authorities in this way could be introducing some other issue. Maybe we should why the places_not_found method from the model doesn't recognise multiple authorities as a valid result. I've tried to superficially compare how this is handled for the other postcode finders like local transaction but those use the location_api model instead. --- app/controllers/place_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/place_controller.rb b/app/controllers/place_controller.rb index 6d336268b..a9dfd869d 100644 --- a/app/controllers/place_controller.rb +++ b/app/controllers/place_controller.rb @@ -55,7 +55,7 @@ def location_error return LocationError.new(INVALID_POSTCODE) unless postcode_provided? return LocationError.new(INVALID_POSTCODE) if places_manager_response.invalid_postcode? - LocationError.new(NO_LOCATION) if places_manager_response.places_not_found? + LocationError.new(NO_LOCATION) if places_manager_response.places_not_found? && !places_manager_response.addresses_returned? end def places_manager_response From b24664bb65a46dd4d5b81a740b49d05fb7efacb1 Mon Sep 17 00:00:00 2001 From: Hanna Laakso Date: Mon, 20 May 2024 18:06:07 +0100 Subject: [PATCH 4/4] Test for correct places search result and multiple auths page titles --- test/integration/place_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/integration/place_test.rb b/test/integration/place_test.rb index 12a89c846..98ed41b0f 100644 --- a/test/integration/place_test.rb +++ b/test/integration/place_test.rb @@ -130,6 +130,10 @@ class PlacesTest < ActionDispatch::IntegrationTest assert_current_url "/passport-interview-office" end + should "include the search result text in the page title" do + assert page.has_title?("Find a passport interview office: #{I18n.t('formats.local_transaction.search_result')} - GOV.UK", exact: true) + end + should "not display an error message" do assert page.has_no_content?("Please enter a valid full UK postcode.") end @@ -329,6 +333,10 @@ class PlacesTest < ActionDispatch::IntegrationTest click_on "Find" end + should "include the select address text in the page title" do + assert page.has_title?("Find a passport interview office: #{I18n.t('formats.local_transaction.select_address').downcase} - GOV.UK", exact: true) + end + should "display the address chooser" do assert page.has_content?("House 1") end