test: verify smtp config either via env or UI only
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
679f1404e9
commit
a244b1b07e
1 changed files with 53 additions and 1 deletions
|
|
@ -1,8 +1,19 @@
|
||||||
defmodule MvWeb.GlobalSettingsLiveTest do
|
defmodule MvWeb.GlobalSettingsLiveTest do
|
||||||
use MvWeb.ConnCase, async: true
|
use MvWeb.ConnCase, async: false
|
||||||
import Phoenix.LiveViewTest
|
import Phoenix.LiveViewTest
|
||||||
alias Mv.Membership
|
alias Mv.Membership
|
||||||
|
|
||||||
|
@smtp_env_keys [
|
||||||
|
"SMTP_HOST",
|
||||||
|
"SMTP_PORT",
|
||||||
|
"SMTP_USERNAME",
|
||||||
|
"SMTP_PASSWORD",
|
||||||
|
"SMTP_PASSWORD_FILE",
|
||||||
|
"SMTP_SSL",
|
||||||
|
"MAIL_FROM_NAME",
|
||||||
|
"MAIL_FROM_EMAIL"
|
||||||
|
]
|
||||||
|
|
||||||
describe "Global Settings LiveView" do
|
describe "Global Settings LiveView" do
|
||||||
setup %{conn: conn} do
|
setup %{conn: conn} do
|
||||||
user = create_test_user(%{email: "admin@example.com"})
|
user = create_test_user(%{email: "admin@example.com"})
|
||||||
|
|
@ -124,6 +135,43 @@ defmodule MvWeb.GlobalSettingsLiveTest do
|
||||||
{:ok, _view, html} = live(conn, ~p"/settings")
|
{:ok, _view, html} = live(conn, ~p"/settings")
|
||||||
assert html =~ "SMTP" or html =~ "E-Mail" or html =~ "Settings"
|
assert html =~ "SMTP" or html =~ "E-Mail" or html =~ "Settings"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@tag :ui
|
||||||
|
test "disables all SMTP inputs when SMTP_HOST is set", %{conn: conn} do
|
||||||
|
clear_smtp_env()
|
||||||
|
System.put_env("SMTP_HOST", "smtp.env-only.example")
|
||||||
|
on_exit(fn -> clear_smtp_env() end)
|
||||||
|
|
||||||
|
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||||
|
|
||||||
|
assert has_element?(view, "#setting_smtp_host[disabled]")
|
||||||
|
assert has_element?(view, "#setting_smtp_port[disabled]")
|
||||||
|
assert has_element?(view, "#setting_smtp_ssl[disabled]")
|
||||||
|
assert has_element?(view, "#setting_smtp_username[disabled]")
|
||||||
|
assert has_element?(view, "#setting_smtp_password[disabled]")
|
||||||
|
assert has_element?(view, "#setting_smtp_from_email[disabled]")
|
||||||
|
assert has_element?(view, "#setting_smtp_from_name[disabled]")
|
||||||
|
end
|
||||||
|
|
||||||
|
@tag :ui
|
||||||
|
test "does not render SMTP save action when SMTP_HOST is set", %{conn: conn} do
|
||||||
|
clear_smtp_env()
|
||||||
|
System.put_env("SMTP_HOST", "smtp.env-only.example")
|
||||||
|
on_exit(fn -> clear_smtp_env() end)
|
||||||
|
|
||||||
|
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||||
|
refute has_element?(view, "#smtp-form button", "Save SMTP Settings")
|
||||||
|
end
|
||||||
|
|
||||||
|
@tag :ui
|
||||||
|
test "shows explicit ENV-only mode hint when SMTP_HOST is set", %{conn: conn} do
|
||||||
|
clear_smtp_env()
|
||||||
|
System.put_env("SMTP_HOST", "smtp.env-only.example")
|
||||||
|
on_exit(fn -> clear_smtp_env() end)
|
||||||
|
|
||||||
|
{:ok, _view, html} = live(conn, ~p"/settings")
|
||||||
|
assert html =~ "SMTP is fully managed via environment variables"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Authentication section when OIDC-only is enabled" do
|
describe "Authentication section when OIDC-only is enabled" do
|
||||||
|
|
@ -190,4 +238,8 @@ defmodule MvWeb.GlobalSettingsLiveTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp clear_smtp_env do
|
||||||
|
Enum.each(@smtp_env_keys, &System.delete_env/1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue