This commit is contained in:
parent
33d4fa66c8
commit
06574a932d
6 changed files with 201 additions and 145 deletions
|
|
@ -65,12 +65,12 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
# Should show ascending indicator (up arrow)
|
||||
assert html =~ "hero-chevron-up"
|
||||
assert html =~ ~s(aria-sort="ascending")
|
||||
|
||||
|
||||
# Test actual sort order: alpha should appear before mike, mike before zulu
|
||||
alpha_pos = html |> :binary.match("alpha@example.com") |> elem(0)
|
||||
mike_pos = html |> :binary.match("mike@example.com") |> elem(0)
|
||||
zulu_pos = html |> :binary.match("zulu@example.com") |> elem(0)
|
||||
|
||||
|
||||
assert alpha_pos < mike_pos, "alpha@example.com should appear before mike@example.com"
|
||||
assert mike_pos < zulu_pos, "mike@example.com should appear before zulu@example.com"
|
||||
end
|
||||
|
|
@ -78,21 +78,24 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
test "can sort email descending by clicking sort button", %{conn: conn} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
{:ok, view, _html} = live(conn, "/users")
|
||||
|
||||
|
||||
# Click on email sort button and get rendered result
|
||||
html = view |> element("button[phx-value-field='email']") |> render_click()
|
||||
|
||||
# Should now show descending indicator (down arrow)
|
||||
assert html =~ "hero-chevron-down"
|
||||
assert html =~ ~s(aria-sort="descending")
|
||||
|
||||
|
||||
# Test actual sort order reversed: zulu should now appear before mike, mike before alpha
|
||||
alpha_pos = html |> :binary.match("alpha@example.com") |> elem(0)
|
||||
mike_pos = html |> :binary.match("mike@example.com") |> elem(0)
|
||||
zulu_pos = html |> :binary.match("zulu@example.com") |> elem(0)
|
||||
|
||||
assert zulu_pos < mike_pos, "zulu@example.com should appear before mike@example.com when sorted desc"
|
||||
assert mike_pos < alpha_pos, "mike@example.com should appear before alpha@example.com when sorted desc"
|
||||
|
||||
assert zulu_pos < mike_pos,
|
||||
"zulu@example.com should appear before mike@example.com when sorted desc"
|
||||
|
||||
assert mike_pos < alpha_pos,
|
||||
"mike@example.com should appear before alpha@example.com when sorted desc"
|
||||
end
|
||||
|
||||
test "toggles back to ascending when clicking sort button twice", %{conn: conn} do
|
||||
|
|
@ -106,12 +109,12 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
# Should be back to ascending
|
||||
assert html =~ "hero-chevron-up"
|
||||
assert html =~ ~s(aria-sort="ascending")
|
||||
|
||||
|
||||
# Should be back to original ascending order
|
||||
alpha_pos = html |> :binary.match("alpha@example.com") |> elem(0)
|
||||
mike_pos = html |> :binary.match("mike@example.com") |> elem(0)
|
||||
zulu_pos = html |> :binary.match("zulu@example.com") |> elem(0)
|
||||
|
||||
|
||||
assert alpha_pos < mike_pos, "Should be back to ascending: alpha before mike"
|
||||
assert mike_pos < zulu_pos, "Should be back to ascending: mike before zulu"
|
||||
end
|
||||
|
|
@ -162,16 +165,20 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
# Initially, individual checkboxes should exist but not be checked
|
||||
assert view |> element("input[type='checkbox'][name='#{user1.id}']") |> has_element?()
|
||||
assert view |> element("input[type='checkbox'][name='#{user2.id}']") |> has_element?()
|
||||
|
||||
|
||||
# Initially, select_all should not be checked (since no individual items are selected)
|
||||
refute view |> element("input[type='checkbox'][name='select_all'][checked]") |> has_element?()
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='select_all'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
# Select first user checkbox
|
||||
html = view |> element("input[type='checkbox'][name='#{user1.id}']") |> render_click()
|
||||
|
||||
# The select_all checkbox should still not be checked (not all users selected)
|
||||
refute view |> element("input[type='checkbox'][name='select_all'][checked]") |> has_element?()
|
||||
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='select_all'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
# Page should still function normally
|
||||
assert html =~ "Email"
|
||||
assert html =~ to_string(user1.email)
|
||||
|
|
@ -186,10 +193,12 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
|
||||
# Then deselect user
|
||||
html = view |> element("input[type='checkbox'][name='#{user1.id}']") |> render_click()
|
||||
|
||||
|
||||
# Select all should not be checked after deselecting individual user
|
||||
refute view |> element("input[type='checkbox'][name='select_all'][checked]") |> has_element?()
|
||||
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='select_all'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
# Page should still function normally
|
||||
assert html =~ "Email"
|
||||
assert html =~ to_string(user1.email)
|
||||
|
|
@ -200,16 +209,26 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
{:ok, view, _html} = live(conn, "/users")
|
||||
|
||||
# Initially no checkboxes should be checked
|
||||
refute view |> element("input[type='checkbox'][name='select_all'][checked]") |> has_element?()
|
||||
refute view |> element("input[type='checkbox'][name='#{user1.id}'][checked]") |> has_element?()
|
||||
refute view |> element("input[type='checkbox'][name='#{user2.id}'][checked]") |> has_element?()
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='select_all'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='#{user1.id}'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='#{user2.id}'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
# Click select all
|
||||
html = view |> element("input[type='checkbox'][name='select_all']") |> render_click()
|
||||
|
||||
# After selecting all, the select_all checkbox should be checked
|
||||
assert view |> element("input[type='checkbox'][name='select_all'][checked]") |> has_element?()
|
||||
|
||||
assert view
|
||||
|> element("input[type='checkbox'][name='select_all'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
# Page should still function normally and show all users
|
||||
assert html =~ "Email"
|
||||
assert html =~ to_string(user1.email)
|
||||
|
|
@ -222,35 +241,52 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
|
||||
# Select all first
|
||||
view |> element("input[type='checkbox'][name='select_all']") |> render_click()
|
||||
|
||||
|
||||
# Verify that select_all is checked
|
||||
assert view |> element("input[type='checkbox'][name='select_all'][checked]") |> has_element?()
|
||||
assert view
|
||||
|> element("input[type='checkbox'][name='select_all'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
# Then deselect all
|
||||
html = view |> element("input[type='checkbox'][name='select_all']") |> render_click()
|
||||
|
||||
|
||||
# After deselecting all, no checkboxes should be checked
|
||||
refute view |> element("input[type='checkbox'][name='select_all'][checked]") |> has_element?()
|
||||
refute view |> element("input[type='checkbox'][name='#{user1.id}'][checked]") |> has_element?()
|
||||
refute view |> element("input[type='checkbox'][name='#{user2.id}'][checked]") |> has_element?()
|
||||
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='select_all'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='#{user1.id}'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='#{user2.id}'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
# Page should still function normally
|
||||
assert html =~ "Email"
|
||||
assert html =~ to_string(user1.email)
|
||||
assert html =~ to_string(user2.email)
|
||||
end
|
||||
|
||||
test "select all automatically checks when all individual users are selected", %{conn: conn, users: [user1, user2]} do
|
||||
test "select all automatically checks when all individual users are selected", %{
|
||||
conn: conn,
|
||||
users: [user1, user2]
|
||||
} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
{:ok, view, _html} = live(conn, "/users")
|
||||
|
||||
# Initially nothing should be checked
|
||||
refute view |> element("input[type='checkbox'][name='select_all'][checked]") |> has_element?()
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='select_all'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
# Select first user
|
||||
view |> element("input[type='checkbox'][name='#{user1.id}']") |> render_click()
|
||||
# Select all should still not be checked (only 1 of 2+ users selected)
|
||||
refute view |> element("input[type='checkbox'][name='select_all'][checked]") |> has_element?()
|
||||
refute view
|
||||
|> element("input[type='checkbox'][name='select_all'][checked]")
|
||||
|> has_element?()
|
||||
|
||||
# Select second user
|
||||
html = view |> element("input[type='checkbox'][name='#{user2.id}']") |> render_click()
|
||||
|
|
@ -278,7 +314,8 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
|
||||
# The page should still render (basic functionality test)
|
||||
html = render(view)
|
||||
assert html =~ "Email" # Table header should still be there
|
||||
# Table header should still be there
|
||||
assert html =~ "Email"
|
||||
end
|
||||
|
||||
test "shows delete confirmation", %{conn: conn} do
|
||||
|
|
@ -336,7 +373,8 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
|
||||
# Note: English translations might be empty strings by default
|
||||
# This test would verify the structure is there
|
||||
assert html =~ ~s(aria-label=) # Checking that aria-label attributes exist
|
||||
# Checking that aria-label attributes exist
|
||||
assert html =~ ~s(aria-label=)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -371,5 +409,4 @@ defmodule MvWeb.UserLive.IndexTest do
|
|||
assert html =~ long_email
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue