@@ -73,6 +73,7 @@ defmodule LinearCli.CLI.IssueCommandsTest do
7373 "branchName" => "cry-1-fix-the-thing" ,
7474 "description" => "It is broken" ,
7575 "assignee" => nil ,
76+ "state" => % { "id" => "s1" , "name" => "In Progress" , "type" => "started" } ,
7677 "team" => team_map ( ) ,
7778 "comments" => % { "nodes" => [ ] }
7879 } ,
@@ -256,6 +257,49 @@ defmodule LinearCli.CLI.IssueCommandsTest do
256257 assert output =~ "CRY-1"
257258 end
258259
260+ test "compact listing shows workflow status name in brackets" do
261+ Req.Test . stub ( LinearCli.Api , fn conn ->
262+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
263+ Req.Test . json ( conn , issues_response ( [ issue_map ( ) ] ) )
264+ end )
265+
266+ output = capture_io ( fn -> assert :ok = LinearCli.CLI . main ( [ "issue" , "list" ] ) end )
267+ assert output =~ "[In Progress]"
268+ assert output =~ "Fix the thing"
269+ end
270+
271+ test "compact listing omits status brackets when state is absent" do
272+ Req.Test . stub ( LinearCli.Api , fn conn ->
273+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
274+ Req.Test . json ( conn , issues_response ( [ issue_map ( % { "state" => nil } ) ] ) )
275+ end )
276+
277+ output = capture_io ( fn -> assert :ok = LinearCli.CLI . main ( [ "issue" , "list" ] ) end )
278+ assert output =~ "CRY-1"
279+ refute output =~ "["
280+ end
281+
282+ test "--full listing shows workflow status in the header line" do
283+ Req.Test . stub ( LinearCli.Api , fn conn ->
284+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
285+ % { "query" => query } = Jason . decode! ( body )
286+
287+ if String . contains? ( query , "issue(id: $id)" ) do
288+ Req.Test . json ( conn , % { "data" => % { "issue" => issue_map ( ) } } )
289+ else
290+ Req.Test . json ( conn , issues_response ( [ issue_map ( ) ] ) )
291+ end
292+ end )
293+
294+ output =
295+ capture_io ( fn ->
296+ assert :ok = LinearCli.CLI . main ( [ "issue" , "list" , "--full" , "CRY-1" ] )
297+ end )
298+
299+ assert output =~ "[In Progress]"
300+ assert output =~ "Fix the thing"
301+ end
302+
259303 test "--all removes completedAt and canceledAt null-check filters" do
260304 test_pid = self ( )
261305
@@ -379,6 +423,62 @@ defmodule LinearCli.CLI.IssueCommandsTest do
379423
380424 assert_received { :halted , 1 }
381425 end
426+
427+ test "compact listing includes workflow state name in brackets" do
428+ Req.Test . stub ( LinearCli.Api , fn conn ->
429+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
430+ % { "query" => query } = Jason . decode! ( body )
431+
432+ if String . contains? ( query , "projects(" ) do
433+ raise "issue list must not query projects when --project wasn't given"
434+ end
435+
436+ Req.Test . json (
437+ conn ,
438+ issues_response ( [
439+ issue_map ( % { "state" => % { "id" => "s2" , "name" => "In Review" , "type" => "started" } } )
440+ ] )
441+ )
442+ end )
443+
444+ output = capture_io ( fn -> assert :ok = LinearCli.CLI . main ( [ "issue" , "list" ] ) end )
445+ assert output =~ "[In Review]"
446+ assert output =~ "Fix the thing"
447+ end
448+
449+ test "compact listing omits state bracket when state is nil" do
450+ Req.Test . stub ( LinearCli.Api , fn conn ->
451+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
452+ % { "query" => _ } = Jason . decode! ( body )
453+ Req.Test . json ( conn , issues_response ( [ issue_map ( % { "state" => nil } ) ] ) )
454+ end )
455+
456+ output = capture_io ( fn -> assert :ok = LinearCli.CLI . main ( [ "issue" , "list" ] ) end )
457+ assert output =~ "CRY-1"
458+ refute output =~ "["
459+ end
460+
461+ test "--full listing includes workflow state name in header" do
462+ Req.Test . stub ( LinearCli.Api , fn conn ->
463+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
464+ % { "query" => _ } = Jason . decode! ( body )
465+
466+ Req.Test . json ( conn , % {
467+ "data" => % {
468+ "issue" =>
469+ issue_map ( % { "state" => % { "id" => "s3" , "name" => "Done" , "type" => "completed" } } )
470+ }
471+ } )
472+ end )
473+
474+ output =
475+ capture_io ( fn ->
476+ assert :ok = LinearCli.CLI . main ( [ "issue" , "list" , "--full" , "CRY-1" ] )
477+ end )
478+
479+ assert output =~ "[Done]"
480+ assert output =~ "Fix the thing"
481+ end
382482 end
383483
384484 describe "issue create (Ruby: commands/issue/create.rb)" do
0 commit comments