style: consistent back button and some translations
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
91cf7cca6a
commit
0f12befd11
26 changed files with 747 additions and 710 deletions
|
|
@ -46,6 +46,17 @@ 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)
|
||||
defp open_delete_modal(view, custom_field) do
|
||||
view
|
||||
|> element("tr#custom_fields-#{custom_field.id} td", custom_field.name)
|
||||
|> render_click()
|
||||
|
||||
view
|
||||
|> element("[data-testid=custom-field-delete]")
|
||||
|> render_click()
|
||||
end
|
||||
|
||||
describe "delete button and modal" do
|
||||
test "opens modal with correct member count when delete is clicked", %{conn: conn} do
|
||||
{:ok, member} = create_member()
|
||||
|
|
@ -55,11 +66,7 @@ defmodule MvWeb.CustomFieldLive.DeletionTest do
|
|||
create_custom_field_value(member, custom_field, "test")
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/datafields")
|
||||
|
||||
# Click delete button - find the delete link within the component
|
||||
view
|
||||
|> element("#custom-fields-component a", "Delete")
|
||||
|> render_click()
|
||||
open_delete_modal(view, custom_field)
|
||||
|
||||
# Modal should be visible
|
||||
assert has_element?(view, "#delete-custom-field-modal")
|
||||
|
|
@ -81,23 +88,17 @@ defmodule MvWeb.CustomFieldLive.DeletionTest do
|
|||
create_custom_field_value(member2, custom_field, "test2")
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/datafields")
|
||||
|
||||
view
|
||||
|> element("#custom-fields-component a", "Delete")
|
||||
|> render_click()
|
||||
open_delete_modal(view, custom_field)
|
||||
|
||||
# Should show plural form
|
||||
assert render(view) =~ "2 members have values assigned for this custom field"
|
||||
end
|
||||
|
||||
test "shows 0 members for custom field without values", %{conn: conn} do
|
||||
{:ok, _custom_field} = create_custom_field("test_field", :string)
|
||||
{:ok, custom_field} = create_custom_field("test_field", :string)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/datafields")
|
||||
|
||||
view
|
||||
|> element("#custom-fields-component a", "Delete")
|
||||
|> render_click()
|
||||
open_delete_modal(view, custom_field)
|
||||
|
||||
# Should show 0 members
|
||||
assert render(view) =~ "0 members have values assigned for this custom field"
|
||||
|
|
@ -109,10 +110,7 @@ defmodule MvWeb.CustomFieldLive.DeletionTest do
|
|||
{:ok, custom_field} = create_custom_field("test_field", :string)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/datafields")
|
||||
|
||||
view
|
||||
|> element("#custom-fields-component a", "Delete")
|
||||
|> render_click()
|
||||
open_delete_modal(view, custom_field)
|
||||
|
||||
# Type in slug input - use element to find the form with phx-target
|
||||
view
|
||||
|
|
@ -124,13 +122,10 @@ defmodule MvWeb.CustomFieldLive.DeletionTest do
|
|||
end
|
||||
|
||||
test "delete button is disabled when slug doesn't match", %{conn: conn} do
|
||||
{:ok, _custom_field} = create_custom_field("test_field", :string)
|
||||
{:ok, custom_field} = create_custom_field("test_field", :string)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/datafields")
|
||||
|
||||
view
|
||||
|> element("#custom-fields-component a", "Delete")
|
||||
|> render_click()
|
||||
open_delete_modal(view, custom_field)
|
||||
|
||||
# Type wrong slug - use element to find the form with phx-target
|
||||
view
|
||||
|
|
@ -149,11 +144,7 @@ defmodule MvWeb.CustomFieldLive.DeletionTest do
|
|||
{:ok, custom_field_value} = create_custom_field_value(member, custom_field, "test")
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/datafields")
|
||||
|
||||
# Open modal
|
||||
view
|
||||
|> element("#custom-fields-component a", "Delete")
|
||||
|> render_click()
|
||||
open_delete_modal(view, custom_field)
|
||||
|
||||
# Enter correct slug - use element to find the form with phx-target
|
||||
view
|
||||
|
|
@ -162,7 +153,7 @@ defmodule MvWeb.CustomFieldLive.DeletionTest do
|
|||
|
||||
# Click confirm
|
||||
view
|
||||
|> element("#delete-custom-field-modal button", "Delete Custom Field and All Values")
|
||||
|> element("#delete-custom-field-modal button", "Delete Datafields and All Values")
|
||||
|> render_click()
|
||||
|
||||
# Should show success message
|
||||
|
|
@ -186,10 +177,7 @@ defmodule MvWeb.CustomFieldLive.DeletionTest do
|
|||
{:ok, custom_field} = create_custom_field("test_field", :string)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/datafields")
|
||||
|
||||
view
|
||||
|> element("#custom-fields-component a", "Delete")
|
||||
|> render_click()
|
||||
open_delete_modal(view, custom_field)
|
||||
|
||||
# Enter wrong slug - use element to find the form with phx-target
|
||||
view
|
||||
|
|
@ -210,10 +198,7 @@ defmodule MvWeb.CustomFieldLive.DeletionTest do
|
|||
{:ok, custom_field} = create_custom_field("test_field", :string)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/datafields")
|
||||
|
||||
view
|
||||
|> element("#custom-fields-component a", "Delete")
|
||||
|> render_click()
|
||||
open_delete_modal(view, custom_field)
|
||||
|
||||
# Modal should be visible
|
||||
assert has_element?(view, "#delete-custom-field-modal")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue