@@ -150,6 +150,46 @@ defmodule LinearCli.CLI.Commands.Issues.MoveTest do
150150 assert output =~ "Move cancelled"
151151 end
152152
153+ test "closed stdin cancels explicit-ID move without mutation" do
154+ test_pid = self ( )
155+
156+ Req.Test . stub ( LinearCli.Api , fn conn ->
157+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
158+ decoded = Jason . decode! ( body )
159+ query = decoded [ "query" ]
160+
161+ cond do
162+ String . contains? ( query , "issue(id: $id)" ) ->
163+ Req.Test . json ( conn , % { "data" => % { "issue" => issue_map ( ) } } )
164+
165+ String . contains? ( query , "projects(first: 100" ) ->
166+ Req.Test . json ( conn , move_team_projects ( ) )
167+
168+ String . contains? ( query , "issueUpdate" ) ->
169+ send ( test_pid , :mutation_called )
170+ raise "closed stdin must not send issueUpdate"
171+
172+ true ->
173+ raise "no stub matched query: #{ query } "
174+ end
175+ end )
176+
177+ output =
178+ capture_io ( [ input: "" ] , fn ->
179+ assert :ok =
180+ LinearCli.CLI . main ( [
181+ "issue" ,
182+ "move" ,
183+ "--project" ,
184+ "Manhattan" ,
185+ "CRY-1"
186+ ] )
187+ end )
188+
189+ refute_received :mutation_called
190+ assert output =~ "Move cancelled"
191+ end
192+
153193 test "user confirms, mutation is called" do
154194 test_pid = self ( )
155195
@@ -473,6 +513,43 @@ defmodule LinearCli.CLI.Commands.Issues.MoveTest do
473513 assert vars3 [ "input" ] [ "projectId" ] == "p-tgt"
474514 end
475515
516+ test "--from/--to proceeds with an explicit yes answer" do
517+ test_pid = self ( )
518+
519+ Req.Test . stub ( LinearCli.Api , fn conn ->
520+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
521+ decoded = Jason . decode! ( body )
522+ % { "query" => query } = decoded
523+
524+ if String . contains? ( query , "issueUpdate" ) do
525+ send ( test_pid , :update )
526+ end
527+
528+ case Enum . find ( bulk_stub_pairs ( ) , fn { match , _ } -> String . contains? ( query , match ) end ) do
529+ { _match , response } -> Req.Test . json ( conn , response )
530+ nil -> raise "no stub matched query: #{ query } "
531+ end
532+ end )
533+
534+ capture_io ( [ input: "y\n " ] , fn ->
535+ assert :ok =
536+ LinearCli.CLI . main ( [
537+ "issue" ,
538+ "move" ,
539+ "--from" ,
540+ "Source Project" ,
541+ "--to" ,
542+ "Target Project" ,
543+ "--team" ,
544+ "ENG"
545+ ] )
546+ end )
547+
548+ assert_received :update
549+ assert_received :update
550+ assert_received :update
551+ end
552+
476553 test "--from/--to --all sends list query without completedAt/canceledAt guards" do
477554 test_pid = self ( )
478555
@@ -726,6 +803,43 @@ defmodule LinearCli.CLI.Commands.Issues.MoveTest do
726803 assert output =~ "Move cancelled"
727804 end
728805
806+ test "--from/--to closed stdin cancels without mutation" do
807+ test_pid = self ( )
808+
809+ Req.Test . stub ( LinearCli.Api , fn conn ->
810+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
811+ % { "query" => query } = Jason . decode! ( body )
812+
813+ if String . contains? ( query , "issueUpdate" ) do
814+ send ( test_pid , :mutation_called )
815+ raise "closed stdin must not send issueUpdate"
816+ end
817+
818+ case Enum . find ( bulk_stub_pairs ( ) , fn { match , _ } -> String . contains? ( query , match ) end ) do
819+ { _match , response } -> Req.Test . json ( conn , response )
820+ nil -> raise "no stub matched query: #{ query } "
821+ end
822+ end )
823+
824+ output =
825+ capture_io ( [ input: "" ] , fn ->
826+ assert :ok =
827+ LinearCli.CLI . main ( [
828+ "issue" ,
829+ "move" ,
830+ "--from" ,
831+ "Source Project" ,
832+ "--to" ,
833+ "Target Project" ,
834+ "--team" ,
835+ "ENG"
836+ ] )
837+ end )
838+
839+ refute_received :mutation_called
840+ assert output =~ "Move cancelled"
841+ end
842+
729843 test "--from without --to exits 22 with a clear error" do
730844 test_pid = self ( )
731845 halt = fn code -> send ( test_pid , { :halted , code } ) end
0 commit comments