fix: add missing user for view and fix test
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Simon 2025-09-29 16:59:35 +02:00
parent d10fcc3da1
commit 1d334c7da1
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
2 changed files with 44 additions and 13 deletions

View file

@ -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