From: Tom Hughes Date: Sat, 15 Feb 2025 16:31:12 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/5131' X-Git-Tag: live~145 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/357352465c69e0bc1f4982bdd858715f850782ab?hp=91f5a68dec4ac25677eb24efeba02910b8517ae8 Merge remote-tracking branch 'upstream/pull/5131' --- diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index c3ee1e3bc..b6ead9f2d 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -309,8 +309,9 @@ $(document).ready(function () { }; function addObject(type, id, center) { + var hashParams = OSM.parseHash(window.location.hash); map.addObject({ type: type, id: parseInt(id, 10) }, function (bounds) { - if (!window.location.hash && bounds.isValid() && + if (!hashParams.center && bounds.isValid() && (center || !map.getBounds().contains(bounds))) { OSM.router.withoutMoveListener(function () { map.fitBounds(bounds); diff --git a/app/assets/javascripts/index/changeset.js b/app/assets/javascripts/index/changeset.js index 39b4abde1..d3e61270b 100644 --- a/app/assets/javascripts/index/changeset.js +++ b/app/assets/javascripts/index/changeset.js @@ -12,9 +12,10 @@ OSM.Changeset = function (map) { const changesetData = content.find("[data-changeset]").data("changeset"); changesetData.type = "changeset"; + var hashParams = OSM.parseHash(window.location.hash); initialize(); map.addObject(changesetData, function (bounds) { - if (!window.location.hash && bounds.isValid()) { + if (!hashParams.center && bounds.isValid()) { OSM.router.withoutMoveListener(function () { map.fitBounds(bounds); }); diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index e9c51f9bf..6a0487aaa 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -27,13 +27,16 @@ OSM.Note = function (map) { var data = $(".details").data(); if (!data) return; var latLng = L.latLng(data.coordinates.split(",")); - if (!map.getBounds().contains(latLng)) moveToNote(); + if (!map.getBounds().contains(latLng)) { + OSM.router.withoutMoveListener(function () { + map.setView(latLng, 15, { reset: true }); + }); + } }); }; page.load = function (path, id) { initialize(path, id); - moveToNote(); }; function initialize(path, id) { @@ -48,7 +51,6 @@ OSM.Note = function (map) { success: () => { OSM.loadSidebarContent(path, () => { initialize(path, id); - moveToNote(); }); }, error: (xhr) => { @@ -77,11 +79,19 @@ OSM.Note = function (map) { var data = $(".details").data(); if (data) { + var hashParams = OSM.parseHash(window.location.hash); map.addObject({ type: "note", id: parseInt(id, 10), latLng: L.latLng(data.coordinates.split(",")), icon: noteIcons[data.status] + }, function () { + if (!hashParams.center) { + var latLng = L.latLng(data.coordinates.split(",")); + OSM.router.withoutMoveListener(function () { + map.setView(latLng, 15, { reset: true }); + }); + } }); } } @@ -99,18 +109,6 @@ OSM.Note = function (map) { } } - function moveToNote() { - var data = $(".details").data(); - if (!data) return; - var latLng = L.latLng(data.coordinates.split(",")); - - if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) { - OSM.router.withoutMoveListener(function () { - map.setView(latLng, 15, { reset: true }); - }); - } - } - page.unload = function () { map.removeObject(); }; diff --git a/config/settings/test.yml b/config/settings/test.yml index b0e2f4613..b7cffcc27 100644 --- a/config/settings/test.yml +++ b/config/settings/test.yml @@ -53,3 +53,5 @@ doorkeeper_signing_key: | cK1+/2V+OkM/0nXjxPwPj7LiOediUyZNUn48r29uGOL1S83PSUdyST207CP6mZjc K8aJmnGsVEAcWPzbpNh14q/c -----END PRIVATE KEY----- +# Override Firefox binary used in system tests +#system_test_firefox_binary: diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 0ddb8a87a..496f37c16 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -9,6 +9,7 @@ end class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, :using => :headless_firefox do |options| options.add_preference("intl.accept_languages", "en") + options.binary = Settings.system_test_firefox_binary if Settings.system_test_firefox_binary end def before_setup diff --git a/test/teaspoon_env.rb b/test/teaspoon_env.rb index 8a9dc001f..c14045b1c 100644 --- a/test/teaspoon_env.rb +++ b/test/teaspoon_env.rb @@ -100,10 +100,12 @@ Teaspoon.configure do |config| # Capybara Webkit: https://github.com/jejacks0n/teaspoon/wiki/Using-Capybara-Webkit require "selenium-webdriver" config.driver = :selenium + firefox_options = Selenium::WebDriver::Firefox::Options.new(:args => ["-headless"]) + firefox_options.binary = Settings.system_test_firefox_binary if Settings.system_test_firefox_binary config.driver_options = { :client_driver => :firefox, :selenium_options => { - :options => Selenium::WebDriver::Firefox::Options.new(:args => ["-headless"]) + :options => firefox_options } }