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
7 changes: 6 additions & 1 deletion src/commands/issue/issue-comment-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export const commentAddCommand = new Command()
"Read comment body from a file (preferred for markdown content)",
)
.option("-p, --parent <id:string>", "Parent comment ID for replies")
.option("--id <uuid:string>", "Caller-supplied UUID for the new comment", {
hidden: true,
})
.option(
"-a, --attach <filepath:string>",
"Upload a file and add its Markdown link to the comment (images render inline; repeatable)",
Expand All @@ -35,7 +38,7 @@ export const commentAddCommand = new Command()
"Upload attached images to a public, unauthenticated URL (default: private, workspace-members only)",
)
.action(async (options, issueId) => {
const { body, bodyFile, parent, attach, public: makePublic } = options
const { body, bodyFile, parent, id, attach, public: makePublic } = options

try {
// Validate that body and bodyFile are not both provided
Expand Down Expand Up @@ -168,6 +171,8 @@ export const commentAddCommand = new Command()
issueId: resolvedIdentifier,
}

if (id) input.id = id

if (parent) {
input.parentId = parent
}
Expand Down
2 changes: 2 additions & 0 deletions src/commands/issue/issue-comment-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ export const commentListCommand = new Command()
body
createdAt
updatedAt
editedAt
url
user {
id
name
displayName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ stderr:
""
`;

snapshot[`Issue Comment Add Command - With Caller Supplied ID 1`] = `
stdout:
"✓ Comment added to TEST-123
https://linear.app/issue/TEST-123#comment-uuid
"
stderr:
""
`;

snapshot[`Issue Comment Add Command - With Parent Flag 1`] = `
stdout:
"✓ Comment added to TEST-123
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ stdout:
"body": "This is a comment",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z",
"editedAt": null,
"url": "https://linear.app/issue/TEST-123#comment-uuid-456",
"user": {
"id": "user-uuid-123",
"name": "testuser",
"displayName": "Test User"
},
Expand Down
53 changes: 53 additions & 0 deletions test/commands/issue/issue-comment-add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,59 @@ await snapshotTest({
},
})

await snapshotTest({
name: "Issue Comment Add Command - With Caller Supplied ID",
meta: import.meta,
colors: false,
args: [
"TEST-123",
"--body",
"Bound authority marker",
"--id",
"123e4567-e89b-42d3-a456-426614174000",
],
denoArgs: commonDenoArgs,
async fn() {
const { cleanup } = await setupMockLinearServer([
{
queryName: "GetIssueId",
variables: { id: "TEST-123" },
response: { data: { issue: { id: "issue-uuid-123" } } },
},
{
queryName: "AddComment",
variables: {
input: {
body: "Bound authority marker",
id: "123e4567-e89b-42d3-a456-426614174000",
issueId: "TEST-123",
},
},
response: {
data: {
commentCreate: {
success: true,
comment: {
id: "123e4567-e89b-42d3-a456-426614174000",
body: "Bound authority marker",
createdAt: "2024-01-15T10:30:00Z",
url: "https://linear.app/issue/TEST-123#comment-uuid",
user: { name: "testuser", displayName: "Test User" },
},
},
},
},
},
])

try {
await commentAddCommand.parse()
} finally {
await cleanup()
}
},
})

// Test replying to a comment with parent flag
await snapshotTest({
name: "Issue Comment Add Command - With Parent Flag",
Expand Down
3 changes: 3 additions & 0 deletions test/commands/issue/issue-comment-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ await snapshotTest({
},
{
queryName: "GetIssueComments",
queryIncludes: "editedAt",
response: {
data: {
issue: {
Expand All @@ -125,8 +126,10 @@ await snapshotTest({
body: "This is a comment",
createdAt: "2024-01-15T10:30:00Z",
updatedAt: "2024-01-15T10:30:00Z",
editedAt: null,
url: "https://linear.app/issue/TEST-123#comment-uuid-456",
user: {
id: "user-uuid-123",
name: "testuser",
displayName: "Test User",
},
Expand Down
1 change: 1 addition & 0 deletions test/utils/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const commonDenoArgs = ["--allow-all", "--quiet"]
export async function setupMockLinearServer(
mockResponses: Array<{
queryName: string
queryIncludes?: string
variables?: Record<string, unknown>
response: Record<string, unknown>
}>,
Expand Down
Loading