towerops/test/towerops_web/live/mobile_qr_live_test.exs
Graham McIntire 03ec909e3a test: add LiveView tests following testing-liveview patterns
Apply Testing LiveView course patterns (live/2, has_element?,
render_click, form/3). Add tests for MobileQRLive, WeathermapLive,
StatusPageLive, controllers, plugs, and pure function modules.
Expand proto decode coverage to 85.24%.
2026-05-07 12:55:39 -05:00

37 lines
1.1 KiB
Elixir

defmodule ToweropsWeb.MobileQRLiveTest do
use ToweropsWeb.ConnCase, async: true
import Phoenix.LiveViewTest
setup :register_and_log_in_user
describe "mount" do
test "renders QR code display", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/mobile/qr-login")
assert html =~ "Link Mobile App"
end
test "shows QR code image", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/mobile/qr-login")
assert has_element?(view, "img")
end
test "shows waiting message", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/mobile/qr-login")
assert html =~ "Waiting for mobile app to scan"
end
test "shows how-to instructions", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/mobile/qr-login")
assert html =~ "How to link your phone"
end
end
describe "handle_info" do
test "catch-all handles unexpected messages without crashing", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/mobile/qr-login")
send(view.pid, :unexpected_message)
assert render(view) =~ "Link Mobile App"
end
end
end