From cbb87726852e4d614d8e54ffb5573b28288b3d47 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 28 Jul 2022 22:04:38 +0300 Subject: [PATCH] Fix map key tooltip --- app/assets/javascripts/leaflet.key.js | 2 +- test/system/site_test.rb | 31 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/leaflet.key.js b/app/assets/javascripts/leaflet.key.js index e839171ab..e170ff352 100644 --- a/app/assets/javascripts/leaflet.key.js +++ b/app/assets/javascripts/leaflet.key.js @@ -63,7 +63,7 @@ L.OSM.key = function (options) { var disabled = ["mapnik", "cyclemap"].indexOf(map.getMapBaseLayerId()) === -1; button .toggleClass("disabled", disabled) - .attr("data-original-title", + .attr("data-bs-original-title", I18n.t(disabled ? "javascripts.key.tooltip_disabled" : "javascripts.key.tooltip")); diff --git a/test/system/site_test.rb b/test/system/site_test.rb index 2ecc7f5a9..b9d7bcd57 100644 --- a/test/system/site_test.rb +++ b/test/system/site_test.rb @@ -6,4 +6,35 @@ class SiteTest < ApplicationSystemTestCase assert_selector "h1", :text => "OpenStreetMap" end + + test "tooltip shows for Layers button" do + visit "/" + + assert_no_selector ".tooltip" + button = find ".control-layers .control-button" + button.hover + assert_selector ".tooltip", :text => "Layers" + end + + test "tooltip shows for Map Key button on Standard layer" do + visit "/" + + assert_no_selector ".tooltip" + button = find ".control-key .control-button" + button.hover + tooltip = find ".tooltip" + tooltip.assert_text "Map Key" + tooltip.assert_no_text "not available" + end + + test "tooltip shows for Map Key button on a layer without a key provided" do + visit "/#layers=Y" # assumes that CyclOSM layer has no map key + + assert_no_selector ".tooltip" + button = find ".control-key .control-button" + button.hover + tooltip = find ".tooltip" + tooltip.assert_text "Map Key" + tooltip.assert_text "not available" + end end -- 2.39.5