mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-04-24 06:38:50 +00:00
Fix: Ignore other users' comments (#332)
Make findPreviousComment only return comments made by the current user (usually github-actions[bot])
This commit is contained in:
parent
2020b5bc34
commit
65b0a353cc
5 changed files with 309 additions and 283 deletions
|
|
@ -16,45 +16,51 @@ const repo = {
|
|||
repo: "sticky-pull-request-comment"
|
||||
}
|
||||
it("findPreviousComment", async () => {
|
||||
const authenticatedUser = {
|
||||
login: "github-actions[bot]"
|
||||
}
|
||||
const otherUser = {
|
||||
login: "some-user"
|
||||
}
|
||||
const comment = {
|
||||
user: {
|
||||
login: "github-actions[bot]"
|
||||
},
|
||||
user: authenticatedUser,
|
||||
body: "previous message\n<!-- Sticky Pull Request Comment -->"
|
||||
}
|
||||
const commentWithCustomHeader = {
|
||||
user: {
|
||||
login: "github-actions[bot]"
|
||||
},
|
||||
user: authenticatedUser,
|
||||
body: "previous message\n<!-- Sticky Pull Request CommentTypeA -->"
|
||||
}
|
||||
const headerFirstComment = {
|
||||
user: {
|
||||
login: "github-actions[bot]"
|
||||
},
|
||||
user: authenticatedUser,
|
||||
body: "<!-- Sticky Pull Request CommentLegacyComment -->\nheader first message"
|
||||
}
|
||||
const otherUserComment = {
|
||||
user: otherUser,
|
||||
body: "Fake previous message\n<!-- Sticky Pull Request Comment -->"
|
||||
}
|
||||
const otherComments = [
|
||||
{
|
||||
user: {
|
||||
login: "some-user"
|
||||
},
|
||||
user: otherUser,
|
||||
body: "lgtm"
|
||||
},
|
||||
{
|
||||
user: {
|
||||
login: "github-actions[bot]"
|
||||
},
|
||||
user: authenticatedUser,
|
||||
body: "previous message\n<!-- Sticky Pull Request CommentTypeB -->"
|
||||
}
|
||||
]
|
||||
const octokit: any = {
|
||||
graphql: jest.fn(() =>
|
||||
Promise.resolve({
|
||||
viewer: authenticatedUser
|
||||
})
|
||||
),
|
||||
rest: {
|
||||
issues: {
|
||||
listComments: jest.fn(() =>
|
||||
Promise.resolve({
|
||||
data: [
|
||||
commentWithCustomHeader,
|
||||
otherUserComment,
|
||||
comment,
|
||||
headerFirstComment,
|
||||
...otherComments
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue