test: restore removed tests including optimizations

This commit is contained in:
Simon 2026-01-29 12:59:06 +01:00
parent 25da6a6820
commit 0b29fbbd21
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
4 changed files with 403 additions and 10 deletions

View file

@ -23,12 +23,14 @@ defmodule MvWeb.UserLive.ShowTest do
end
describe "mount and display" do
@tag :slow
test "mounts successfully with valid user ID", %{conn: conn, user: user} do
@tag :ui
test "mounts successfully and displays user information", %{conn: conn, user: user} do
conn = conn_with_oidc_user(conn)
{:ok, _view, html} = live(conn, ~p"/users/#{user.id}")
# Basic display
assert html =~ to_string(user.email)
assert html =~ gettext("Email")
end
test "displays password authentication status when enabled", %{conn: conn} do
@ -96,6 +98,47 @@ defmodule MvWeb.UserLive.ShowTest do
end
end
describe "navigation" do
@tag :ui
test "navigation buttons work correctly", %{conn: conn, user: user} do
conn = conn_with_oidc_user(conn)
{:ok, view, _html} = live(conn, ~p"/users/#{user.id}")
# Back button navigates to user list
assert {:error, {:live_redirect, %{to: to}}} =
view
|> element(
"a[aria-label='#{gettext("Back to users list")}'], button[aria-label='#{gettext("Back to users list")}']"
)
|> render_click()
assert to == "/users"
# Edit button navigates to edit form
{:ok, view, _html} = live(conn, ~p"/users/#{user.id}")
assert {:error, {:live_redirect, %{to: to}}} =
view
|> element(
"a[href='/users/#{user.id}/edit?return_to=show'], button[href='/users/#{user.id}/edit?return_to=show']"
)
|> render_click()
assert to == "/users/#{user.id}/edit?return_to=show"
end
end
describe "page title" do
@tag :ui
test "sets correct page title", %{conn: conn, user: user} do
conn = conn_with_oidc_user(conn)
{:ok, _view, html} = live(conn, ~p"/users/#{user.id}")
# Check that page title is set (might be in title tag or header)
assert html =~ gettext("Show User") || html =~ to_string(user.email)
end
end
describe "error handling" do
test "raises exception for invalid user ID", %{conn: conn} do
invalid_id = Ecto.UUID.generate()