Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/lib/linear_cli/cli/display.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
57 changes: 57 additions & 0 deletions app/test/linear_cli/cli/issue_commands_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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" => []}
},
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/test/linear_cli/cli/profile_defaults_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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" => []}
},
Expand Down