From 0f4e5234f146b09567a0e1b49f7e8b682bcd2c9c Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 23 Apr 2026 17:40:51 -0500 Subject: [PATCH] test: add InfoLive.Show scenarios for various packet types and broadcasts --- .../live/info_live/show_full_render_test.exs | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/test/aprsme_web/live/info_live/show_full_render_test.exs b/test/aprsme_web/live/info_live/show_full_render_test.exs index 6f1c760..b2f7982 100644 --- a/test/aprsme_web/live/info_live/show_full_render_test.exs +++ b/test/aprsme_web/live/info_live/show_full_render_test.exs @@ -66,5 +66,80 @@ defmodule AprsmeWeb.InfoLive.ShowFullRenderTest do {:ok, _lv, html} = live(conn, ~p"/info/MICE1-9", on_error: :warn) assert html =~ "MICE1" end + + test "renders info with an SSID-only path query (e.g., K1ABC-15)", %{conn: conn} do + _packet = + packet_fixture(%{ + sender: "K1ABC-15", + base_callsign: "K1ABC", + ssid: "15", + received_at: DateTime.utc_now(), + lat: Decimal.new("42.0"), + lon: Decimal.new("-72.0"), + has_position: true, + path: "WIDE1-1,WIDE2-1,qAO,K5XYZ*" + }) + + {:ok, _lv, html} = live(conn, ~p"/info/K1ABC-15", on_error: :warn) + assert html =~ "K1ABC-15" + end + + test "renders info for a station with a weather-only packet", %{conn: conn} do + _packet = + packet_fixture(%{ + sender: "WXONLY", + base_callsign: "WXONLY", + ssid: "0", + received_at: DateTime.utc_now(), + lat: Decimal.new("38.0"), + lon: Decimal.new("-77.0"), + has_position: true, + has_weather: true, + data_type: "weather", + temperature: 68.0, + humidity: 80.0, + pressure: 1010.0, + wind_speed: 3.0, + wind_direction: 270, + wind_gust: 5.0, + rain_1h: 0.0, + rain_24h: 0.5, + rain_since_midnight: 0.3 + }) + + {:ok, _lv, html} = live(conn, ~p"/info/WXONLY", on_error: :warn) + assert html =~ "WXONLY" + end + + test "posts a postgres_packet broadcast to InfoLive.Show without crashing", %{conn: conn} do + _packet = + packet_fixture(%{ + sender: "BC1", + base_callsign: "BC1", + ssid: "0", + received_at: DateTime.utc_now(), + lat: Decimal.new("33.0"), + lon: Decimal.new("-96.5"), + has_position: true, + path: "WIDE1-1" + }) + + {:ok, lv, _html} = live(conn, ~p"/info/BC1", on_error: :warn) + + broadcast_payload = %{ + sender: "BC1", + base_callsign: "BC1", + ssid: "0", + lat: 33.1, + lon: -96.6, + received_at: DateTime.utc_now(), + has_position: true, + path: "WIDE1-1" + } + + send(lv.pid, {:postgres_packet, broadcast_payload}) + Process.sleep(50) + assert render(lv) =~ "BC1" + end end end