prop/test/microwaveprop_web/live/skewt_live_test.exs
Graham McIntire 9ef10f5aae
test: expand coverage across rover, pskr, valkey, skewt, scores
- Rover.Compute: road/prominence/clearance/clutter/canopy tests (90%)
- Rover.Prominence: full unit test suite with mock elev_lookup (100%)
- Rover.Elevation: dedup + multi-tile tests (44%)
- Rover.LinkMargin: edge cases, negative scores, all modes (57%)
- Rover.Location: changeset validation + statuses/0 (100%)
- RoverPlanning.Path: changeset validation + statuses/0 (67%)
- Pskr.FeatureBin: changeset validation (100%)
- Pskr.Mqtt: QoS reject, unknown type, varint overflow, ping/disconnect (97%)
- Valkey: not-configured error paths, empty guards (55%)
- ScoresController: bad params, time format, missing band tests (81%)
- SkewtLive: info/no-profiles state, loading states (29%)
2026-05-07 12:51:58 -05:00

86 lines
2.6 KiB
Elixir

defmodule MicrowavepropWeb.SkewtLiveTest do
use MicrowavepropWeb.ConnCase, async: false
import Phoenix.LiveViewTest
describe "GET /skewt" do
test "renders search bar with no results when no query is supplied", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/skewt")
assert html =~ "Skew-T-Log-P"
assert html =~ ~s|placeholder="EM12kp|
refute html =~ "viewBox=\"0 0 720"
end
test "initial render with a URL query shows the page chrome + a loading indicator", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/skewt?q=EM12kp")
assert html =~ "Skew-T-Log-P"
assert html =~ ~s|placeholder="EM12kp|
assert html =~ "Resolving location"
refute html =~ "EM12KP"
end
test "after the async completes the resolved location label appears", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/skewt?q=EM12kp")
html = render_async(view)
assert html =~ "EM12KP"
assert html =~ "32.646"
assert html =~ "-97.125"
refute html =~ "Resolving location"
end
test "submitting the form patches the URL with the query", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/skewt")
view |> form("form", q: "EM12") |> render_submit()
assert render_async(view) =~ "EM12"
end
test "shows info alert when no HRRR profiles are stored", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/skewt?q=EM12kp")
html = render_async(view)
assert html =~ "No HRRR profiles are currently stored"
assert has_element?(view, ".alert.alert-info")
end
test "time selector is not shown when there are no valid times", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/skewt?q=EM12kp")
render_async(view)
refute has_element?(view, "button[phx-click=select_time]")
end
test "loading indicator visible while async is in flight", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/skewt?q=EM12kp")
assert has_element?(view, ".loading")
assert render(view) =~ "Resolving location"
end
test "on successful async the loading state is cleared and location shown", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/skewt?q=EM12kp")
html = render_async(view)
refute html =~ "Resolving location"
assert html =~ "EM12KP"
assert html =~ "32.646"
end
test "coordinates are formatted with 3 decimal places", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/skewt?q=EM12kp")
html = render_async(view)
assert html =~ "32.646"
assert html =~ "-97.125"
end
end
end