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