chore: update gettext files and test cleanup
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Update translation files after code changes and remove unused debug logging code from tests.
This commit is contained in:
parent
fe8b4a65dd
commit
586985f7f0
4 changed files with 82 additions and 41 deletions
|
|
@ -208,10 +208,11 @@ defmodule MvWeb.RoleLiveTest do
|
|||
test "returns 404 for invalid role ID", %{conn: conn} do
|
||||
invalid_id = Ecto.UUID.generate()
|
||||
|
||||
# Ash.get! raises Ash.Error.Invalid with Query.NotFound inside
|
||||
assert_raise Ash.Error.Invalid, fn ->
|
||||
live(conn, "/admin/roles/#{invalid_id}")
|
||||
end
|
||||
# Should redirect to index with error message
|
||||
# redirect in mount returns {:error, {:redirect, ...}}
|
||||
result = live(conn, "/admin/roles/#{invalid_id}")
|
||||
|
||||
assert match?({:error, {:redirect, %{to: "/admin/roles"}}}, result)
|
||||
end
|
||||
|
||||
test "shows system role badge if is_system_role is true", %{conn: conn} do
|
||||
|
|
@ -269,21 +270,20 @@ defmodule MvWeb.RoleLiveTest do
|
|||
test "shows error with invalid permission_set_name", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, "/admin/roles/new")
|
||||
|
||||
# Use a valid permission set name but test validation differently
|
||||
# The select dropdown prevents invalid values, so we test via form validation
|
||||
# Try to submit with empty permission_set_name (invalid)
|
||||
attrs = %{
|
||||
"name" => "New Role",
|
||||
"description" => "New description",
|
||||
"permission_set_name" => "read_only"
|
||||
"permission_set_name" => ""
|
||||
}
|
||||
|
||||
# Submit with valid data first
|
||||
view
|
||||
|> form("#role-form", role: attrs)
|
||||
|> render_submit()
|
||||
|
||||
# Should succeed - validation happens on backend
|
||||
assert_redirect(view, "/admin/roles")
|
||||
# Should show validation error
|
||||
html = render(view)
|
||||
assert html =~ "error" || html =~ "required" || html =~ "Permission Set"
|
||||
end
|
||||
|
||||
test "shows flash message after successful creation", %{conn: conn} do
|
||||
|
|
@ -317,6 +317,16 @@ defmodule MvWeb.RoleLiveTest do
|
|||
assert html =~ role.name
|
||||
end
|
||||
|
||||
test "returns 404 for invalid role ID in edit", %{conn: conn} do
|
||||
invalid_id = Ecto.UUID.generate()
|
||||
|
||||
# Should redirect to index with error message
|
||||
# redirect in mount returns {:error, {:redirect, ...}}
|
||||
result = live(conn, "/admin/roles/#{invalid_id}/edit")
|
||||
|
||||
assert match?({:error, {:redirect, %{to: "/admin/roles"}}}, result)
|
||||
end
|
||||
|
||||
test "updates role name", %{conn: conn, role: role} do
|
||||
{:ok, view, _html} = live(conn, "/admin/roles/#{role.id}/edit?return_to=show")
|
||||
|
||||
|
|
@ -400,12 +410,18 @@ defmodule MvWeb.RoleLiveTest do
|
|||
|> Ash.Changeset.force_change_attribute(:is_system_role, true)
|
||||
|> Ash.create!()
|
||||
|
||||
{:ok, _view, html} = live(conn, "/admin/roles")
|
||||
{:ok, view, html} = live(conn, "/admin/roles")
|
||||
|
||||
# System role delete button should be disabled
|
||||
assert html =~ "disabled" || html =~ "cursor-not-allowed" ||
|
||||
html =~ "System roles cannot be deleted"
|
||||
|
||||
# Try to delete via event (backend check)
|
||||
render_click(view, "delete", %{"id" => system_role.id})
|
||||
|
||||
# Should show error message
|
||||
assert render(view) =~ "System roles cannot be deleted"
|
||||
|
||||
# Role should still exist
|
||||
{:ok, _role} = Authorization.get_role(system_role.id)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue