diff --git a/lib/mv_web/live/user_live/show.ex b/lib/mv_web/live/user_live/show.ex index 3bf6baf..609a07c 100644 --- a/lib/mv_web/live/user_live/show.ex +++ b/lib/mv_web/live/user_live/show.ex @@ -4,7 +4,7 @@ defmodule MvWeb.UserLive.Show do @impl true def render(assigns) do ~H""" - + <.header> {gettext("User")} {@user.email} <:subtitle>{gettext("This is a user record from your database.")} diff --git a/test/mv_web/live/profile_navigation_test.exs b/test/mv_web/live/profile_navigation_test.exs index b90c74b..8a59656 100644 --- a/test/mv_web/live/profile_navigation_test.exs +++ b/test/mv_web/live/profile_navigation_test.exs @@ -16,18 +16,6 @@ defmodule MvWeb.ProfileNavigationTest do assert_redirected(view, "/users/#{user.id}") end - test "profile button is visible on all main pages", %{conn: conn} do - # Setup: Create and login a user - user = create_test_user(%{email: "test@example.com"}) - conn = conn_with_password_user(conn, user) - - # Test main routes - for path <- ["/", "/members", "/properties", "/users"] do - {:ok, _view, html} = live(conn, path) - assert html =~ "Profil" - end - end - test "profile navigation shows correct user data", %{conn: conn} do # Setup: Create and login a user user = create_test_user(%{email: "test@example.com"}) @@ -148,4 +136,47 @@ defmodule MvWeb.ProfileNavigationTest do assert_redirected(view_oidc, "/users/#{oidc_user.id}") end end + + describe "authenticated views" do + setup %{conn: conn} do + user = create_test_user(%{email: "test@example.com"}) + conn = conn_with_password_user(conn, user) + {:ok, conn: conn, user: user} + end + + @authenticated_paths [ + "/", + "/members", + "/members/new", + "/properties", + "/properties/new", + "/property_types", + "/property_types/new", + "/users", + "/users/new" + ] + + for path <- @authenticated_paths do + @path path + test "layout shows user data on #{path}", %{conn: conn, user: user} do + {:ok, _view, html} = live(conn, @path) + # The navbar (which requires current_user) should be visible + assert html =~ "navbar" + # Profile button should be visible + assert html =~ "Profil" + # User ID should be in profile link + assert html =~ ~p"/users/#{user.id}" + end + end + + test "layout shows user data on user profile page", %{conn: conn, user: user} do + {:ok, _view, html} = live(conn, ~p"/users/#{user.id}") + # The navbar (which requires current_user) should be visible + assert html =~ "navbar" + # Profile button should be visible + assert html =~ "Profil" + # User ID should be in profile link + assert html =~ ~p"/users/#{user.id}" + end + end end