@@ -78,4 +78,54 @@ defmodule Igniter.Extensions.PhoenixTest do
7878 { :ok , "test_web/controllers/foo_json.ex" }
7979 end
8080 end
81+
82+ describe "Live namespace handling" do
83+ test "does not duplicate 'live' directory for modules with Live namespace segment" do
84+ igniter =
85+ test_project ( )
86+ |> Igniter.Project.IgniterConfig . add_extension ( Igniter.Extensions.Phoenix )
87+
88+ module_name = MyApp.Live.Dashboard.TestLive
89+
90+ igniter =
91+ Igniter.Project.Module . create_module ( igniter , module_name , """
92+ @moduledoc "Test module"
93+ def hello, do: :world
94+ """ )
95+
96+ { :ok , { _igniter , source , _zipper } } =
97+ Igniter.Project.Module . find_module ( igniter , module_name )
98+
99+ actual_path = Rewrite.Source . get ( source , :path )
100+
101+ refute actual_path =~ ~r/ live\/ live/ ,
102+ "Module path should not contain duplicate 'live/live' directories. Got: #{ actual_path } "
103+
104+ assert actual_path == "lib/my_app/live/dashboard/test_live.ex"
105+ end
106+
107+ test "correctly handles LiveView modules with Web prefix" do
108+ igniter =
109+ test_project ( )
110+ |> Igniter.Project.IgniterConfig . add_extension ( Igniter.Extensions.Phoenix )
111+
112+ module_name = TestWeb.DashboardLive
113+
114+ igniter =
115+ Igniter.Project.Module . create_module ( igniter , module_name , """
116+ use TestWeb, :live_view
117+
118+ def render(assigns) do
119+ ~H"<div>Test</div>"
120+ end
121+ """ )
122+
123+ { :ok , { _igniter , source , _zipper } } =
124+ Igniter.Project.Module . find_module ( igniter , module_name )
125+
126+ actual_path = Rewrite.Source . get ( source , :path )
127+
128+ assert actual_path == "lib/test_web/live/dashboard_live.ex"
129+ end
130+ end
81131end
0 commit comments