80 lines
2.4 KiB
Elixir
80 lines
2.4 KiB
Elixir
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
|
|
})
|
|
|
|
assert html =~ "<span>TU</span>" # Initials from test.user@example.com
|
|
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
|
|
})
|
|
|
|
assert html =~ "<span>OU</span>" # Initials from oidc.user@example.com
|
|
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
|
|
end
|
|
end
|