fix: fix tests and remove navbar remainings
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
30805b07ca
commit
8a1b14fc79
9 changed files with 706 additions and 332 deletions
|
|
@ -1,106 +0,0 @@
|
|||
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 =~ "<span>TU</span>"
|
||||
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 =~ "<span>OU</span>"
|
||||
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
|
||||
|
|
@ -143,14 +143,14 @@ defmodule MvWeb.Layouts.SidebarTest do
|
|||
assert html =~ ~s(href="/users")
|
||||
|
||||
# Check for Custom Fields link
|
||||
assert html =~ ~s(href="/custom_fields")
|
||||
assert html =~ ~s(href="/custom_field_values")
|
||||
|
||||
# Check for Contributions section
|
||||
assert html =~ ~s(href="/contribution_types")
|
||||
assert html =~ ~s(href="/contribution_settings")
|
||||
assert html =~ ~s(href="/membership_fee_settings")
|
||||
|
||||
# Check for Settings link (placeholder)
|
||||
assert html =~ ~s(href="#")
|
||||
assert html =~ ~s(href="/settings")
|
||||
end
|
||||
|
||||
test "T2.4: renders sidebar with main-sidebar ID" do
|
||||
|
|
@ -183,11 +183,11 @@ defmodule MvWeb.Layouts.SidebarTest do
|
|||
assert html =~ "hero-user-circle"
|
||||
|
||||
# Check for Custom Fields link with icon
|
||||
assert html =~ ~s(href="/custom_fields")
|
||||
assert html =~ ~s(href="/custom_field_values")
|
||||
assert html =~ "hero-rectangle-group"
|
||||
|
||||
# Check for Settings link with icon
|
||||
assert html =~ ~s(href="#")
|
||||
assert html =~ ~s(href="/settings")
|
||||
assert html =~ "hero-cog-6-tooth"
|
||||
|
||||
# Check for tooltips (data-tip attribute)
|
||||
|
|
@ -203,7 +203,7 @@ defmodule MvWeb.Layouts.SidebarTest do
|
|||
|
||||
# Check for contribution links
|
||||
assert html =~ ~s(href="/contribution_types")
|
||||
assert html =~ ~s(href="/contribution_settings")
|
||||
assert html =~ ~s(href="/membership_fee_settings")
|
||||
end
|
||||
|
||||
test "T3.3: renders nested menu with dropdown for collapsed state" do
|
||||
|
|
@ -514,9 +514,9 @@ defmodule MvWeb.Layouts.SidebarTest do
|
|||
expected_links = [
|
||||
"/members",
|
||||
"/users",
|
||||
"/custom_fields",
|
||||
"/custom_field_values",
|
||||
"/contribution_types",
|
||||
"/contribution_settings",
|
||||
"/membership_fee_settings",
|
||||
"/sign-out"
|
||||
]
|
||||
|
||||
|
|
@ -641,7 +641,7 @@ defmodule MvWeb.Layouts.SidebarTest do
|
|||
|
||||
# Inner_block items rendered
|
||||
assert html =~ ~s(href="/contribution_types")
|
||||
assert html =~ ~s(href="/contribution_settings")
|
||||
assert html =~ ~s(href="/membership_fee_settings")
|
||||
assert html =~ ~s(role="menu")
|
||||
end
|
||||
end
|
||||
|
|
@ -749,7 +749,7 @@ defmodule MvWeb.Layouts.SidebarTest do
|
|||
|
||||
# Drawer overlay label for mobile
|
||||
assert html =~ ~s(for="mobile-drawer")
|
||||
assert html =~ ~s(class="drawer-overlay")
|
||||
assert has_class?(html, "drawer-overlay")
|
||||
assert html =~ ~s(lg:hidden)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue