fix: pr comments
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon 2026-02-12 15:08:40 +01:00
parent e4671e816b
commit 900f322422
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
11 changed files with 161 additions and 80 deletions

View file

@ -93,7 +93,7 @@ defmodule MvWeb.GroupLive.ShowAccessibilityTest do
end
describe "keyboard navigation" do
test "tab navigation works in modal", %{conn: conn} do
test "tab navigation works in inline add member area", %{conn: conn} do
# This test verifies that keyboard navigation is possible
# Actual tab order testing would require more complex setup
group = Fixtures.group_fixture()
@ -107,7 +107,7 @@ defmodule MvWeb.GroupLive.ShowAccessibilityTest do
html = render(view)
# Modal should have focusable elements
# Inline add member area should have focusable elements
assert html =~ ~r/input|button/ ||
html =~ "#member-search-input"
end

View file

@ -1,11 +1,12 @@
defmodule MvWeb.GroupLive.ShowAddMemberTest do
@moduledoc """
Tests for adding members to groups via the Add Member modal.
Tests for adding members to groups via the inline Add Member combobox.
Tests successful add, error handling, and edge cases.
"""
use MvWeb.ConnCase, async: false
import Phoenix.LiveViewTest
import MvWeb.GroupLiveHelpers
use Gettext, backend: MvWeb.Gettext
alias Mv.Membership
@ -28,32 +29,11 @@ defmodule MvWeb.GroupLive.ShowAddMemberTest do
{:ok, view, _html} = live(conn, "/groups/#{group.slug}")
# Open inline input
view
|> element("button", "Add Member")
|> render_click()
open_add_member(view)
search_member(view, "Alice")
select_member(view, member)
add_selected(view)
# Search and select member
view
|> element("#member-search-input")
|> render_focus()
# phx-change is on the form, so we need to trigger it via the form
view
|> element("form[phx-change='search_members']")
|> render_change(%{"member_search" => "Alice"})
# Select member
view
|> element("[data-member-id='#{member.id}']")
|> render_click()
# Click Add button
view
|> element("button[phx-click='add_selected_members']")
|> render_click()
# Verify member appears in group list (no success flash message)
html = render(view)
assert html =~ "Alice"
assert html =~ "Johnson"
@ -198,7 +178,7 @@ defmodule MvWeb.GroupLive.ShowAddMemberTest do
assert new_count == initial_count + 1
end
test "modal closes after successful member addition", %{conn: conn} do
test "inline add member area closes after successful member addition", %{conn: conn} do
system_actor = Mv.Helpers.SystemActor.get_system_actor()
group = Fixtures.group_fixture()
@ -242,6 +222,21 @@ defmodule MvWeb.GroupLive.ShowAddMemberTest do
# Inline input should be closed (Add Member button should be visible again)
refute has_element?(view, "#member-search-input")
end
test "Cancel button closes inline add member area without adding", %{conn: conn} do
group = Fixtures.group_fixture()
{:ok, view, _html} = live(conn, "/groups/#{group.slug}")
open_add_member(view)
assert has_element?(view, "#member-search-input")
assert has_element?(view, "button[phx-click='hide_add_member_input']")
cancel_add_member(view)
refute has_element?(view, "#member-search-input")
assert has_element?(view, "button", "Add Member")
end
end
describe "error handling" do

View file

@ -1,6 +1,6 @@
defmodule MvWeb.GroupLive.ShowAddRemoveMembersTest do
@moduledoc """
UI tests for Add/Remove Member buttons visibility and modal display.
UI tests for Add/Remove Member buttons visibility and inline add member display.
Tests UI rendering and permission-based visibility.
"""

View file

@ -217,7 +217,7 @@ defmodule MvWeb.GroupLive.ShowAuthorizationTest do
end
@tag role: :read_only
test "modal cannot be opened for unauthorized users", %{conn: conn} do
test "inline add member area cannot be opened for unauthorized users", %{conn: conn} do
group = Fixtures.group_fixture()
{:ok, _view, html} = live(conn, "/groups/#{group.slug}")
@ -262,14 +262,14 @@ defmodule MvWeb.GroupLive.ShowAuthorizationTest do
match?({:error, {:live_redirect, %{to: "/groups"}}}, result)
end
@tag :skip
test "non-existent member IDs are handled", %{conn: conn} do
# Future: test add_selected_members with invalid ID (would require pushing event with forged selected_member_ids)
group = Fixtures.group_fixture()
{:ok, _view, _html} = live(conn, "/groups/#{group.slug}")
{:ok, view, _html} = live(conn, "/groups/#{group.slug}")
# Try to add non-existent member (if possible)
# Implementation should handle this gracefully
# This tests error handling for invalid IDs
assert has_element?(view, "button", "Add Member")
end
test "non-existent group IDs are handled", %{conn: conn} do

View file

@ -1,6 +1,6 @@
defmodule MvWeb.GroupLive.ShowMemberSearchTest do
@moduledoc """
UI tests for member search functionality in Add Member modal.
UI tests for member search functionality in inline Add Member combobox.
Tests search behavior and filtering of members already in group.
"""