Tests: data-testid selectors, scoped delete, sidebar testid
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing

Member/User auth tests use data-testid and #row-id selectors.
Sidebar auth tests assert on data-testid=sidebar-administration.
Sidebar test expects data-testid in expanded-menu-group markup.
This commit is contained in:
Moritz 2026-02-03 17:16:15 +01:00
parent ee6bfbacbb
commit cbc9376b7b
4 changed files with 46 additions and 43 deletions

View file

@ -8,19 +8,16 @@ defmodule MvWeb.UserLiveAuthorizationTest do
alias Mv.Fixtures
@new_user_text "New User"
@edit_user_text "Edit User"
describe "User Index - Admin" do
@tag role: :admin
test "sees New User, Edit and Delete buttons", %{conn: conn} do
user = Fixtures.user_with_role_fixture("admin")
{:ok, view, html} = live(conn, "/users")
{:ok, view, _html} = live(conn, "/users")
assert html =~ @new_user_text
assert has_element?(view, "a[href=\"/users/#{user.id}/edit\"]")
assert has_element?(view, "a[phx-click*='delete']")
assert has_element?(view, "[data-testid=user-new]")
assert has_element?(view, "#row-#{user.id} [data-testid=user-edit]")
assert has_element?(view, "#row-#{user.id} [data-testid=user-delete]")
end
end
@ -47,25 +44,25 @@ defmodule MvWeb.UserLiveAuthorizationTest do
describe "User Show - own profile" do
@tag role: :member
test "member sees Edit button on own profile", %{conn: conn, current_user: user} do
{:ok, _view, html} = live(conn, "/users/#{user.id}")
{:ok, view, _html} = live(conn, "/users/#{user.id}")
assert html =~ @edit_user_text
assert has_element?(view, "[data-testid=user-edit]")
end
@tag role: :read_only
test "read_only sees Edit button on own profile", %{conn: conn, current_user: user} do
{:ok, _view, html} = live(conn, "/users/#{user.id}")
{:ok, view, _html} = live(conn, "/users/#{user.id}")
assert html =~ @edit_user_text
assert has_element?(view, "[data-testid=user-edit]")
end
@tag role: :admin
test "admin sees Edit button on user show", %{conn: conn} do
user = Fixtures.user_with_role_fixture("read_only")
{:ok, _view, html} = live(conn, "/users/#{user.id}")
{:ok, view, _html} = live(conn, "/users/#{user.id}")
assert html =~ @edit_user_text
assert has_element?(view, "[data-testid=user-edit]")
end
end