test: adapt tests to reflect implementation details
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon 2026-01-27 23:40:12 +01:00
parent 5e0b6580ae
commit 9991291b2f
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
7 changed files with 98 additions and 71 deletions

View file

@ -49,7 +49,7 @@ defmodule MvWeb.GroupLive.ShowTest do
{:ok, _view, html} = live(conn, "/groups/#{group.slug}")
# Member count should be displayed (might be 0 or more)
assert html =~ "0" || html =~ gettext("Members") || html =~ "member"
assert html =~ "0" or html =~ gettext("Members") or html =~ "member" or html =~ "Mitglied"
end
test "displays list of members in group", %{conn: conn} do
@ -69,8 +69,8 @@ defmodule MvWeb.GroupLive.ShowTest do
{:ok, _view, html} = live(conn, "/groups/#{group.slug}")
assert html =~ "Alice" || html =~ "Smith"
assert html =~ "Bob" || html =~ "Jones"
assert html =~ "Alice" or html =~ "Smith"
assert html =~ "Bob" or html =~ "Jones"
end
test "displays edit button for admin users", %{conn: conn} do
@ -78,7 +78,7 @@ defmodule MvWeb.GroupLive.ShowTest do
{:ok, _view, html} = live(conn, "/groups/#{group.slug}")
assert html =~ gettext("Edit") || html =~ "edit"
assert html =~ gettext("Edit") or html =~ "edit" or html =~ "Bearbeiten"
end
test "displays delete button for admin users", %{conn: conn} do
@ -86,7 +86,7 @@ defmodule MvWeb.GroupLive.ShowTest do
{:ok, _view, html} = live(conn, "/groups/#{group.slug}")
assert html =~ gettext("Delete") || html =~ "delete"
assert html =~ gettext("Delete") or html =~ "delete" or html =~ "Löschen"
end
end
@ -98,7 +98,7 @@ defmodule MvWeb.GroupLive.ShowTest do
assert html =~ "Board Members"
# Verify slug is in URL
assert html =~ group.slug || html =~ "board-members"
assert html =~ group.slug or html =~ "board-members"
end
test "group is found by slug via unique_slug identity", %{conn: conn} do
@ -147,7 +147,8 @@ defmodule MvWeb.GroupLive.ShowTest do
{:ok, _view, html} = live(conn, "/groups/#{group.slug}")
assert html =~ "0" || html =~ gettext("No members") || html =~ "empty"
assert html =~ "0" or html =~ gettext("No members") or html =~ "empty" or
html =~ "Keine Mitglieder"
end
test "handles group without description correctly", %{conn: conn} do
@ -165,7 +166,7 @@ defmodule MvWeb.GroupLive.ShowTest do
{:ok, _view, html} = live(conn, "/groups/#{group.slug}")
assert html =~ "Test-Group-Name" || html =~ group.name
assert html =~ "Test-Group-Name" or html =~ group.name
end
end
@ -180,7 +181,7 @@ defmodule MvWeb.GroupLive.ShowTest do
assert html =~ group.name
# Should NOT see edit/delete buttons
refute html =~ gettext("Edit") || html =~ gettext("Delete")
refute html =~ gettext("Edit") or html =~ gettext("Delete")
end
@tag role: :unauthenticated
@ -189,8 +190,8 @@ defmodule MvWeb.GroupLive.ShowTest do
result = live(conn, "/groups/#{group.slug}")
assert match?({:error, {:redirect, %{to: "/auth/sign_in"}}}, result) ||
match?({:error, {:live_redirect, %{to: "/auth/sign_in"}}}, result)
assert match?({:error, {:redirect, %{to: "/sign-in"}}}, result) ||
match?({:error, {:live_redirect, %{to: "/sign-in"}}}, result)
end
test "slug injection attempts are prevented", %{conn: conn} do
@ -238,7 +239,7 @@ defmodule MvWeb.GroupLive.ShowTest do
# All members should be displayed
Enum.each(members, fn member ->
assert html =~ member.first_name || html =~ member.last_name
assert html =~ member.first_name or html =~ member.last_name
end)
end
@ -260,7 +261,9 @@ defmodule MvWeb.GroupLive.ShowTest do
assert {:error, {:live_redirect, %{to: to}}} =
view
|> element("a[aria-label*='Back'], button[aria-label*='Back']")
|> element(
"a[aria-label*='Back'], button[aria-label*='Back'], a[aria-label*='groups list'], button[aria-label*='groups list']"
)
|> render_click()
assert to == "/groups"
@ -271,9 +274,11 @@ defmodule MvWeb.GroupLive.ShowTest do
{:ok, view, _html} = live(conn, "/groups/#{group.slug}")
# Button with navigate is rendered as <a> tag via <.link>
# Use element with text content to find the link
assert {:error, {:live_redirect, %{to: to}}} =
view
|> element("a[href*='edit'], button[href*='edit']")
|> element("a", gettext("Edit"))
|> render_click()
assert to == "/groups/#{group.slug}/edit"