fix: join confirmation mail configuration
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
a7481f6ab1
commit
40a4461d23
12 changed files with 167 additions and 28 deletions
54
test/mv_web/live/join_live_email_failure_test.exs
Normal file
54
test/mv_web/live/join_live_email_failure_test.exs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
defmodule MvWeb.JoinLiveEmailFailureTest do
|
||||
@moduledoc """
|
||||
When join confirmation email delivery fails, the user sees an error message
|
||||
and no success copy. Uses FailingMailAdapter; async: false to avoid config races.
|
||||
"""
|
||||
use MvWeb.ConnCase, async: false
|
||||
import Phoenix.LiveViewTest
|
||||
|
||||
alias Mv.Membership
|
||||
|
||||
@tag role: :unauthenticated
|
||||
test "when confirmation email fails, user sees error flash and no success message", %{
|
||||
conn: conn
|
||||
} do
|
||||
enable_join_form_for_test()
|
||||
|
||||
saved = Application.get_env(:mv, Mv.Mailer)
|
||||
|
||||
Application.put_env(
|
||||
:mv,
|
||||
Mv.Mailer,
|
||||
Keyword.put(saved || [], :adapter, Mv.TestSupport.FailingMailAdapter)
|
||||
)
|
||||
|
||||
on_exit(fn ->
|
||||
Application.put_env(:mv, Mv.Mailer, saved)
|
||||
end)
|
||||
|
||||
{:ok, view, _html} = live(conn, "/join")
|
||||
|
||||
view
|
||||
|> form("#join-form", %{
|
||||
"email" => "fail#{System.unique_integer([:positive])}@example.com",
|
||||
"first_name" => "Jane",
|
||||
"last_name" => "Doe",
|
||||
"website" => ""
|
||||
})
|
||||
|> render_submit()
|
||||
|
||||
html = render(view)
|
||||
assert html =~ "could not send" or html =~ "confirmation email"
|
||||
refute view |> element("[data-testid='join-success-message']") |> has_element?()
|
||||
end
|
||||
|
||||
defp enable_join_form_for_test do
|
||||
{:ok, settings} = Membership.get_settings()
|
||||
|
||||
Membership.update_settings(settings, %{
|
||||
join_form_enabled: true,
|
||||
join_form_field_ids: ["email", "first_name", "last_name"],
|
||||
join_form_field_required: %{"email" => true, "first_name" => false, "last_name" => false}
|
||||
})
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue