fix tests
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing

This commit is contained in:
carla 2026-02-26 17:14:47 +01:00
parent e0484a0533
commit 7f15909cc6
4 changed files with 19 additions and 8 deletions

View file

@ -54,6 +54,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
<.table
id="custom_fields_table"
rows={@streams.custom_fields}
row_id={fn {_stream_key, cf} -> "custom_fields-#{cf.id}" end}
row_click={
fn {_id, custom_field} ->
JS.push("edit_custom_field", value: %{id: custom_field.id}, target: @myself)

View file

@ -307,6 +307,7 @@ defmodule MvWeb.RoleLive.Show do
type="button"
variant="danger"
phx-click={JS.push("delete", value: %{id: @role.id})}
data-testid="role-delete-confirm"
aria-label={gettext("Delete role")}
>
{gettext("Delete")}

View file

@ -46,15 +46,19 @@ defmodule MvWeb.CustomFieldLive.DeletionTest do
%{conn: conn, user: user_with_role}
end
# Delete is in the edit form (FormComponent); open form by clicking the name cell (unique td with phx-click)
# Delete is in the edit form (FormComponent). First row click opens form (overview) or switches
# to edit-mode (new component shows table). If delete button is visible, click it; else click row
# again to open the form, then click delete.
defp open_delete_modal(view, custom_field) do
view
|> element("tr#custom_fields-#{custom_field.id} td", custom_field.name)
|> render_click()
row_selector = "tr#custom_fields-#{custom_field.id} td"
view |> element(row_selector, custom_field.name) |> render_click()
view
|> element("[data-testid=custom-field-delete]")
|> render_click()
if has_element?(view, "[data-testid=custom-field-delete]") do
view |> element("[data-testid=custom-field-delete]") |> render_click()
else
view |> element(row_selector, custom_field.name) |> render_click()
view |> element("[data-testid=custom-field-delete]") |> render_click()
end
end
describe "delete button and modal" do

View file

@ -386,11 +386,16 @@ defmodule MvWeb.RoleLiveTest do
{:ok, view, _html} = live(conn, "/admin/roles/#{role.id}")
# Delete from Danger zone on show page
# Open delete modal from Danger zone
view
|> element("[data-testid=role-delete]")
|> render_click()
# Confirm deletion in modal
view
|> element("[data-testid=role-delete-confirm]")
|> render_click()
assert_redirect(view, "/admin/roles")
# Verify deletion by checking database