@@ -1008,7 +1008,7 @@ func TestPullRequestReviewCommentSubmit(t *testing.T) {
1008
1008
"owner" : currentOwner ,
1009
1009
"repo" : repoName ,
1010
1010
"path" : "test-file.txt" ,
1011
- "content" : fmt .Sprintf ("Created by e2e test %s" , t .Name ()),
1011
+ "content" : fmt .Sprintf ("Created by e2e test %s\n with multiple lines " , t .Name ()),
1012
1012
"message" : "Add test file" ,
1013
1013
"branch" : "test-branch" ,
1014
1014
}
@@ -1065,21 +1065,62 @@ func TestPullRequestReviewCommentSubmit(t *testing.T) {
1065
1065
require .True (t , ok , "expected content to be of type TextContent" )
1066
1066
require .Equal (t , "" , textContent .Text , "expected content to be empty" )
1067
1067
1068
- // Add a review comment
1069
- addReviewCommentRequest := mcp.CallToolRequest {}
1070
- addReviewCommentRequest .Params .Name = "add_pull_request_review_comment_to_pending_review"
1071
- addReviewCommentRequest .Params .Arguments = map [string ]any {
1068
+ // Add a file review comment
1069
+ addFileReviewCommentRequest := mcp.CallToolRequest {}
1070
+ addFileReviewCommentRequest .Params .Name = "add_pull_request_review_comment_to_pending_review"
1071
+ addFileReviewCommentRequest .Params .Arguments = map [string ]any {
1072
+ "owner" : currentOwner ,
1073
+ "repo" : repoName ,
1074
+ "pullNumber" : 1 ,
1075
+ "path" : "test-file.txt" ,
1076
+ "subjectType" : "FILE" ,
1077
+ "body" : "File review comment" ,
1078
+ }
1079
+
1080
+ t .Logf ("Adding file review comment to pull request in %s/%s..." , currentOwner , repoName )
1081
+ resp , err = mcpClient .CallTool (ctx , addFileReviewCommentRequest )
1082
+ require .NoError (t , err , "expected to call 'add_pull_request_review_comment_to_pending_review' tool successfully" )
1083
+ require .False (t , resp .IsError , fmt .Sprintf ("expected result not to be an error: %+v" , resp ))
1084
+
1085
+ // Add a single line review comment
1086
+ addSingleLineReviewCommentRequest := mcp.CallToolRequest {}
1087
+ addSingleLineReviewCommentRequest .Params .Name = "add_pull_request_review_comment_to_pending_review"
1088
+ addSingleLineReviewCommentRequest .Params .Arguments = map [string ]any {
1072
1089
"owner" : currentOwner ,
1073
1090
"repo" : repoName ,
1074
1091
"pullNumber" : 1 ,
1075
1092
"path" : "test-file.txt" ,
1076
1093
"subjectType" : "LINE" ,
1077
- "body" : "Very nice! " ,
1094
+ "body" : "Single line review comment " ,
1078
1095
"line" : 1 ,
1096
+ "side" : "RIGHT" ,
1097
+ "commitId" : commitId ,
1079
1098
}
1080
1099
1081
- t .Logf ("Adding review comment to pull request in %s/%s..." , currentOwner , repoName )
1082
- resp , err = mcpClient .CallTool (ctx , addReviewCommentRequest )
1100
+ t .Logf ("Adding single line review comment to pull request in %s/%s..." , currentOwner , repoName )
1101
+ resp , err = mcpClient .CallTool (ctx , addSingleLineReviewCommentRequest )
1102
+ require .NoError (t , err , "expected to call 'add_pull_request_review_comment_to_pending_review' tool successfully" )
1103
+ require .False (t , resp .IsError , fmt .Sprintf ("expected result not to be an error: %+v" , resp ))
1104
+
1105
+ // Add a multiline review comment
1106
+ addMultilineReviewCommentRequest := mcp.CallToolRequest {}
1107
+ addMultilineReviewCommentRequest .Params .Name = "add_pull_request_review_comment_to_pending_review"
1108
+ addMultilineReviewCommentRequest .Params .Arguments = map [string ]any {
1109
+ "owner" : currentOwner ,
1110
+ "repo" : repoName ,
1111
+ "pullNumber" : 1 ,
1112
+ "path" : "test-file.txt" ,
1113
+ "subjectType" : "LINE" ,
1114
+ "body" : "Multiline review comment" ,
1115
+ "startLine" : 1 ,
1116
+ "line" : 2 ,
1117
+ "startSide" : "RIGHT" ,
1118
+ "side" : "RIGHT" ,
1119
+ "commitId" : commitId ,
1120
+ }
1121
+
1122
+ t .Logf ("Adding multi line review comment to pull request in %s/%s..." , currentOwner , repoName )
1123
+ resp , err = mcpClient .CallTool (ctx , addMultilineReviewCommentRequest )
1083
1124
require .NoError (t , err , "expected to call 'add_pull_request_review_comment_to_pending_review' tool successfully" )
1084
1125
require .False (t , resp .IsError , fmt .Sprintf ("expected result not to be an error: %+v" , resp ))
1085
1126
@@ -1117,6 +1158,7 @@ func TestPullRequestReviewCommentSubmit(t *testing.T) {
1117
1158
require .True (t , ok , "expected content to be of type TextContent" )
1118
1159
1119
1160
var reviews []struct {
1161
+ ID int `json:"id"`
1120
1162
State string `json:"state"`
1121
1163
}
1122
1164
err = json .Unmarshal ([]byte (textContent .Text ), & reviews )
@@ -1125,6 +1167,13 @@ func TestPullRequestReviewCommentSubmit(t *testing.T) {
1125
1167
// Check that there is one review
1126
1168
require .Len (t , reviews , 1 , "expected to find one review" )
1127
1169
require .Equal (t , "COMMENTED" , reviews [0 ].State , "expected review state to be COMMENTED" )
1170
+
1171
+ // Check that there are three review comments
1172
+ // MCP Server doesn't support this, but we can use the GitHub Client
1173
+ ghClient := gogithub .NewClient (nil ).WithAuthToken (getE2EToken (t ))
1174
+ comments , _ , err := ghClient .PullRequests .ListReviewComments (context .Background (), currentOwner , repoName , 1 , int64 (reviews [0 ].ID ), nil )
1175
+ require .NoError (t , err , "expected to list review comments successfully" )
1176
+ require .Equal (t , 3 , len (comments ), "expected to find three review comments" )
1128
1177
}
1129
1178
1130
1179
func TestPullRequestReviewDeletion (t * testing.T ) {
@@ -1314,5 +1363,4 @@ func TestPullRequestReviewDeletion(t *testing.T) {
1314
1363
err = json .Unmarshal ([]byte (textContent .Text ), & noReviews )
1315
1364
require .NoError (t , err , "expected to unmarshal text content successfully" )
1316
1365
require .Len (t , noReviews , 0 , "expected to find no reviews" )
1317
-
1318
1366
}
0 commit comments