fix: add missing user for view and fix test
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
d10fcc3da1
commit
1d334c7da1
2 changed files with 44 additions and 13 deletions
|
|
@ -4,7 +4,7 @@ defmodule MvWeb.UserLive.Show do
|
||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<Layouts.app flash={@flash}>
|
<Layouts.app flash={@flash} current_user={@current_user}>
|
||||||
<.header>
|
<.header>
|
||||||
{gettext("User")} {@user.email}
|
{gettext("User")} {@user.email}
|
||||||
<:subtitle>{gettext("This is a user record from your database.")}</:subtitle>
|
<:subtitle>{gettext("This is a user record from your database.")}</:subtitle>
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,6 @@ defmodule MvWeb.ProfileNavigationTest do
|
||||||
assert_redirected(view, "/users/#{user.id}")
|
assert_redirected(view, "/users/#{user.id}")
|
||||||
end
|
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
|
test "profile navigation shows correct user data", %{conn: conn} do
|
||||||
# Setup: Create and login a user
|
# Setup: Create and login a user
|
||||||
user = create_test_user(%{email: "test@example.com"})
|
user = create_test_user(%{email: "test@example.com"})
|
||||||
|
|
@ -148,4 +136,47 @@ defmodule MvWeb.ProfileNavigationTest do
|
||||||
assert_redirected(view_oidc, "/users/#{oidc_user.id}")
|
assert_redirected(view_oidc, "/users/#{oidc_user.id}")
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue