defmodule CartosnapAppWeb.MapLiveTest do
use CartosnapAppWeb.ConnCase, async: true
import Phoenix.LiveViewTest
import CartosnapApp.PhotosFixtures
setup :register_and_log_in_user
test "puts your located photos on the map with neiam tiles", %{conn: conn, scope: scope} do
boston = photo_fixture(scope, lat: 42.36, lon: -71.06)
_nowhere = photo_fixture(scope)
{:ok, view, _html} = live(conn, ~p"/map")
map = view |> element("#photos-map") |> render()
assert map =~ ~s(phx-hook="PhotoMap")
assert map =~ "tiles.neiam.org"
assert map =~ boston.id
assert has_element?(view, "#map-panel-photos [data-photo-id='#{boston.id}']")
assert has_element?(view, "#map-unmapped")
end
test "the panel follows the map's bounds", %{conn: conn, scope: scope} do
boston = photo_fixture(scope, lat: 42.36, lon: -71.06)
seattle = photo_fixture(scope, lat: 47.61, lon: -122.33)
{:ok, view, _html} = live(conn, ~p"/map")
render_hook(view, "bounds", %{
"north" => 43.0,
"south" => 42.0,
"east" => -70.0,
"west" => -72.0
})
assert has_element?(view, "#map-panel-photos [data-photo-id='#{boston.id}']")
refute has_element?(view, "#map-panel-photos [data-photo-id='#{seattle.id}']")
end
test "photos anywhere in the world are mapped, with no coverage caveat",
%{conn: conn, scope: scope} do
paris = photo_fixture(scope, lat: 48.85, lon: 2.35)
{:ok, view, _html} = live(conn, ~p"/map")
assert render(element(view, "#photos-map")) =~ paris.id
refute render(view) =~ "North America"
end
end
neiam
/cartosnap_ex
public · Issues · Pulls · Labels · Forks · Compare · Actions queued · Badges · Packages
⭐
Log in to mark this repository.
1.6 KiB · text
History
e569b6d