feat: add smtp settings
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon 2026-03-12 13:39:48 +01:00
parent c4135308e6
commit a4f3aa5d6f
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
23 changed files with 2424 additions and 152 deletions

View file

@ -8,7 +8,6 @@ defmodule Mv.Membership.SettingSmtpTest do
"""
use Mv.DataCase, async: false
alias Mv.Helpers.SystemActor
alias Mv.Membership
setup do

View file

@ -37,9 +37,10 @@ defmodule Mv.MailerTest do
assert {:ok, _} = Mailer.send_test_email(to_email)
assert_email_sent(fn email ->
{_name, from_email} = Mailer.mail_from()
from_addresses = Enum.map(email.from, &elem(&1, 1))
from_email in from_addresses
{_name, expected_from} = Mailer.mail_from()
# email.from is a single {name, address} tuple in Swoosh, not a list
{_name, actual_from} = email.from
actual_from == expected_from
end)
end
end

View file

@ -89,19 +89,16 @@ defmodule MvWeb.GlobalSettingsLiveTest do
test "send test email with valid address shows success or error result", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/settings")
# If test email UI exists: fill recipient, click button, assert result area updates
# Uses data-testid or button text "Send test email" / "Test email"
if has_element?(view, "[data-testid='smtp-test-email-form']") do
# Submit the test-email form (phx-submit) with a valid recipient address
view
|> element("[data-testid='smtp-test-email-input']")
|> render_change(%{"to_email" => "test@example.com"})
view
|> element("[data-testid='smtp-send-test-email']")
|> render_click()
# Result is either success or error message
|> form("[data-testid='smtp-test-email-form']", %{"to_email" => "test@example.com"})
|> render_submit()
# Result area must appear regardless of success or error
assert has_element?(view, "[data-testid='smtp-test-result']")
else
# Section not yet implemented: just ensure page still renders
assert render(view) =~ "Settings"
end
end
@ -109,7 +106,7 @@ defmodule MvWeb.GlobalSettingsLiveTest do
test "shows warning when SMTP is not configured in production", %{conn: conn} do
# Concept: in prod, show warning "SMTP is not configured. Transactional emails..."
# In test we only check that the section exists; warning visibility is env-dependent
{:ok, view, html} = live(conn, ~p"/settings")
{:ok, _view, html} = live(conn, ~p"/settings")
assert html =~ "SMTP" or html =~ "E-Mail" or html =~ "Settings"
end
end