Skip to content
Open
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
17 changes: 17 additions & 0 deletions src/utils/linear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export async function fetchIssueDetails(
project?: { name: string } | null
projectMilestone?: { name: string } | null
cycle?: { name?: string | null; number: number } | null
labels?: Array<{ id: string; name: string; color: string }>
parent?: {
identifier: string
title: string
Expand Down Expand Up @@ -225,6 +226,13 @@ export async function fetchIssueDetails(
name
number
}
labels(first: 50) {
nodes {
id
name
color
}
}
parent {
identifier
title
Expand Down Expand Up @@ -298,6 +306,13 @@ export async function fetchIssueDetails(
name
number
}
labels(first: 50) {
nodes {
id
name
color
}
}
parent {
identifier
title
Expand Down Expand Up @@ -338,6 +353,7 @@ export async function fetchIssueDetails(
spinner?.stop()
return {
...data.issue,
labels: data.issue.labels?.nodes || [],
children: data.issue.children?.nodes || [],
comments: data.issue.comments?.nodes || [],
attachments: data.issue.attachments?.nodes || [],
Expand All @@ -347,6 +363,7 @@ export async function fetchIssueDetails(
spinner?.stop()
return {
...data.issue,
labels: data.issue.labels?.nodes || [],
children: data.issue.children?.nodes || [],
attachments: data.issue.attachments?.nodes || [],
}
Expand Down
47 changes: 41 additions & 6 deletions test/commands/issue/__snapshots__/issue-view.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ Users are experiencing issues logging in when their session expires.

## Comments

- **@Bob Senior** - *1/15/2024*
- **@Bob Senior** - *2024/1/16*

Should we also consider implementing automatic session refresh?

- **@John Doe** - *1/15/2024*
- **@John Doe** - *2024/1/15*

I've reproduced this issue on staging. The session timeout seems to be too aggressive.

- **@Jane Smith** - *1/15/2024*
- **@Jane Smith** - *2024/1/15*

Working on a fix. Will increase the session timeout and add proper error handling.

- **@Alice Developer** - *1/15/2024*
- **@Alice Developer** - *2024/1/15*

Sounds good! Also, we should add better error messaging for expired sessions.

Expand Down Expand Up @@ -108,7 +108,41 @@ stdout:
},
"parent": null,
"children": [],
"attachments": []
"attachments": [],
"labels": []
}
'
stderr:
""
`;

snapshot[`Issue View Command - JSON Output With Labels 1`] = `
stdout:
'{
"identifier": "TEST-123",
"title": "Fix authentication bug in login flow",
"description": "Users are experiencing issues logging in when their session expires.",
"url": "https://linear.app/test-team/issue/TEST-123/fix-authentication-bug-in-login-flow",
"branchName": "fix/test-123-auth-bug",
"state": {
"name": "In Progress",
"color": "#f87462"
},
"parent": null,
"children": [],
"attachments": [],
"labels": [
{
"id": "label-1",
"name": "bug",
"color": "#e5484d"
},
{
"id": "label-2",
"name": "priority:high",
"color": "#f5a524"
}
]
}
'
stderr:
Expand Down Expand Up @@ -157,7 +191,8 @@ stdout:
}
}
],
"attachments": []
"attachments": [],
"labels": []
}
\`
stderr:
Expand Down
73 changes: 73 additions & 0 deletions test/commands/issue/issue-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ await snapshotTest({
attachments: {
nodes: [],
},
labels: {
nodes: [],
},
},
},
},
Expand Down Expand Up @@ -115,6 +118,9 @@ await snapshotTest({
attachments: {
nodes: [],
},
labels: {
nodes: [],
},
},
},
},
Expand Down Expand Up @@ -335,6 +341,73 @@ await snapshotTest({
},
})

// Test JSON output with labels
await snapshotTest({
name: "Issue View Command - JSON Output With Labels",
meta: import.meta,
colors: false,
args: ["TEST-123", "--json", "--no-comments"],
denoArgs,
async fn() {
const server = new MockLinearServer([
{
queryName: "GetIssueDetails",
variables: { id: "TEST-123" },
response: {
data: {
issue: {
identifier: "TEST-123",
title: "Fix authentication bug in login flow",
description:
"Users are experiencing issues logging in when their session expires.",
url:
"https://linear.app/test-team/issue/TEST-123/fix-authentication-bug-in-login-flow",
branchName: "fix/test-123-auth-bug",
state: {
name: "In Progress",
color: "#f87462",
},
parent: null,
children: {
nodes: [],
},
attachments: {
nodes: [],
},
labels: {
nodes: [
{
id: "label-1",
name: "bug",
color: "#e5484d",
},
{
id: "label-2",
name: "priority:high",
color: "#f5a524",
},
],
},
},
},
},
},
])

try {
await server.start()
Deno.env.set("LINEAR_GRAPHQL_ENDPOINT", server.getEndpoint())
Deno.env.set("LINEAR_API_KEY", "Bearer test-token")

await viewCommand.parse()
} finally {
await server.stop()
Deno.env.delete("LINEAR_GRAPHQL_ENDPOINT")
Deno.env.delete("LINEAR_API_KEY")
}
},
})

// Test JSON output with comments
await snapshotTest({
name: "Issue View Command - JSON Output With Comments",
Expand Down
Loading