formating
This commit is contained in:
parent
41e3a52482
commit
bb362e1636
3 changed files with 78 additions and 28 deletions
|
|
@ -17,7 +17,16 @@ defmodule MvWeb.Components.SortHeaderComponentTest do
|
|||
conn = conn_with_oidc_user(conn)
|
||||
{:ok, view, _html} = live(conn, "/members")
|
||||
|
||||
sortable_fields = [:first_name, :email, :street, :house_number, :postal_code, :city, :phone_number, :join_date]
|
||||
sortable_fields = [
|
||||
:first_name,
|
||||
:email,
|
||||
:street,
|
||||
:house_number,
|
||||
:postal_code,
|
||||
:city,
|
||||
:phone_number,
|
||||
:join_date
|
||||
]
|
||||
|
||||
for field <- sortable_fields do
|
||||
assert has_element?(view, "button[phx-value-field='#{field}']")
|
||||
|
|
@ -65,7 +74,8 @@ defmodule MvWeb.Components.SortHeaderComponentTest do
|
|||
|
||||
# Count occurrences to ensure only one ascending icon
|
||||
up_count = html |> String.split("hero-chevron-up ") |> length() |> Kernel.-(1)
|
||||
assert up_count == 1 # Should be exactly one chevron-up icon
|
||||
# Should be exactly one chevron-up icon
|
||||
assert up_count == 1
|
||||
end
|
||||
|
||||
test "shows descending icon for specific field when sorted descending", %{conn: conn} do
|
||||
|
|
@ -74,7 +84,8 @@ defmodule MvWeb.Components.SortHeaderComponentTest do
|
|||
|
||||
# Count occurrences to ensure only one descending icon
|
||||
down_count = html |> String.split("hero-chevron-down ") |> length() |> Kernel.-(1)
|
||||
assert down_count == 1 # Should be exactly one chevron-down icon
|
||||
# Should be exactly one chevron-down icon
|
||||
assert down_count == 1
|
||||
end
|
||||
|
||||
test "multiple fields can have different icon states", %{conn: conn} do
|
||||
|
|
@ -146,7 +157,9 @@ defmodule MvWeb.Components.SortHeaderComponentTest do
|
|||
{:ok, _view, html_neutral} = live(conn, "/members")
|
||||
|
||||
# Count neutral icons (should be 7 - one for each field)
|
||||
neutral_count = html_neutral |> String.split("hero-chevron-up-down") |> length() |> Kernel.-(1)
|
||||
neutral_count =
|
||||
html_neutral |> String.split("hero-chevron-up-down") |> length() |> Kernel.-(1)
|
||||
|
||||
assert neutral_count == 7
|
||||
|
||||
# Count active icons (should be 1)
|
||||
|
|
@ -209,7 +222,12 @@ defmodule MvWeb.Components.SortHeaderComponentTest do
|
|||
|
||||
# Test aria-labels for different fields
|
||||
assert has_element?(view, "button[phx-value-field='email'][aria-label='descending']")
|
||||
assert has_element?(view, "button[phx-value-field='first_name'][aria-label='Click to sort']")
|
||||
|
||||
assert has_element?(
|
||||
view,
|
||||
"button[phx-value-field='first_name'][aria-label='Click to sort']"
|
||||
)
|
||||
|
||||
assert has_element?(view, "button[phx-value-field='city'][aria-label='Click to sort']")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -115,7 +115,15 @@ defmodule MvWeb.MemberLive.IndexTest do
|
|||
# default ascending sorting with first name
|
||||
assert has_element?(view, "[data-testid='first_name'][aria-label='ascending']")
|
||||
|
||||
sortable_fields = [:email, :street, :house_number, :postal_code, :city, :phone_number, :join_date]
|
||||
sortable_fields = [
|
||||
:email,
|
||||
:street,
|
||||
:house_number,
|
||||
:postal_code,
|
||||
:city,
|
||||
:phone_number,
|
||||
:join_date
|
||||
]
|
||||
|
||||
for field <- sortable_fields do
|
||||
view
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue