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 # The URL parameter triggers an async resolve. The page must # render the chrome (header, search bar) and a loading state # synchronously — *before* the geocoder / HRRR fetch returns. {:ok, _view, html} = live(conn, ~p"/skewt?q=EM12kp") assert html =~ "Skew-T-Log-P" assert html =~ ~s|placeholder="EM12kp| assert html =~ "Resolving location" # Location label has not arrived yet — that's the whole point. 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") # Wait for the :load_skewt async to finish, then re-render. 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 end end