74 lines
2.3 KiB
Elixir
74 lines
2.3 KiB
Elixir
defmodule ToweropsWeb.DeviceLive.TabsSmokeTest do
|
|
@moduledoc """
|
|
Smoke tests exercising each DeviceLive.Show tab render. Each tab is backed by
|
|
a large component module (overview_tab, ports_tab, etc). Hitting each tab path
|
|
pulls those components into coverage even for an empty device.
|
|
"""
|
|
use ToweropsWeb.ConnCase, async: true
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
setup do
|
|
user = Towerops.AccountsFixtures.user_fixture(enable_totp: true)
|
|
{:ok, org} = Towerops.Organizations.create_organization(%{name: "Tabs Org"}, user.id)
|
|
|
|
device =
|
|
Towerops.DevicesFixtures.device_fixture(%{
|
|
organization_id: org.id,
|
|
name: "Tabs Device",
|
|
ip_address: "192.168.77.77"
|
|
})
|
|
|
|
%{user: user, org: org, device: device}
|
|
end
|
|
|
|
defp assert_tab_mounts(conn, user, device, tab) do
|
|
conn = log_in_user(conn, user)
|
|
url = "/devices/#{device.id}?tab=#{tab}"
|
|
|
|
# Dump the LiveView flash/error if mount fails so we can see what's happening.
|
|
case live(conn, url) do
|
|
{:ok, _view, html} ->
|
|
assert is_binary(html) and byte_size(html) > 0
|
|
|
|
{:error, {:redirect, %{to: to}}} ->
|
|
IO.puts("redirected to #{to}")
|
|
flunk("expected mount, got redirect to #{to}")
|
|
|
|
{:error, {:live_redirect, %{to: to}}} ->
|
|
IO.puts("live_redirected to #{to}")
|
|
flunk("expected mount, got live_redirect to #{to}")
|
|
|
|
other ->
|
|
flunk("unexpected result: #{inspect(other)}")
|
|
end
|
|
end
|
|
|
|
test "overview tab", %{conn: conn, user: user, device: device} do
|
|
assert_tab_mounts(conn, user, device, "overview")
|
|
end
|
|
|
|
test "ports tab", %{conn: conn, user: user, device: device} do
|
|
assert_tab_mounts(conn, user, device, "ports")
|
|
end
|
|
|
|
test "checks tab", %{conn: conn, user: user, device: device} do
|
|
assert_tab_mounts(conn, user, device, "checks")
|
|
end
|
|
|
|
test "backups tab", %{conn: conn, user: user, device: device} do
|
|
assert_tab_mounts(conn, user, device, "backups")
|
|
end
|
|
|
|
test "wireless tab", %{conn: conn, user: user, device: device} do
|
|
assert_tab_mounts(conn, user, device, "wireless")
|
|
end
|
|
|
|
test "preseem tab", %{conn: conn, user: user, device: device} do
|
|
assert_tab_mounts(conn, user, device, "preseem")
|
|
end
|
|
|
|
test "gaiia tab", %{conn: conn, user: user, device: device} do
|
|
assert_tab_mounts(conn, user, device, "gaiia")
|
|
end
|
|
end
|