- CacheTest: fix sweep timing race by using negative TTL (-1) instead of positive TTL (1) for already-expired entries - ScoreCache: replace ETS match-spec DateTime comparisons with :ets.foldl + DateTime.compare — DateTime structs are maps in Elixir >= 1.15 and ETS can't compare maps with :< / :> guards - Accounts: drop unsupported returning: true on delete_all, return [] for expired tokens list - Backtest: catch ArgumentError from String.to_existing_atom for unknown feature names, preserving the helpful Mix.Error - ContactLive IndexTest: invalidate monthly_bars cache before assertion so test data is visible - RoverLocationsLive MapTest: invalidate cached points before assertion - StatusLiveTest: add DB cleanup in setup to reduce test interference; parameterize NARR candidate coordinates
38 lines
1.5 KiB
Elixir
38 lines
1.5 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})
|
|
|
|
# Invalidate the cached points so the LiveView picks up our test data.
|
|
Microwaveprop.Cache.invalidate({MicrowavepropWeb.RoverLocationsLive.Map, :points})
|
|
|
|
{: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
|