defmodule MicrowavepropWeb.EmeLiveTest do use MicrowavepropWeb.ConnCase, async: true import Phoenix.LiveViewTest describe "GET /eme" do test "renders the empty form when no source is supplied", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/eme") assert html =~ "EME Calculator" assert html =~ "Station (callsign, grid, or" assert html =~ "Calculate" # No aim readout yet. refute html =~ "Antenna aim" end test "renders the live Moon aim + link budget when a grid source is provided", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/eme?source=EM13&band=1296&tx_power_dbm=50&tx_gain_dbi=30") assert html =~ "Antenna aim" assert html =~ "Link budget" assert html =~ "EM13" assert html =~ "Azimuth" assert html =~ "Elevation" assert html =~ "Slant range" # Path loss should be in the high 200s (dB) for 1296 MHz. assert html =~ "dB" end test "submitting the form patches the URL with the supplied params", %{conn: conn} do {:ok, view, _html} = live(conn, ~p"/eme") view |> form("form", source: "EM13", band: "432", tx_power_dbm: "60", tx_gain_dbi: "25", bandwidth_hz: "100", t_sys_k: "150" ) |> render_submit() # Flush any pending assign updates to catch redirects/patches. html = render(view) assert html =~ "EM13" assert html =~ "Antenna aim" end test "coordinate pair 'lat,lon' resolves without touching the callsign API", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/eme?source=32.9,-97.0&band=1296") assert html =~ "Antenna aim" assert html =~ "32.9" assert html =~ "-97.0" end end end