test: add tests for custom field labels
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
3bfb7dd09c
commit
a6f6f402af
2 changed files with 99 additions and 0 deletions
71
test/mv_web/live/join_request_live/show_test.exs
Normal file
71
test/mv_web/live/join_request_live/show_test.exs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
defmodule MvWeb.JoinRequestLive.ShowTest do
|
||||
@moduledoc """
|
||||
Tests for join request detail view label rendering.
|
||||
|
||||
Focus: applicant data labels for custom fields should use custom field names,
|
||||
not raw UUIDs.
|
||||
"""
|
||||
use MvWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
|
||||
alias Mv.Fixtures
|
||||
alias Mv.Membership
|
||||
|
||||
setup do
|
||||
{:ok, settings} = Membership.get_settings()
|
||||
|
||||
saved = %{
|
||||
join_form_enabled: settings.join_form_enabled,
|
||||
join_form_field_ids: settings.join_form_field_ids,
|
||||
join_form_field_required: settings.join_form_field_required
|
||||
}
|
||||
|
||||
on_exit(fn ->
|
||||
{:ok, current_settings} = Membership.get_settings()
|
||||
|
||||
Membership.update_settings(current_settings, %{
|
||||
join_form_enabled: saved.join_form_enabled,
|
||||
join_form_field_ids: saved.join_form_field_ids || [],
|
||||
join_form_field_required: saved.join_form_field_required || %{}
|
||||
})
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
describe "custom field labels in applicant data" do
|
||||
@tag role: :normal_user
|
||||
test "renders custom field name instead of custom field UUID", %{conn: conn} do
|
||||
system_actor = Mv.Helpers.SystemActor.get_system_actor()
|
||||
{:ok, settings} = Membership.get_settings()
|
||||
|
||||
{:ok, custom_field} =
|
||||
Membership.create_custom_field(
|
||||
%{
|
||||
name: "Emergency contact",
|
||||
value_type: :string
|
||||
},
|
||||
actor: system_actor
|
||||
)
|
||||
|
||||
{:ok, _} =
|
||||
Membership.update_settings(settings, %{
|
||||
join_form_enabled: true,
|
||||
join_form_field_ids: ["email", custom_field.id],
|
||||
join_form_field_required: %{"email" => true, custom_field.id => false}
|
||||
})
|
||||
|
||||
join_request =
|
||||
Fixtures.submitted_join_request_fixture(%{
|
||||
form_data: %{custom_field.id => "Alice Example"}
|
||||
})
|
||||
|
||||
{:ok, view, _html} = live(conn, "/join_requests/#{join_request.id}")
|
||||
|
||||
assert has_element?(view, "span", "#{custom_field.name}:")
|
||||
assert has_element?(view, "span", "Alice Example")
|
||||
refute has_element?(view, "span", "#{custom_field.id}:")
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue