Adds a full-screen map view rendering every Good rover-location as a green circle marker (popup links to the detail page). Uses the standard OSM/Satellite + Maidenhead grid overlay pattern. Bad locations are excluded. Adds a Map button next to Add location on the index header.
35 lines
1.3 KiB
Elixir
35 lines
1.3 KiB
Elixir
defmodule MicrowavepropWeb.RoverLocationsLive.MapTest do
|
|
use MicrowavepropWeb.ConnCase, async: true
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
alias Microwaveprop.AccountsFixtures
|
|
alias Microwaveprop.Rover
|
|
|
|
test "renders the map shell with a count + JS hook container", %{conn: conn} do
|
|
user = AccountsFixtures.user_fixture()
|
|
|
|
{:ok, _} = Rover.create_location(user, %{lat: 32.0, lon: -97.0, status: :good})
|
|
{:ok, _} = Rover.create_location(user, %{lat: 33.0, lon: -98.0, status: :good})
|
|
# `bad` rows must NOT show up on the map.
|
|
{:ok, _} = Rover.create_location(user, %{lat: 34.0, lon: -99.0, status: :bad})
|
|
|
|
{:ok, lv, html} = live(conn, ~p"/rover-locations/map")
|
|
|
|
assert html =~ "Rover Locations Map"
|
|
assert html =~ "2 good locations"
|
|
assert has_element?(lv, "#rover-locations-map[phx-hook=RoverLocationsMap]")
|
|
# Marker payload only includes the two good rows.
|
|
refute html =~ ~s("lat":34.0)
|
|
end
|
|
|
|
test "List link returns to /rover-locations", %{conn: conn} do
|
|
{:ok, lv, _html} = live(conn, ~p"/rover-locations/map")
|
|
assert has_element?(lv, "a[href='/rover-locations']", "List")
|
|
end
|
|
|
|
test "/rover-locations renders a Map link", %{conn: conn} do
|
|
{:ok, lv, _html} = live(conn, ~p"/rover-locations")
|
|
assert has_element?(lv, "a[href='/rover-locations/map']", "Map")
|
|
end
|
|
end
|