From 16d2e929c0c9316f6253d70b2135580835ca3506 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 23 Apr 2026 16:18:03 -0500 Subject: [PATCH] test: push coverage to 70% with more CoreComponents and PostgresNotifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CoreComponents.input/1: expanded coverage to include the select, textarea, generic-text, and unchecked-checkbox branches, plus error-vs-no-error border styling. - PostgresNotifier: handle_info forwards pg_notify payload to Aprsme.PubSub and ignores unrelated messages. Coverage 69.56 → 70.11%. --- test/aprsme/postgres_notifier_test.exs | 24 ++++ .../components/core_components_test.exs | 116 ++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 test/aprsme/postgres_notifier_test.exs diff --git a/test/aprsme/postgres_notifier_test.exs b/test/aprsme/postgres_notifier_test.exs new file mode 100644 index 0000000..bea6c96 --- /dev/null +++ b/test/aprsme/postgres_notifier_test.exs @@ -0,0 +1,24 @@ +defmodule Aprsme.PostgresNotifierTest do + use ExUnit.Case, async: true + + alias Aprsme.PostgresNotifier + + describe "handle_info/2 notification forwarding" do + test "broadcasts the payload on Aprsme.PubSub for aprs_events channel" do + :ok = Phoenix.PubSub.subscribe(Aprsme.PubSub, "postgres:aprsme_events") + + msg = {:notification, :conn_stub, :from_pid, "aprs_events", "payload-content"} + + assert {:noreply, state} = PostgresNotifier.handle_info(msg, %{conn: :stub}) + assert state.conn == :stub + + assert_receive {:postgres_notify, "payload-content"}, 500 + end + + test "ignores unrelated messages" do + state = %{conn: :stub} + assert {:noreply, ^state} = PostgresNotifier.handle_info(:random_message, state) + assert {:noreply, ^state} = PostgresNotifier.handle_info({:other_tuple, "data"}, state) + end + end +end diff --git a/test/aprsme_web/components/core_components_test.exs b/test/aprsme_web/components/core_components_test.exs index 9305ec8..c084aa3 100644 --- a/test/aprsme_web/components/core_components_test.exs +++ b/test/aprsme_web/components/core_components_test.exs @@ -145,6 +145,122 @@ defmodule AprsmeWeb.CoreComponentsTest do # Checkbox is pre-checked when value matches "true". assert html =~ "checked" end + + test "checkbox is unchecked when value is not 'true'" do + html = + render_component(&CoreComponents.input/1, %{ + id: "flag", + name: "flag", + type: "checkbox", + value: "false", + errors: [] + }) + + refute html =~ " checked " + end + end + + describe "input/1 select" do + test "renders a select with options" do + html = + render_component(&CoreComponents.input/1, %{ + id: "color", + name: "color", + type: "select", + label: "Color", + value: "red", + errors: [], + options: [{"Red", "red"}, {"Blue", "blue"}], + multiple: false, + prompt: nil + }) + + assert html =~ "