New LiveView at /weather-ca duplicates the /weather UI but defaults the viewport to central Canada (55N, -100W, z=4) and renders the map div with data-source="hrdps". The JS hook reads that attribute and appends &source=hrdps to every cell fetch; the WeatherTileController routes those reads through Weather.weather_grid_hrdps_at/2, which only reads the <vt>.hrdps scalar dir and skips HRRR merging entirely. Timeline is sourced from ScalarFile.list_valid_times_hrdps/0 so HRDPS-only hours show up even when no HRRR file exists for the same valid_time. Also drops "— Unified" from the algo.md H1.
57 lines
1.9 KiB
Elixir
57 lines
1.9 KiB
Elixir
defmodule MicrowavepropWeb.WeatherCaMapLiveTest do
|
|
# async: false because we touch the shared scalar / profile dirs.
|
|
use MicrowavepropWeb.ConnCase, async: false
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
alias Microwaveprop.Propagation.ProfilesFile
|
|
alias Microwaveprop.Weather.GridCache
|
|
|
|
setup do
|
|
GridCache.clear()
|
|
|
|
on_exit(fn ->
|
|
GridCache.clear()
|
|
ProfilesFile.prune_older_than(~U[2099-12-31 23:59:59Z])
|
|
end)
|
|
|
|
:ok
|
|
end
|
|
|
|
test "mounts at /weather-ca with Canadian default viewport", %{conn: conn} do
|
|
{:ok, _lv, html} = live(conn, ~p"/weather-ca")
|
|
|
|
# Default viewport is centered roughly on central Canada at a low
|
|
# zoom — different from /weather's DFW@z7. The exact numbers are
|
|
# asserted so a routing accident (mounting WeatherMapLive at this
|
|
# path by mistake) is caught.
|
|
assert html =~ ~s(data-initial-lat="55.0")
|
|
assert html =~ ~s(data-initial-lon="-100.0")
|
|
assert html =~ ~s(data-initial-zoom="4")
|
|
end
|
|
|
|
test "renders the weather map element with data-source=hrdps", %{conn: conn} do
|
|
{:ok, _lv, html} = live(conn, ~p"/weather-ca")
|
|
|
|
# The JS hook reads data-source and appends &source=hrdps to its cell
|
|
# fetches. Without this attribute the page would silently fall back
|
|
# to HRRR-only reads and never show Canadian data.
|
|
assert html =~ ~s(data-source="hrdps")
|
|
end
|
|
|
|
test "viewport_changed event push_patches /weather-ca, not /weather", %{conn: conn} do
|
|
{:ok, lv, _html} = live(conn, ~p"/weather-ca")
|
|
|
|
render_hook(lv, "viewport_changed", %{"lat" => 60.0, "lon" => -110.0, "zoom" => 5})
|
|
|
|
assert_patch(lv, "/weather-ca?layer=temperature&lat=60.0&lon=-110.0&zoom=5")
|
|
end
|
|
|
|
test "select_layer push_patches a /weather-ca URL", %{conn: conn} do
|
|
{:ok, lv, _html} = live(conn, ~p"/weather-ca")
|
|
|
|
render_hook(lv, "select_layer", %{"layer" => "pwat"})
|
|
|
|
assert_patch(lv, "/weather-ca?layer=pwat&lat=55.0&lon=-100.0&zoom=4")
|
|
end
|
|
end
|