diff --git a/app/lib/linear_cli/cli/display.ex b/app/lib/linear_cli/cli/display.ex index 301a140..d5a8538 100644 --- a/app/lib/linear_cli/cli/display.ex +++ b/app/lib/linear_cli/cli/display.ex @@ -68,7 +68,8 @@ defmodule LinearCli.CLI.Display do end defp issue_line(issue) do - basic = "#{String.pad_trailing(issue.identifier || "", 12)} #{issue.title}" + state = if issue.state, do: "[#{issue.state.name}] ", else: "" + basic = "#{String.pad_trailing(issue.identifier || "", 12)} #{state}#{issue.title}" if issue.assignee, do: "#{basic} (#{issue.assignee.name})", else: basic end diff --git a/app/test/linear_cli/cli/issue_commands_test.exs b/app/test/linear_cli/cli/issue_commands_test.exs index b89a884..c41940e 100644 --- a/app/test/linear_cli/cli/issue_commands_test.exs +++ b/app/test/linear_cli/cli/issue_commands_test.exs @@ -73,6 +73,7 @@ defmodule LinearCli.CLI.IssueCommandsTest do "branchName" => "cry-1-fix-the-thing", "description" => "It is broken", "assignee" => nil, + "state" => %{"id" => "s1", "name" => "In Progress", "type" => "started"}, "team" => team_map(), "comments" => %{"nodes" => []} }, @@ -379,6 +380,62 @@ defmodule LinearCli.CLI.IssueCommandsTest do assert_received {:halted, 1} end + + test "compact listing includes workflow state name in brackets" do + Req.Test.stub(LinearCli.Api, fn conn -> + {:ok, body, conn} = Plug.Conn.read_body(conn) + %{"query" => query} = Jason.decode!(body) + + if String.contains?(query, "projects(") do + raise "issue list must not query projects when --project wasn't given" + end + + Req.Test.json( + conn, + issues_response([ + issue_map(%{"state" => %{"id" => "s2", "name" => "In Review", "type" => "started"}}) + ]) + ) + end) + + output = capture_io(fn -> assert :ok = LinearCli.CLI.main(["issue", "list"]) end) + assert output =~ "[In Review]" + assert output =~ "Fix the thing" + end + + test "compact listing omits state bracket when state is nil" do + Req.Test.stub(LinearCli.Api, fn conn -> + {:ok, body, conn} = Plug.Conn.read_body(conn) + %{"query" => _} = Jason.decode!(body) + Req.Test.json(conn, issues_response([issue_map(%{"state" => nil})])) + end) + + output = capture_io(fn -> assert :ok = LinearCli.CLI.main(["issue", "list"]) end) + assert output =~ "CRY-1" + refute output =~ "[" + end + + test "--full listing includes workflow state name in header" do + Req.Test.stub(LinearCli.Api, fn conn -> + {:ok, body, conn} = Plug.Conn.read_body(conn) + %{"query" => _} = Jason.decode!(body) + + Req.Test.json(conn, %{ + "data" => %{ + "issue" => + issue_map(%{"state" => %{"id" => "s3", "name" => "Done", "type" => "completed"}}) + } + }) + end) + + output = + capture_io(fn -> + assert :ok = LinearCli.CLI.main(["issue", "list", "--full", "CRY-1"]) + end) + + assert output =~ "[Done]" + assert output =~ "Fix the thing" + end end describe "issue create (Ruby: commands/issue/create.rb)" do diff --git a/app/test/linear_cli/cli/profile_defaults_test.exs b/app/test/linear_cli/cli/profile_defaults_test.exs index 67507da..3ede985 100644 --- a/app/test/linear_cli/cli/profile_defaults_test.exs +++ b/app/test/linear_cli/cli/profile_defaults_test.exs @@ -73,6 +73,7 @@ defmodule LinearCli.CLI.ProfileDefaultsTest do "branchName" => "cry-1-fix-the-thing", "description" => "It is broken", "assignee" => nil, + "state" => %{"id" => "s1", "name" => "In Progress", "type" => "started"}, "team" => team_map("ENG"), "comments" => %{"nodes" => []} },