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%.
37 lines
1.1 KiB
Elixir
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
|