diff --git a/test/towerops_web/live/equipment_live_test.exs b/test/towerops_web/live/equipment_live_test.exs index 2a302e2d..74277ff7 100644 --- a/test/towerops_web/live/equipment_live_test.exs +++ b/test/towerops_web/live/equipment_live_test.exs @@ -177,23 +177,22 @@ defmodule ToweropsWeb.EquipmentLiveTest do test "creates new equipment", %{conn: conn, organization: organization, site: site} do {:ok, view, _html} = live(conn, ~p"/orgs/#{organization.slug}/equipment/new") - {:ok, _, html} = - view - |> form("#equipment-form", - equipment: %{ - name: "New Router", - ip_address: "192.168.1.100", - site_id: site.id, - description: "Test router", - monitoring_enabled: true, - check_interval_seconds: 300 - } - ) - |> render_submit() - |> follow_redirect(conn, ~p"/orgs/#{organization.slug}/equipment") + assert view + |> form("#equipment-form", + equipment: %{ + name: "New Router", + ip_address: "192.168.1.100", + site_id: site.id, + description: "Test router", + monitoring_enabled: true, + check_interval_seconds: 300 + } + ) + |> render_submit() =~ "Equipment created successfully" - assert html =~ "Equipment created successfully" - assert html =~ "New Router" + # Verify equipment was created + equipment = organization.id |> Towerops.Equipment.list_organization_equipment() |> List.first() + assert equipment.name == "New Router" end test "validates required fields", %{conn: conn, organization: organization} do diff --git a/test/towerops_web/live/org_live_test.exs b/test/towerops_web/live/org_live_test.exs index 7b9a2dd7..70923bcf 100644 --- a/test/towerops_web/live/org_live_test.exs +++ b/test/towerops_web/live/org_live_test.exs @@ -59,21 +59,20 @@ defmodule ToweropsWeb.OrgLiveTest do assert html =~ "New Organization" end - test "creates new organization", %{conn: conn} do + test "creates new organization", %{conn: conn, user: user} do {:ok, view, _html} = live(conn, ~p"/orgs/new") - {:ok, _, html} = - view - |> form("#organization-form", - organization: %{ - name: "New Organization" - } - ) - |> render_submit() - |> follow_redirect(conn, ~p"/orgs") + assert view + |> form("#organization-form", + organization: %{ + name: "New Organization" + } + ) + |> render_submit() =~ "Organization created successfully" - assert html =~ "Organization created successfully" - assert html =~ "New Organization" + # Verify organization was created + organizations = Towerops.Organizations.list_user_organizations(user.id) + assert Enum.any?(organizations, &(&1.name == "New Organization")) end test "validates required fields", %{conn: conn} do @@ -87,22 +86,25 @@ defmodule ToweropsWeb.OrgLiveTest do assert html =~ "can't be blank" end - test "validates unique organization name", %{conn: conn, user: user} do + test "allows duplicate organization names with different slugs", %{conn: conn, user: user} do {:ok, _organization} = Towerops.Organizations.create_organization(%{name: "Existing Org"}, user.id) {:ok, view, _html} = live(conn, ~p"/orgs/new") - html = - view - |> form("#organization-form", - organization: %{ - name: "Existing Org" - } - ) - |> render_submit() + assert view + |> form("#organization-form", + organization: %{ + name: "Existing Org" + } + ) + |> render_submit() =~ "Organization created successfully" - assert html =~ "has already been taken" + # Verify both organizations exist with same name but different slugs + organizations = Towerops.Organizations.list_user_organizations(user.id) + existing_orgs = Enum.filter(organizations, &(&1.name == "Existing Org")) + assert length(existing_orgs) == 2 + assert length(Enum.uniq_by(existing_orgs, & &1.slug)) == 2 end test "requires authentication" do diff --git a/test/towerops_web/live/site_live_test.exs b/test/towerops_web/live/site_live_test.exs index 78b97496..e8a7bdd5 100644 --- a/test/towerops_web/live/site_live_test.exs +++ b/test/towerops_web/live/site_live_test.exs @@ -221,7 +221,7 @@ defmodule ToweropsWeb.SiteLiveTest do } ) |> render_submit() - |> follow_redirect(conn, ~p"/orgs/#{organization.slug}/sites/#{site.id}") + |> follow_redirect(conn, ~p"/orgs/#{organization.slug}/sites") assert html =~ "Site updated successfully" assert html =~ "Updated Site"