From 1ca00c0f9583090301842a611bb39c9ec618aad7 Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 6 May 2024 12:43:58 -0500 Subject: [PATCH] [Fix] Using `--no-html` flag test config doesn't generate live_view config (#5802) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: add red coverage for issue * feature: apply conditional to generate live view config * Update installer/templates/phx_single/config/test.exs * Update test.exs * Update test.exs --------- Co-authored-by: Philip Capel Co-authored-by: José Valim --- installer/templates/phx_single/config/test.exs | 10 +++++----- installer/templates/phx_umbrella/config/test.exs | 10 +++++----- installer/test/phx_new_test.exs | 8 ++++++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/installer/templates/phx_single/config/test.exs b/installer/templates/phx_single/config/test.exs index 3ba7c78859..d6fdcb4274 100644 --- a/installer/templates/phx_single/config/test.exs +++ b/installer/templates/phx_single/config/test.exs @@ -7,19 +7,19 @@ config :<%= @app_name %>, <%= @endpoint_module %>, secret_key_base: "<%= @secret_key_base_test %>", server: false<%= if @mailer do %> -# In test we don't send emails. +# In test we don't send emails config :<%= @app_name %>, <%= @app_module %>.Mailer, adapter: Swoosh.Adapters.Test -# Disable swoosh api client as it is only required for production adapters. +# Disable swoosh api client as it is only required for production adapters config :swoosh, :api_client, false<% end %> # Print only warnings and errors during test config :logger, level: :warning # Initialize plugs at runtime for faster test compilation -config :phoenix, :plug_init_mode, :runtime +config :phoenix, :plug_init_mode, :runtime<%= if @live do %> +# Enable helpful, but potentially expensive runtime checks config :phoenix_live_view, - # Enable helpful, but potentially expensive runtime checks - enable_expensive_runtime_checks: true + enable_expensive_runtime_checks: true<% end %> diff --git a/installer/templates/phx_umbrella/config/test.exs b/installer/templates/phx_umbrella/config/test.exs index 4683ea8073..85f7e1d022 100644 --- a/installer/templates/phx_umbrella/config/test.exs +++ b/installer/templates/phx_umbrella/config/test.exs @@ -3,16 +3,16 @@ import Config # Print only warnings and errors during test config :logger, level: :warning<%= if @mailer do %> -# In test we don't send emails. +# In test we don't send emails config :<%= @app_name %>, <%= @app_module %>.Mailer, adapter: Swoosh.Adapters.Test -# Disable swoosh api client as it is only required for production adapters. +# Disable swoosh api client as it is only required for production adapters config :swoosh, :api_client, false<% end %> # Initialize plugs at runtime for faster test compilation -config :phoenix, :plug_init_mode, :runtime +config :phoenix, :plug_init_mode, :runtime<%= if @live do %> +# Enable helpful, but potentially expensive runtime checks config :phoenix_live_view, - # Enable helpful, but potentially expensive runtime checks - enable_expensive_runtime_checks: true + enable_expensive_runtime_checks: true<% end %> diff --git a/installer/test/phx_new_test.exs b/installer/test/phx_new_test.exs index 44bdd4d7ce..7c165d54da 100644 --- a/installer/test/phx_new_test.exs +++ b/installer/test/phx_new_test.exs @@ -474,6 +474,10 @@ defmodule Mix.Tasks.Phx.NewTest do assert file =~ ~s|# socket "/live"| refute file =~ ~s|plug Phoenix.LiveDashboard.RequestLogger| end) + + assert_file("phx_blog/config/test.exs", fn file -> + refute file =~ ~s|config :phoenix_live_view| + end) end) end @@ -512,6 +516,10 @@ defmodule Mix.Tasks.Phx.NewTest do refute file =~ ~s|pipeline :browser| assert file =~ ~s|pipe_through [:fetch_session, :protect_from_forgery]| end) + + assert_file("phx_blog/config/test.exs", fn file -> + refute file =~ ~s|config :phoenix_live_view| + end) end) end