defmodule MvWeb.Layouts.NavbarTest do use MvWeb.ConnCase, async: true import Phoenix.LiveViewTest describe "navbar profile section" do test "renders profile button with correct attributes", %{conn: _conn} do # Setup: Create a user user = create_test_user(%{email: "test@example.com"}) html = render_component(&MvWeb.Layouts.Navbar.navbar/1, %{ current_user: user }) # Test dropdown structure assert html =~ "dropdown-content" assert html =~ "dropdown-end" assert html =~ ~s(role="button") # Test profile link assert html =~ ~s(href="/users/#{user.id}") assert html =~ "Profil" end @tag :skip # TODO: Implement user initials in navbar avatar - see issue #170 test "shows user initials in avatar", %{conn: _conn} do # Setup: Create a user with specific email for testing initials user = create_test_user(%{email: "test.user@example.com"}) html = render_component(&MvWeb.Layouts.Navbar.navbar/1, %{ current_user: user }) # Initials from test.user@example.com assert html =~ "TU" end @tag :skip # TODO: Implement user initials in navbar avatar - see issue #170 test "shows different initials for OIDC user", %{conn: _conn} do # Setup: Create OIDC user user_info = %{ "sub" => "oidc_123", "preferred_username" => "oidc.user@example.com" } oauth_tokens = %{ "access_token" => "test_token", "id_token" => "test_id_token" } user = Mv.Accounts.User |> Ash.Changeset.for_create(:register_with_rauthy, %{ user_info: user_info, oauth_tokens: oauth_tokens }) |> Ash.create!(domain: Mv.Accounts) html = render_component(&MvWeb.Layouts.Navbar.navbar/1, %{ current_user: user }) # Initials from oidc.user@example.com assert html =~ "OU" end test "includes all required navigation items", %{conn: _conn} do user = create_test_user(%{email: "test@example.com"}) html = render_component(&MvWeb.Layouts.Navbar.navbar/1, %{ current_user: user }) # Check for all required menu items assert html =~ "Profil" assert html =~ "Settings" assert html =~ "Logout" # Check for correct logout path assert html =~ ~s(href="/sign-out") end test "Settings link navigates to global settings page", %{conn: conn} do user = create_test_user(%{email: "test@example.com"}) conn = conn_with_oidc_user(conn, user) html = render_component(&MvWeb.Layouts.Navbar.navbar/1, %{ current_user: user }) # Check that Settings link exists and points to /settings assert html =~ "Settings" assert html =~ ~s(href="/settings") || html =~ ~s(navigate="/settings") # Verify the link actually works by navigating to it {:ok, _view, settings_html} = live(conn, ~p"/settings") assert settings_html =~ "Club Settings" end end end