Files
grecia/spec/components/shared/map_location_component_spec.rb
Javi Martín 288f62cdd2 Use coordinates as marker labels when there's only one mappable
When editing/showing a proposal or an investment, the most relevant
information regarding the marker are the coordinates. The title of the
proposal or investment is redundant because we already know the marker
is about that proposal/investment.

There's one problem with this approach, though: when editing a proposal
or an investment, the aria-label of the marker isn't updated
automatically when we move the marker to a different place. This
behaviour will only affect people who use both a screen reader and a
mouse, since keyboard users can't change the position of the marker in
the first place. We'll deal with this issue when we make it possible to
change the position of a marker using the keyboard.
2025-11-17 15:39:36 +01:00

63 lines
2.1 KiB
Ruby

require "rails_helper"
describe Shared::MapLocationComponent do
describe "remove marker button" do
it "is not rendered when there's no form" do
map_location = build(:map_location, proposal: Proposal.new)
render_inline Shared::MapLocationComponent.new(map_location)
expect(page).not_to have_button "Remove map marker"
end
it "is not rendered when there's no mappable" do
map_location = build(:map_location)
form = ConsulFormBuilder.new(:map_location, map_location, ApplicationController.new.view_context, {})
render_inline Shared::MapLocationComponent.new(map_location, form: form)
expect(page).not_to have_button "Remove map marker"
end
it "is rendered when there's a form and a mappable" do
map_location = build(:map_location, proposal: Proposal.new)
form = ConsulFormBuilder.new(:map_location, map_location, ApplicationController.new.view_context, {})
render_inline Shared::MapLocationComponent.new(map_location, form: form)
expect(page).to have_button "Remove map marker"
end
end
describe "marker title" do
it "uses the coordinates when there's a mappable" do
map_location = build(
:map_location,
proposal: Proposal.new(title: "Meet me here"),
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 "uses the coordinates when there's no mappable" do
map_location = build(:map_location, 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)
render_inline Shared::MapLocationComponent.new(map_location)
expect(page).not_to have_css "[data-marker-title]"
end
end
end