prop/test/microwaveprop_web/live/skewt_live_test.exs
Graham McIntire e40ade3b19
feat(skewt): add /skewt LiveView with HRRR-backed Skew-T-Log-P plot
Single search bar accepts an address, Maidenhead grid square, or
callsign; resolves it to lat/lon via Geocoder / Maidenhead /
CallsignLocation (cheapest classification first), snaps to the HRRR
grid via the existing ProfilesFile reader, and renders an SVG
Skew-T-Log-P with isobars, skewed isotherms, dry/moist adiabats, and
mixing-ratio lines. A button row picks between every available
forecast hour (now → f18); default is the most recent analysis.
Right pane lists derived stability and refractivity stats from
SoundingParams.derive (PWAT, BL depth, K-index, lifted index, min
dN/dh, ducting status + per-duct base/top/ΔM).

Renderer is server-side SVG so the page works without JS and serializes
into the LiveView payload as a single tag. Wind barbs are deliberately
omitted — HRRR's persisted profile carries wind only at 10 m AGL.
2026-04-25 12:13:46 -05:00

37 lines
1.2 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 "renders the resolved location label when given a grid square", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/skewt?q=EM12kp")
# The grid is resolved client-side from the URL — even when no
# HRRR profile happens to be on disk for this lat/lon, the
# location header should still surface so the user knows their
# input was accepted.
assert html =~ "EM12KP"
# Lat/lon get formatted to 3 decimals.
assert html =~ "32.646"
assert html =~ "-97.125"
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()
# After patch, the location label appears on the page.
assert render(view) =~ "EM12"
end
end
end