feat: Improve handling of association name config
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
605a897045
commit
2443bc62ac
9 changed files with 179 additions and 4 deletions
|
|
@ -13,6 +13,7 @@ defmodule MvWeb.GlobalSettingsLiveTest do
|
|||
"MAIL_FROM_NAME",
|
||||
"MAIL_FROM_EMAIL"
|
||||
]
|
||||
@association_env_key "ASSOCIATION_NAME"
|
||||
|
||||
describe "Global Settings LiveView" do
|
||||
setup %{conn: conn} do
|
||||
|
|
@ -51,6 +52,17 @@ defmodule MvWeb.GlobalSettingsLiveTest do
|
|||
assert render(view) =~ "Updated Club Name"
|
||||
end
|
||||
|
||||
test "updated club name is shown after remount", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
|
||||
assert view
|
||||
|> form("#settings-form", %{setting: %{club_name: "Remount Club Name"}})
|
||||
|> render_submit()
|
||||
|
||||
{:ok, _view_after_remount, html_after_remount} = live(conn, ~p"/settings")
|
||||
assert html_after_remount =~ "Remount Club Name"
|
||||
end
|
||||
|
||||
test "shows error when club_name is empty", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
|
||||
|
|
@ -90,6 +102,34 @@ defmodule MvWeb.GlobalSettingsLiveTest do
|
|||
"Open"
|
||||
)
|
||||
end
|
||||
|
||||
@tag :ui
|
||||
test "disables association name input when ASSOCIATION_NAME is set", %{conn: conn} do
|
||||
clear_association_name_env()
|
||||
System.put_env(@association_env_key, "Association Name from ENV")
|
||||
on_exit(fn -> clear_association_name_env() end)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
|
||||
assert has_element?(view, "#setting_club_name[disabled]")
|
||||
assert has_element?(view, "#setting_club_name[placeholder='From ASSOCIATION_NAME']")
|
||||
refute has_element?(view, "#settings-form button", "Save Name")
|
||||
assert render(view) =~ "Association name is set via environment variable ASSOCIATION_NAME"
|
||||
end
|
||||
|
||||
@tag :ui
|
||||
test "keeps association name input editable when ASSOCIATION_NAME is not set", %{conn: conn} do
|
||||
clear_association_name_env()
|
||||
on_exit(fn -> clear_association_name_env() end)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
|
||||
refute has_element?(view, "#setting_club_name[disabled]")
|
||||
assert has_element?(view, "#settings-form button", "Save Name")
|
||||
|
||||
refute render(view) =~
|
||||
"Association name is set via environment variable ASSOCIATION_NAME"
|
||||
end
|
||||
end
|
||||
|
||||
describe "SMTP / E-Mail section" do
|
||||
|
|
@ -270,4 +310,8 @@ defmodule MvWeb.GlobalSettingsLiveTest do
|
|||
defp clear_smtp_env do
|
||||
Enum.each(@smtp_env_keys, &System.delete_env/1)
|
||||
end
|
||||
|
||||
defp clear_association_name_env do
|
||||
System.delete_env(@association_env_key)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue