diff --git a/client-templates/github-com/accept.json.sample b/client-templates/github-com/accept.json.sample index ff1371fab..3c29d91bf 100644 --- a/client-templates/github-com/accept.json.sample +++ b/client-templates/github-com/accept.json.sample @@ -2118,6 +2118,24 @@ "method": "POST", "path": "/graphql", "origin": "https://${GITHUB_TOKEN}@${GITHUB_GRAPHQL}" + }, + { + "//": "create a general pull request comment", + "method": "POST", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "update a general pull request comment", + "method": "PATCH", + "path": "/repos/:name/:repo/issues/comments/:commentId", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "create a pull request review", + "method": "POST", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" } ] } diff --git a/client-templates/github-enterprise/accept.json.sample b/client-templates/github-enterprise/accept.json.sample index 217d1b0ba..9475790b7 100644 --- a/client-templates/github-enterprise/accept.json.sample +++ b/client-templates/github-enterprise/accept.json.sample @@ -1398,6 +1398,24 @@ "method": "POST", "path": "/graphql", "origin": "https://${GITHUB_TOKEN}@${GITHUB_GRAPHQL}" + }, + { + "//": "create a general pull request comment", + "method": "POST", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "update a general pull request comment", + "method": "PATCH", + "path": "/repos/:name/:repo/issues/comments/:commentId", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "create a pull request review", + "method": "POST", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" } ] } diff --git a/client-templates/github-server-app/accept.json.sample b/client-templates/github-server-app/accept.json.sample index f6e5ce97e..046aa3712 100644 --- a/client-templates/github-server-app/accept.json.sample +++ b/client-templates/github-server-app/accept.json.sample @@ -1398,6 +1398,24 @@ "method": "POST", "path": "/graphql", "origin": "https://${GITHUB_GRAPHQL}" + }, + { + "//": "create a general pull request comment", + "method": "POST", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + "origin": "https://${GITHUB_API}" + }, + { + "//": "update a general pull request comment", + "method": "PATCH", + "path": "/repos/:name/:repo/issues/comments/:commentId", + "origin": "https://${GITHUB_API}" + }, + { + "//": "create a pull request review", + "method": "POST", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + "origin": "https://${GITHUB_API}" } ] } diff --git a/defaultFilters/github-enterprise.json b/defaultFilters/github-enterprise.json index e5875f4f9..ed3ffb0cc 100644 --- a/defaultFilters/github-enterprise.json +++ b/defaultFilters/github-enterprise.json @@ -1398,6 +1398,24 @@ "method": "POST", "path": "/graphql", "origin": "https://${GITHUB_TOKEN}@${GITHUB_GRAPHQL}" + }, + { + "//": "create a general pull request comment", + "method": "POST", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "update a general pull request comment", + "method": "PATCH", + "path": "/repos/:name/:repo/issues/comments/:commentId", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "create a pull request review", + "method": "POST", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" } ] } \ No newline at end of file diff --git a/defaultFilters/github-server-app.json b/defaultFilters/github-server-app.json index f45e119ca..f122e6df4 100644 --- a/defaultFilters/github-server-app.json +++ b/defaultFilters/github-server-app.json @@ -1992,6 +1992,36 @@ "scheme": "bearer", "token": "${GHSA_ACCESS_TOKEN}" } + }, + { + "//": "create a general pull request comment", + "method": "POST", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + "origin": "https://${GITHUB_API}", + "auth": { + "scheme": "bearer", + "token": "${GHSA_ACCESS_TOKEN}" + } + }, + { + "//": "update a general pull request comment", + "method": "PATCH", + "path": "/repos/:name/:repo/issues/comments/:commentId", + "origin": "https://${GITHUB_API}", + "auth": { + "scheme": "bearer", + "token": "${GHSA_ACCESS_TOKEN}" + } + }, + { + "//": "create a pull request review", + "method": "POST", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + "origin": "https://${GITHUB_API}", + "auth": { + "scheme": "bearer", + "token": "${GHSA_ACCESS_TOKEN}" + } } ] } \ No newline at end of file diff --git a/defaultFilters/github.json b/defaultFilters/github.json index fbdfc29ab..99324d501 100644 --- a/defaultFilters/github.json +++ b/defaultFilters/github.json @@ -2118,6 +2118,24 @@ "method": "POST", "path": "/graphql", "origin": "https://${GITHUB_TOKEN}@${GITHUB_GRAPHQL}" + }, + { + "//": "create a general pull request comment", + "method": "POST", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "update a general pull request comment", + "method": "PATCH", + "path": "/repos/:name/:repo/issues/comments/:commentId", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "create a pull request review", + "method": "POST", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" } ] } \ No newline at end of file diff --git a/test/fixtures/accept/github.json b/test/fixtures/accept/github.json index c4492fb27..f3164c67a 100644 --- a/test/fixtures/accept/github.json +++ b/test/fixtures/accept/github.json @@ -26,6 +26,24 @@ "values": ["application/vnd.github.v4.sha"] } ] + }, + { + "//": "create a general pull request comment", + "method": "POST", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "update a general pull request comment", + "method": "PATCH", + "path": "/repos/:name/:repo/issues/comments/:commentId", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" + }, + { + "//": "create a pull request review", + "method": "POST", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}" } ] } diff --git a/test/fixtures/client/github/graphql/find-pull-request-threads.txt b/test/fixtures/client/github/graphql/find-pull-request-threads.txt new file mode 100644 index 000000000..7ebe452eb --- /dev/null +++ b/test/fixtures/client/github/graphql/find-pull-request-threads.txt @@ -0,0 +1,25 @@ +{ + repository(owner: "test-org", name: "test-repo") { + pullRequest(number: 1) { + reviewThreads(first: 10) { + nodes { + id, + comments(first:1) { + nodes { + id, + pullRequestReview { + id + } + } + } + }, + pageInfo { + hasNextPage, + hasPreviousPage, + endCursor, + startCursor + } + } + } + } +} \ No newline at end of file diff --git a/test/fixtures/client/github/graphql/resolve-pull-request-thread.txt b/test/fixtures/client/github/graphql/resolve-pull-request-thread.txt new file mode 100644 index 000000000..b2a6e6e72 --- /dev/null +++ b/test/fixtures/client/github/graphql/resolve-pull-request-thread.txt @@ -0,0 +1,12 @@ +mutation + { + resolveReviewThread(input: { threadId: "thread_id" }) { + thread { + comments(first: 1) { + nodes { + id + } + } + } + } + } \ No newline at end of file diff --git a/test/fixtures/relay.json b/test/fixtures/relay.json index 895ab15f6..c10e3fc88 100644 --- a/test/fixtures/relay.json +++ b/test/fixtures/relay.json @@ -101,6 +101,16 @@ "//": "query to find open snyk pull requests, allowing auto dependency upgrade pull requests to open no more than a limited amount of pull requests", "path": "query", "regex": "{\\s*search\\(\\s*query: \"repo:[a-zA-Z0-9-_.]+\\/[a-zA-Z0-9-_.]+ is:pr state:[a-zA-Z]+ head:snyk-\\s*(is:[a-zA-Z]+)?\", type: ISSUE, last: [0-9]+\\s*\\)\\s*{\\s*edges {\\s*node {\\s*\\.\\.\\. on PullRequest {\\s*url\\s*title\\s*createdAt\\s*headRefName\\s*state\\s*mergeable\\s*body\\s*repository\\s*{\\s*name\\s*}\\s*}\\s*}\\s*}\\s*}\\s*rateLimit\\s*{\\s*limit\\s*cost\\s*remaining\\s*resetAt\\s*}\\s*}\\s*" + }, + { + "//": "query for pull request review threads", + "path": "query", + "regex": ".*{\\s*reviewThreads\\(first:\\s*\\d+\\)\\s*{.*" + }, + { + "//": "resolve pull request review thread", + "path": "query", + "regex": "mutation\\s*{\\s*resolveReviewThread\\(input:\\s*{\\s*threadId:\\s*\"[a-zA-Z0-9-_.]+\"\\s*}\\)\\s*{.*" } ] }, diff --git a/test/unit/__snapshots__/runtime-rules-hotloading.test.ts.snap b/test/unit/__snapshots__/runtime-rules-hotloading.test.ts.snap index d65955115..115464b0e 100644 --- a/test/unit/__snapshots__/runtime-rules-hotloading.test.ts.snap +++ b/test/unit/__snapshots__/runtime-rules-hotloading.test.ts.snap @@ -4211,6 +4211,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to get custom pull request template", "method": "GET", @@ -5629,6 +5647,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to get custom pull request template", "method": "GET", @@ -12182,6 +12218,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to get repo's teams list", "method": "GET", @@ -13648,6 +13702,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to get repo's teams list", "method": "GET", @@ -19996,6 +20068,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to get given manifest file", "method": "GET", @@ -21408,6 +21498,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to get given manifest file", "method": "GET", @@ -27765,6 +27873,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "allow info refs (for git clone)", "method": "GET", @@ -29189,6 +29315,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "allow info refs (for git clone)", "method": "GET", @@ -35622,6 +35766,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to scan IAC files", "method": "GET", @@ -37058,6 +37220,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to scan IAC files", "method": "GET", @@ -43469,6 +43649,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "allow info refs (for git clone)", "method": "GET", @@ -44893,6 +45091,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "allow info refs (for git clone)", "method": "GET", @@ -54076,6 +54292,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to scan IAC files", "method": "GET", @@ -56262,6 +56496,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to scan IAC files", "method": "GET", @@ -57692,6 +57944,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to scan IAC files", "method": "GET", @@ -59158,6 +59428,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, Object { "//": "used to scan IAC files", "method": "GET", @@ -67103,6 +67391,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, ], "public": Array [ Object { @@ -68509,6 +68815,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, ], "public": Array [ Object { @@ -74767,6 +75091,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, ], "public": Array [ Object { @@ -76173,6 +76515,24 @@ Object { "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_GRAPHQL}", "path": "/graphql", }, + Object { + "//": "create a general pull request comment", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/:issueNumber/comments", + }, + Object { + "//": "update a general pull request comment", + "method": "PATCH", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/issues/comments/:commentId", + }, + Object { + "//": "create a pull request review", + "method": "POST", + "origin": "https://\${GITHUB_TOKEN}@\${GITHUB_API}", + "path": "/repos/:name/:repo/pulls/:pullRef/reviews", + }, ], "public": Array [ Object { diff --git a/test/unit/filters.test.ts b/test/unit/filters.test.ts index 5b3e3515d..a61bec6da 100644 --- a/test/unit/filters.test.ts +++ b/test/unit/filters.test.ts @@ -45,6 +45,42 @@ describe('filters', () => { }); expect(filterResponse).toBeFalsy(); }); + + it('should allow creating a general pull request comment', () => { + const url = '/repos/test-org/test-repo/issues/1/comments'; + + const filterResponse = filter({ + url, + method: 'POST', + }); + expect(filterResponse).not.toEqual(false); + const filterResponseUrl = filterResponse ? filterResponse.url : ''; + expect(filterResponseUrl).toMatch(url); + }); + + it('should allow updating a general pull request comment', () => { + const url = '/repos/test-org/test-repo/issues/comments/12345'; + + const filterResponse = filter({ + url, + method: 'PATCH', + }); + expect(filterResponse).not.toEqual(false); + const filterResponseUrl = filterResponse ? filterResponse.url : ''; + expect(filterResponseUrl).toMatch(url); + }); + + it('should allow creating a pull request review', () => { + const url = '/repos/test-org/test-repo/pulls/:pullRef/reviews'; + + const filterResponse = filter({ + url, + method: 'POST', + }); + expect(filterResponse).not.toEqual(false); + const filterResponseUrl = filterResponse ? filterResponse.url : ''; + expect(filterResponseUrl).toMatch(url); + }); }); }); @@ -243,6 +279,36 @@ describe('filters', () => { const filterResponseUrl = filterResponse ? filterResponse.url : ''; expect(filterResponseUrl).toEqual('/graphql'); }); + + it('find pull request threads', () => { + const filterResponse = filter({ + url: '/graphql', + method: 'POST', + body: jsonBuffer({ + query: readFileSync( + __dirname + + '/../fixtures/client/github/graphql/find-pull-request-threads.txt', + ).toString('utf-8'), + }), + }); + const filterResponseUrl = filterResponse ? filterResponse.url : ''; + expect(filterResponseUrl).toEqual('/graphql'); + }); + + it('resolve pull request thread', () => { + const filterResponse = filter({ + url: '/graphql', + method: 'POST', + body: jsonBuffer({ + query: readFileSync( + __dirname + + '/../fixtures/client/github/graphql/resolve-pull-request-thread.txt', + ).toString('utf-8'), + }), + }); + const filterResponseUrl = filterResponse ? filterResponse.url : ''; + expect(filterResponseUrl).toEqual('/graphql'); + }); }); });