Passes `capture_log: true` to ExUnit.start/1 so log output emitted
during a passing test stays in the per-test capture buffer instead of
stdout. Drops ~360 lines of noise from the suite: Postgrex teardown
disconnects, expected worker failures, NexradClient 404 stubs,
NotifyListener warm-skip messages, SNMP poll failures, PromEx tag-
drop warnings, and OTel-handler boot errors. Failing tests still
surface their full logs on report, so debugging is unchanged.
Side-effect fixes:
- LoggerFormatTest opts out via @moduletag capture_log: false — it
patches the :default :logger handler and capture_log hot-swaps the
same handler, so the setup lookup would 404.
- TelemetryTest.start_link/1 unlinks the supervisor before the brutal
kill so the exit signal doesn't propagate to the test process.
- Drop unused `import Ecto.Query` in a top_hours mix-task test.
- Drop unused default-arg `attrs \\ %{}` on create_contact/1 in
contact_map_live_test (every caller passes attrs explicitly).
Remaining noise is ~3 lines from oban_pro vendored-dep @impl warnings
(require an upstream patch) plus rare intermittent async teardowns.
91 lines
2.8 KiB
Elixir
91 lines
2.8 KiB
Elixir
defmodule MicrowavepropWeb.ContactMapLiveTest do
|
|
use MicrowavepropWeb.ConnCase, async: true
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
alias Microwaveprop.Radio.Contact
|
|
alias Microwaveprop.Repo
|
|
|
|
defp create_contact(attrs) do
|
|
default = %{
|
|
station1: "W5XD",
|
|
station2: "K5TR",
|
|
qso_timestamp: ~U[2026-03-28 18:00:00Z],
|
|
mode: "CW",
|
|
band: Decimal.new("1296"),
|
|
grid1: "EM12",
|
|
grid2: "EM00",
|
|
pos1: %{"lat" => 32.9, "lon" => -97.0},
|
|
pos2: %{"lat" => 30.3, "lon" => -97.7},
|
|
distance_km: Decimal.new("295")
|
|
}
|
|
|
|
{:ok, contact} =
|
|
%Contact{}
|
|
|> Contact.changeset(Map.merge(default, attrs))
|
|
|> Repo.insert()
|
|
|
|
contact
|
|
end
|
|
|
|
describe "GET /contacts/map" do
|
|
test "renders the shell with the Contact Map heading + JS hook container", %{conn: conn} do
|
|
{:ok, _lv, html} = live(conn, ~p"/contacts/map")
|
|
|
|
assert html =~ "Contact Map"
|
|
assert html =~ ~s(id="contacts-map")
|
|
assert html =~ ~s(phx-hook="ContactsMap")
|
|
# Client fetches the JSON blob from the controller endpoint.
|
|
assert html =~ ~s(data-fetch-url="/api/contacts/map")
|
|
end
|
|
|
|
test "shows the contact count and the populated band list", %{conn: conn} do
|
|
_c1 = create_contact(%{band: Decimal.new("1296")})
|
|
_c2 = create_contact(%{band: Decimal.new("10000"), station1: "W5OTHR"})
|
|
|
|
{:ok, _lv, html} = live(conn, ~p"/contacts/map")
|
|
|
|
assert html =~ "2 contacts"
|
|
# band_label/1 converts bands ≥ 1000 MHz into GHz — integer values
|
|
# stay whole ("10 GHz"), non-integer ratios round to 1 decimal ("1.3 GHz").
|
|
assert html =~ "1.3 GHz"
|
|
assert html =~ "10 GHz"
|
|
end
|
|
|
|
test "empty DB renders '0 contacts' and no band checkboxes", %{conn: conn} do
|
|
{:ok, _lv, html} = live(conn, ~p"/contacts/map")
|
|
assert html =~ "0 contacts"
|
|
end
|
|
end
|
|
|
|
describe "filter_callsign event" do
|
|
test "stores the trimmed filter and pushes apply_filter to the hook", %{conn: conn} do
|
|
{:ok, lv, _html} = live(conn, ~p"/contacts/map")
|
|
|
|
html =
|
|
render_change(
|
|
# There's a mobile and a desktop filter — just grab the desktop one.
|
|
element(lv, ~s(input.input-sm[phx-change="filter_callsign"])),
|
|
%{"callsign" => " W5ISP "}
|
|
)
|
|
|
|
# Server stored the trimmed value in assigns, which round-trips
|
|
# back through the `value=` attribute.
|
|
assert html =~ ~s(value="W5ISP")
|
|
end
|
|
|
|
test "blank input round-trips as an empty value", %{conn: conn} do
|
|
{:ok, lv, _html} = live(conn, ~p"/contacts/map")
|
|
|
|
html =
|
|
render_change(
|
|
# There's a mobile and a desktop filter — just grab the desktop one.
|
|
element(lv, ~s(input.input-sm[phx-change="filter_callsign"])),
|
|
%{"callsign" => " "}
|
|
)
|
|
|
|
refute html =~ ~s(value=" ")
|
|
assert html =~ ~s(value="")
|
|
end
|
|
end
|
|
end
|