diff --git a/app/components/shared/map_location_component.rb b/app/components/shared/map_location_component.rb index bd59e52db..11bcbccba 100644 --- a/app/components/shared/map_location_component.rb +++ b/app/components/shared/map_location_component.rb @@ -62,7 +62,7 @@ class Shared::MapLocationComponent < ApplicationComponent marker_investments_coordinates: investments_coordinates, marker_latitude: map_location.latitude.presence, marker_longitude: map_location.longitude.presence, - marker_title: map_location.title.presence || marker_coordinates_text, + marker_title: marker_coordinates_text, marker_clustering: feature?("map.feature.marker_clustering"), geozones: geozones_data }.merge(input_selectors) diff --git a/spec/components/shared/map_location_component_spec.rb b/spec/components/shared/map_location_component_spec.rb index be8b045ba..f16a85e31 100644 --- a/spec/components/shared/map_location_component_spec.rb +++ b/spec/components/shared/map_location_component_spec.rb @@ -30,7 +30,7 @@ describe Shared::MapLocationComponent do end describe "marker title" do - it "uses the mappable title when there's a mappable with a title" do + it "uses the coordinates when there's a mappable" do map_location = build( :map_location, proposal: Proposal.new(title: "Meet me here"), @@ -40,7 +40,7 @@ describe Shared::MapLocationComponent do render_inline Shared::MapLocationComponent.new(map_location) - expect(page).to have_css "[data-marker-title='Meet me here']" + expect(page).to have_css "[data-marker-title='Latitude: 25.25. Longitude: 13.14']" end it "uses the coordinates when there's no mappable" do @@ -51,19 +51,6 @@ describe Shared::MapLocationComponent do expect(page).to have_css "[data-marker-title='Latitude: 25.25. Longitude: 13.14']" end - it "uses the coordinates when the mappable has an empty title" do - map_location = build( - :map_location, - proposal: Proposal.new(title: ""), - latitude: "25.25", - longitude: "13.14" - ) - - render_inline Shared::MapLocationComponent.new(map_location) - - expect(page).to have_css "[data-marker-title='Latitude: 25.25. Longitude: 13.14']" - end - it "is not present when the map location isn't available" do map_location = build(:map_location, latitude: "25.25", longitude: nil) diff --git a/spec/shared/system/mappable.rb b/spec/shared/system/mappable.rb index b0d33be04..1b130a46f 100644 --- a/spec/shared/system/mappable.rb +++ b/spec/shared/system/mappable.rb @@ -175,6 +175,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_edit_path, id: mappable.id) expect(page).to have_content "Navigate the map to the location and place the marker." + expect(page).to have_css ".map-icon[aria-label='Latitude: 51.48. Longitude: 0.0']" expect(page).to have_field "#{mappable_factory_name}_map_location_attributes_latitude", type: :hidden, with: "51.48" expect(page).to have_field "#{mappable_factory_name}_map_location_attributes_longitude", type: :hidden, @@ -255,8 +256,10 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, do_login_for user, management: management if management visit send(mappable_show_path, arguments) + label = "Latitude: #{map_location.latitude}. Longitude: #{map_location.longitude}" + within ".map-location" do - expect(page).to have_css ".map-icon[aria-label='#{mappable.title}']" + expect(page).to have_css ".map-icon[aria-label='#{label}']" end end