mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 14:24:13 +08:00
feat: exclude hidden (minimized) comments from GitHub Issues and PRs (#368)
* feat: ignore minimized comments * fix tests
This commit is contained in:
committed by
GitHub
parent
5bdc533a52
commit
fd012347a2
@@ -252,6 +252,63 @@ describe("formatComments", () => {
|
||||
`[user1 at 2023-01-01T00:00:00Z]: Image: `,
|
||||
);
|
||||
});
|
||||
|
||||
test("filters out minimized comments", () => {
|
||||
const comments: GitHubComment[] = [
|
||||
{
|
||||
id: "1",
|
||||
databaseId: "100001",
|
||||
body: "Normal comment",
|
||||
author: { login: "user1" },
|
||||
createdAt: "2023-01-01T00:00:00Z",
|
||||
isMinimized: false,
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
databaseId: "100002",
|
||||
body: "Minimized comment",
|
||||
author: { login: "user2" },
|
||||
createdAt: "2023-01-02T00:00:00Z",
|
||||
isMinimized: true,
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
databaseId: "100003",
|
||||
body: "Another normal comment",
|
||||
author: { login: "user3" },
|
||||
createdAt: "2023-01-03T00:00:00Z",
|
||||
},
|
||||
];
|
||||
|
||||
const result = formatComments(comments);
|
||||
expect(result).toBe(
|
||||
`[user1 at 2023-01-01T00:00:00Z]: Normal comment\n\n[user3 at 2023-01-03T00:00:00Z]: Another normal comment`,
|
||||
);
|
||||
});
|
||||
|
||||
test("returns empty string when all comments are minimized", () => {
|
||||
const comments: GitHubComment[] = [
|
||||
{
|
||||
id: "1",
|
||||
databaseId: "100001",
|
||||
body: "Minimized comment 1",
|
||||
author: { login: "user1" },
|
||||
createdAt: "2023-01-01T00:00:00Z",
|
||||
isMinimized: true,
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
databaseId: "100002",
|
||||
body: "Minimized comment 2",
|
||||
author: { login: "user2" },
|
||||
createdAt: "2023-01-02T00:00:00Z",
|
||||
isMinimized: true,
|
||||
},
|
||||
];
|
||||
|
||||
const result = formatComments(comments);
|
||||
expect(result).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatReviewComments", () => {
|
||||
@@ -517,6 +574,159 @@ describe("formatReviewComments", () => {
|
||||
`[Review by reviewer1 at 2023-01-01T00:00:00Z]: APPROVED\nReview body\n [Comment on src/index.ts:42]: Image: `,
|
||||
);
|
||||
});
|
||||
|
||||
test("filters out minimized review comments", () => {
|
||||
const reviewData = {
|
||||
nodes: [
|
||||
{
|
||||
id: "review1",
|
||||
databaseId: "300001",
|
||||
author: { login: "reviewer1" },
|
||||
body: "Review with mixed comments",
|
||||
state: "APPROVED",
|
||||
submittedAt: "2023-01-01T00:00:00Z",
|
||||
comments: {
|
||||
nodes: [
|
||||
{
|
||||
id: "comment1",
|
||||
databaseId: "200001",
|
||||
body: "Normal review comment",
|
||||
author: { login: "reviewer1" },
|
||||
createdAt: "2023-01-01T00:00:00Z",
|
||||
path: "src/index.ts",
|
||||
line: 42,
|
||||
isMinimized: false,
|
||||
},
|
||||
{
|
||||
id: "comment2",
|
||||
databaseId: "200002",
|
||||
body: "Minimized review comment",
|
||||
author: { login: "reviewer1" },
|
||||
createdAt: "2023-01-01T00:00:00Z",
|
||||
path: "src/utils.ts",
|
||||
line: 15,
|
||||
isMinimized: true,
|
||||
},
|
||||
{
|
||||
id: "comment3",
|
||||
databaseId: "200003",
|
||||
body: "Another normal comment",
|
||||
author: { login: "reviewer1" },
|
||||
createdAt: "2023-01-01T00:00:00Z",
|
||||
path: "src/main.ts",
|
||||
line: 10,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = formatReviewComments(reviewData);
|
||||
expect(result).toBe(
|
||||
`[Review by reviewer1 at 2023-01-01T00:00:00Z]: APPROVED\nReview with mixed comments\n [Comment on src/index.ts:42]: Normal review comment\n [Comment on src/main.ts:10]: Another normal comment`,
|
||||
);
|
||||
});
|
||||
|
||||
test("returns review with only body when all review comments are minimized", () => {
|
||||
const reviewData = {
|
||||
nodes: [
|
||||
{
|
||||
id: "review1",
|
||||
databaseId: "300001",
|
||||
author: { login: "reviewer1" },
|
||||
body: "Review body only",
|
||||
state: "APPROVED",
|
||||
submittedAt: "2023-01-01T00:00:00Z",
|
||||
comments: {
|
||||
nodes: [
|
||||
{
|
||||
id: "comment1",
|
||||
databaseId: "200001",
|
||||
body: "Minimized comment 1",
|
||||
author: { login: "reviewer1" },
|
||||
createdAt: "2023-01-01T00:00:00Z",
|
||||
path: "src/index.ts",
|
||||
line: 42,
|
||||
isMinimized: true,
|
||||
},
|
||||
{
|
||||
id: "comment2",
|
||||
databaseId: "200002",
|
||||
body: "Minimized comment 2",
|
||||
author: { login: "reviewer1" },
|
||||
createdAt: "2023-01-01T00:00:00Z",
|
||||
path: "src/utils.ts",
|
||||
line: 15,
|
||||
isMinimized: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = formatReviewComments(reviewData);
|
||||
expect(result).toBe(
|
||||
`[Review by reviewer1 at 2023-01-01T00:00:00Z]: APPROVED\nReview body only`,
|
||||
);
|
||||
});
|
||||
|
||||
test("handles multiple reviews with mixed minimized comments", () => {
|
||||
const reviewData = {
|
||||
nodes: [
|
||||
{
|
||||
id: "review1",
|
||||
databaseId: "300001",
|
||||
author: { login: "reviewer1" },
|
||||
body: "First review",
|
||||
state: "APPROVED",
|
||||
submittedAt: "2023-01-01T00:00:00Z",
|
||||
comments: {
|
||||
nodes: [
|
||||
{
|
||||
id: "comment1",
|
||||
databaseId: "200001",
|
||||
body: "Good comment",
|
||||
author: { login: "reviewer1" },
|
||||
createdAt: "2023-01-01T00:00:00Z",
|
||||
path: "src/index.ts",
|
||||
line: 42,
|
||||
isMinimized: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "review2",
|
||||
databaseId: "300002",
|
||||
author: { login: "reviewer2" },
|
||||
body: "Second review",
|
||||
state: "COMMENTED",
|
||||
submittedAt: "2023-01-02T00:00:00Z",
|
||||
comments: {
|
||||
nodes: [
|
||||
{
|
||||
id: "comment2",
|
||||
databaseId: "200002",
|
||||
body: "Spam comment",
|
||||
author: { login: "reviewer2" },
|
||||
createdAt: "2023-01-02T00:00:00Z",
|
||||
path: "src/utils.ts",
|
||||
line: 15,
|
||||
isMinimized: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = formatReviewComments(reviewData);
|
||||
expect(result).toBe(
|
||||
`[Review by reviewer1 at 2023-01-01T00:00:00Z]: APPROVED\nFirst review\n [Comment on src/index.ts:42]: Good comment\n\n[Review by reviewer2 at 2023-01-02T00:00:00Z]: COMMENTED\nSecond review`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatChangedFiles", () => {
|
||||
|
||||
Reference in New Issue
Block a user