From: Tom Hughes Date: Wed, 17 Jul 2024 17:25:03 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/4998' X-Git-Tag: live~413 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e189bafa54d2b76d77989d329a3165232d5baf97?hp=38cb875c200ca15058557cd2a3070d8b129f41a2 Merge remote-tracking branch 'upstream/pull/4998' --- diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index 2f3882e3a..476ad30a1 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -118,8 +118,13 @@ OSM.Search = function (map) { page.pushstate = page.popstate = function (path) { var params = Qs.parse(path.substring(path.indexOf("?") + 1)); - $(".search_form input[name=query]").val(params.query); - $(".describe_location").hide(); + if (params.query) { + $(".search_form input[name=query]").val(params.query); + $(".describe_location").hide(); + } else if (params.lat && params.lon) { + $(".search_form input[name=query]").val(params.lat + ", " + params.lon); + $(".describe_location").hide(); + } OSM.loadSidebarContent(path, page.load); }; diff --git a/test/system/search_test.rb b/test/system/search_test.rb new file mode 100644 index 000000000..8cda1f74e --- /dev/null +++ b/test/system/search_test.rb @@ -0,0 +1,14 @@ +require "application_system_test_case" + +class SearchTest < ApplicationSystemTestCase + test "click on 'where is this' sets search input value" do + stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?}) + .to_return(:status => 404) + + visit "/#map=7/1.234/6.789" + + assert_field "Search", :with => "" + click_on "Where is this?" + assert_field "Search", :with => "1.234, 6.789" + end +end