feat(member): show join_description as a tooltip on custom-field labels

This commit is contained in:
Simon 2026-06-03 12:22:58 +02:00
parent ee5ccbf7e9
commit df271055a8
5 changed files with 85 additions and 9 deletions

View file

@ -220,4 +220,59 @@ defmodule MvWeb.MemberLive.ShowTest do
assert html =~ "private@example.com"
end
end
describe "custom field join_description tooltip" do
test "shows a tooltip on the custom field label when join_description is set", %{
conn: conn,
member: member,
actor: actor
} do
{:ok, custom_field} =
CustomField
|> Ash.Changeset.for_create(:create, %{
name: "DSGVO",
value_type: :boolean,
join_description: "Accept the privacy policy"
})
|> Ash.create(actor: actor)
conn = conn_with_oidc_user(conn)
{:ok, view, html} = live(conn, ~p"/members/#{member}")
assert has_element?(view, "[data-tip*='Accept the privacy policy']")
# Tooltip content conveys both the join-form context and the description text.
assert has_element?(view, "[data-tip*='Join form:']")
assert html =~ "Accept the privacy policy"
assert html =~ custom_field.name
# The info-icon wrapper must center the icon vertically with the label,
# matching the flex-items-center idiom used elsewhere (e.g. custom field edit),
# so the icon is flush with the label text and not offset downward.
assert has_element?(
view,
"[data-tip*='Accept the privacy policy'].inline-flex.items-center"
)
end
test "shows no tooltip on the custom field label when join_description is nil", %{
conn: conn,
member: member,
actor: actor
} do
{:ok, _custom_field} =
CustomField
|> Ash.Changeset.for_create(:create, %{
name: "Plain field",
value_type: :string
})
|> Ash.create(actor: actor)
conn = conn_with_oidc_user(conn)
{:ok, view, _html} = live(conn, ~p"/members/#{member}")
assert has_element?(view, "dt", "Plain field")
# The info-icon tooltip beside the label is only rendered when join_description is set.
refute has_element?(view, "[data-testid='join-description-tooltip']")
end
end
end