Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 29 additions & 0 deletions src/utils/subject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,35 @@ describe('utils/subject.ts', () => {
});
});

it('avoid fetching comments if latest_comment_url and url are the same', async () => {
mockNotification.subject.latest_comment_url =
mockNotification.subject.url;

nock('https://api.github.com')
.get('/repos/gitify-app/notifications-test/pulls/1')
.reply(200, {
state: 'open',
draft: false,
merged: false,
user: mockAuthor,
});

const result = await getGitifySubjectDetails(
mockNotification,
mockAccounts.token,
);

expect(result).toEqual({
state: 'open',
user: {
login: mockAuthor.login,
html_url: mockAuthor.html_url,
avatar_url: mockAuthor.avatar_url,
type: mockAuthor.type,
},
});
});

it('handle pull request without latest_comment_url', async () => {
mockNotification.subject.latest_comment_url = null;

Expand Down
5 changes: 4 additions & 1 deletion src/utils/subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ async function getGitifySubjectForPullRequest(

let prCommentUser: User;

if (notification.subject.latest_comment_url) {
if (
notification.subject.latest_comment_url &&
notification.subject.latest_comment_url !== notification.subject.url
) {
const prComment = (
await getIssueOrPullRequestComment(
notification.subject.latest_comment_url,
Expand Down