Skip to content

Commit

Permalink
[Fix] Using --no-html flag test config doesn't generate live_view c…
Browse files Browse the repository at this point in the history
…onfig (phoenixframework#5802)

* 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 <[email protected]>
Co-authored-by: José Valim <[email protected]>
  • Loading branch information
3 people authored May 6, 2024
1 parent 6ee1226 commit 1ca00c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
10 changes: 5 additions & 5 deletions installer/templates/phx_single/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
10 changes: 5 additions & 5 deletions installer/templates/phx_umbrella/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
8 changes: 8 additions & 0 deletions installer/test/phx_new_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 1ca00c0

Please sign in to comment.