defmodule MicrowavepropWeb.RoverLiveTest do use MicrowavepropWeb.ConnCase, async: false import Phoenix.LiveViewTest describe "GET /rover" do test "renders the Rover Planner sidebar + map hook", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/rover") assert html =~ "Rover Planner" # Band selector + station form. assert html =~ ~s(id="rover-map") assert html =~ ~s(phx-hook="RoverMap") assert html =~ "Add station" # Default band is 10_000 MHz — check the corresponding option label. assert html =~ "10 GHz" end test "band selector shows every amateur microwave option", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/rover") # BandConfig.band_options/0 currently includes these microwave bands. for label <- ~w(50MHz 144MHz 432MHz 1296MHz 10GHz 24GHz) do nospace = label |> String.replace("MHz", " MHz") |> String.replace("GHz", " GHz") assert html =~ nospace, "expected band option #{nospace} in rover HTML" end end test "a maidenhead grid in the URL resolves a station synchronously", %{conn: conn} do {:ok, view, _html} = live(conn, ~p"/rover?stations=EM13") # Async resolution runs in a message; flush by calling render. html = render(view) assert html =~ "EM13" end test "selecting a band patches the URL and keeps the selection", %{conn: conn} do {:ok, view, _html} = live(conn, ~p"/rover") view |> element(~s(select[name="band"])) |> render_change(%{band: "1296"}) # URL patch replaces the current URL with ?band=1296. assert_patched(view, ~p"/rover?band=1296") assert render(view) =~ ~s(