From a285eb815bf2f61ae76b0c5d56492456d12fd1ff Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 23 Apr 2026 17:22:14 -0500 Subject: [PATCH] test: add PacketsLive.CallsignView mount tests --- .../live/packets_live/callsign_view_test.exs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/aprsme_web/live/packets_live/callsign_view_test.exs b/test/aprsme_web/live/packets_live/callsign_view_test.exs index 7807b30..cf2b707 100644 --- a/test/aprsme_web/live/packets_live/callsign_view_test.exs +++ b/test/aprsme_web/live/packets_live/callsign_view_test.exs @@ -1,8 +1,36 @@ defmodule AprsmeWeb.PacketsLive.CallsignViewTest do use AprsmeWeb.ConnCase + import Aprsme.PacketsFixtures import Phoenix.LiveViewTest + describe "mount" do + test "renders the page for a callsign with no existing packets", %{conn: conn} do + {:ok, _view, html} = live(conn, "/packets/NOPACKETS", on_error: :warn) + assert html =~ "NOPACKETS" + end + + test "normalizes a lowercase callsign", %{conn: conn} do + {:ok, _view, html} = live(conn, "/packets/abc1xyz", on_error: :warn) + assert html =~ "ABC1XYZ" + end + + test "renders with existing packet in db", %{conn: conn} do + _packet = + packet_fixture(%{ + sender: "LIVEPKT-1", + base_callsign: "LIVEPKT", + ssid: "1", + received_at: DateTime.utc_now(), + lat: Decimal.new("33.0"), + lon: Decimal.new("-96.0") + }) + + {:ok, _view, html} = live(conn, "/packets/LIVEPKT-1", on_error: :warn) + assert html =~ "LIVEPKT-1" + end + end + describe "live packet broadcast" do test "handles raw broadcast packet without :data key", %{conn: conn} do {:ok, view, _html} = live(conn, "/packets/DB0WUN-13")