diff --git a/src/utils/linear.ts b/src/utils/linear.ts index cd4d2c0c..4bee01d2 100644 --- a/src/utils/linear.ts +++ b/src/utils/linear.ts @@ -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 @@ -225,6 +226,13 @@ export async function fetchIssueDetails( name number } + labels(first: 50) { + nodes { + id + name + color + } + } parent { identifier title @@ -298,6 +306,13 @@ export async function fetchIssueDetails( name number } + labels(first: 50) { + nodes { + id + name + color + } + } parent { identifier title @@ -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 || [], @@ -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 || [], } diff --git a/test/commands/issue/__snapshots__/issue-view.test.ts.snap b/test/commands/issue/__snapshots__/issue-view.test.ts.snap index b8e1162f..dd524f03 100644 --- a/test/commands/issue/__snapshots__/issue-view.test.ts.snap +++ b/test/commands/issue/__snapshots__/issue-view.test.ts.snap @@ -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. @@ -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: @@ -157,7 +191,8 @@ stdout: } } ], - "attachments": [] + "attachments": [], + "labels": [] } \` stderr: diff --git a/test/commands/issue/issue-view.test.ts b/test/commands/issue/issue-view.test.ts index b4e04f16..2764ffaa 100644 --- a/test/commands/issue/issue-view.test.ts +++ b/test/commands/issue/issue-view.test.ts @@ -60,6 +60,9 @@ await snapshotTest({ attachments: { nodes: [], }, + labels: { + nodes: [], + }, }, }, }, @@ -115,6 +118,9 @@ await snapshotTest({ attachments: { nodes: [], }, + labels: { + nodes: [], + }, }, }, }, @@ -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",