Migrates all equipment-related flash messages to gettext for internationalization: - DeviceLive.Index: device discovery, reordering, error messages - DeviceLive.Show: backup messages, permission errors - DeviceLive.Form: device CRUD operations - AlertLive.Index: alert acknowledgment messages - SiteLive.Show: site discovery messages - SiteLive.Form: site CRUD and SNMP/agent propagation Fixes sudo mode test suite issues: - Updates Accounts.sudo_mode?/2 test to check last_sudo_at instead of authenticated_at - Adds register_and_log_in_user_with_sudo/1 helper to ConnCase - Fixes UserAuth sudo mode tests to use session-based authentication - Updates MyData tests to use sudo mode (now required per router config) - Removes obsolete UserSettingsLive "without sudo mode" test - Fixes grant_sudo_mode/1 DateTime truncation to seconds All equipment module tests passing. Ready for Phase 3 (Admin Features).
59 lines
1.7 KiB
Elixir
59 lines
1.7 KiB
Elixir
defmodule ToweropsWeb.AccountLive.MyDataTest do
|
|
use ToweropsWeb.ConnCase
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
setup :register_and_log_in_user_with_sudo
|
|
|
|
describe "My Data page" do
|
|
test "renders for organization owner without additional data", %{conn: conn} do
|
|
# register_and_log_in_user creates a user with a Personal org (as owner)
|
|
{:ok, _view, html} = live(conn, ~p"/users/my-data")
|
|
|
|
assert html =~ "My Data"
|
|
assert html =~ "Profile Information"
|
|
assert html =~ "Organizations"
|
|
assert html =~ "Devices"
|
|
assert html =~ "Audit Log"
|
|
end
|
|
|
|
test "renders for organization owner with full data", %{conn: conn, user: user} do
|
|
{:ok, organization} = Towerops.Organizations.create_organization(%{name: "Test Org"}, user.id)
|
|
|
|
{:ok, site} =
|
|
Towerops.Sites.create_site(%{
|
|
name: "Test Site",
|
|
organization_id: organization.id
|
|
})
|
|
|
|
{:ok, device} =
|
|
Towerops.Devices.create_device(%{
|
|
name: "Test Device",
|
|
ip_address: "192.168.1.1",
|
|
site_id: site.id,
|
|
monitoring_enabled: true
|
|
})
|
|
|
|
# Create an alert
|
|
{:ok, _alert} =
|
|
Towerops.Alerts.create_alert(%{
|
|
device_id: device.id,
|
|
alert_type: :device_down,
|
|
triggered_at: DateTime.utc_now(),
|
|
message: "Device is down"
|
|
})
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/users/my-data")
|
|
|
|
assert html =~ "My Data"
|
|
assert html =~ "Profile Information"
|
|
assert html =~ "Organizations"
|
|
assert html =~ "Devices"
|
|
assert html =~ "Recent Alerts"
|
|
assert html =~ "Audit Log"
|
|
assert html =~ "Test Org"
|
|
assert html =~ "Test Device"
|
|
assert html =~ "192.168.1.1"
|
|
end
|
|
end
|
|
end
|