test: GraphLive.Show error branches for missing sensor/storage/interface
Adds 4 tests that drive the nil → nil fallbacks in load_single_sensor_chart_data, load_storage_chart_data, load_interface_errors_chart_data, and load_interface_traffic_chart_data by navigating to graph routes with non-existent IDs.
This commit is contained in:
parent
940b4daf14
commit
fb288395aa
1 changed files with 48 additions and 0 deletions
|
|
@ -511,6 +511,54 @@ defmodule ToweropsWeb.GraphLive.ShowEventsTest do
|
|||
assert {:error, {:live_redirect, %{to: "/devices"}}} =
|
||||
live(conn, ~p"/devices/#{fake_id}/graph/processors")
|
||||
end
|
||||
|
||||
test "renders gracefully when sensor_id query param does not exist", %{
|
||||
conn: conn,
|
||||
device: device
|
||||
} do
|
||||
fake_sensor_id = Ecto.UUID.generate()
|
||||
|
||||
{:ok, _view, html} =
|
||||
live(conn, ~p"/devices/#{device.id}/graph/temperature?sensor_id=#{fake_sensor_id}")
|
||||
|
||||
assert is_binary(html)
|
||||
end
|
||||
|
||||
test "renders gracefully when storage_id query param does not exist", %{
|
||||
conn: conn,
|
||||
device: device
|
||||
} do
|
||||
fake_storage_id = Ecto.UUID.generate()
|
||||
|
||||
{:ok, _view, html} =
|
||||
live(conn, ~p"/devices/#{device.id}/graph/storage_volume?storage_id=#{fake_storage_id}")
|
||||
|
||||
assert is_binary(html)
|
||||
end
|
||||
|
||||
test "renders interface_errors with non-existent interface id", %{
|
||||
conn: conn,
|
||||
device: device
|
||||
} do
|
||||
fake_interface_id = Ecto.UUID.generate()
|
||||
|
||||
{:ok, _view, html} =
|
||||
live(conn, ~p"/devices/#{device.id}/graph/interface_errors?interface_id=#{fake_interface_id}")
|
||||
|
||||
assert is_binary(html)
|
||||
end
|
||||
|
||||
test "renders traffic with non-existent interface id", %{
|
||||
conn: conn,
|
||||
device: device
|
||||
} do
|
||||
fake_interface_id = Ecto.UUID.generate()
|
||||
|
||||
{:ok, _view, html} =
|
||||
live(conn, ~p"/devices/#{device.id}/graph/traffic?interface_id=#{fake_interface_id}")
|
||||
|
||||
assert is_binary(html)
|
||||
end
|
||||
end
|
||||
|
||||
describe "interface_errors graph data shapes" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue