Skip to content

Commit c273335

Browse files
committed
feat(url): improve fallback url handling
Signed-off-by: Adam Setch <[email protected]>
1 parent c6422c4 commit c273335

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

src/renderer/utils/api/__mocks__/response-mocks.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -418,27 +418,26 @@ export const mockDiscussionLabels: DiscussionLabels = {
418418
],
419419
};
420420

421+
export const mockDiscussion: Discussion = {
422+
number: 123,
423+
title: '1.16.0',
424+
isAnswered: false,
425+
stateReason: 'OPEN',
426+
url: 'https://github.com/gitify-app/notifications-test/discussions/612' as Link,
427+
author: {
428+
login: 'discussion-creator',
429+
url: 'https://github.com/discussion-creator' as Link,
430+
avatar_url: 'https://avatars.githubusercontent.com/u/123456789?v=4' as Link,
431+
type: 'User',
432+
},
433+
comments: mockDiscussionComments,
434+
labels: mockDiscussionLabels,
435+
};
436+
421437
export const mockSearchDiscussionsGraphQLResponse: GraphQLSearch<Discussion> = {
422438
data: {
423439
search: {
424-
nodes: [
425-
{
426-
number: 123,
427-
title: '1.16.0',
428-
isAnswered: false,
429-
stateReason: 'OPEN',
430-
url: 'https://github.com/gitify-app/notifications-test/discussions/612' as Link,
431-
author: {
432-
login: 'discussion-creator',
433-
url: 'https://github.com/discussion-creator' as Link,
434-
avatar_url:
435-
'https://avatars.githubusercontent.com/u/123456789?v=4' as Link,
436-
type: 'User',
437-
},
438-
comments: mockDiscussionComments,
439-
labels: mockDiscussionLabels,
440-
},
441-
],
440+
nodes: [mockDiscussion],
442441
},
443442
},
444443
};

src/renderer/utils/api/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,6 @@ export async function getLatestDiscussion(
284284
notification,
285285
);
286286
}
287+
288+
return null;
287289
}

src/renderer/utils/helpers.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { Hostname, Link } from '../types';
88
import type { SubjectType } from '../typesGitHub';
99
import * as logger from '../utils/logger';
1010
import {
11-
mockSearchDiscussionsGraphQLResponse,
11+
mockDiscussion,
1212
mockSingleNotification,
1313
} from './api/__mocks__/response-mocks';
1414
import * as apiClient from './api/client';
@@ -283,9 +283,7 @@ describe('renderer/utils/helpers.ts', () => {
283283
type: 'Discussion' as SubjectType,
284284
};
285285

286-
getLatestDiscussionSpy.mockResolvedValue(
287-
mockSearchDiscussionsGraphQLResponse[0],
288-
);
286+
getLatestDiscussionSpy.mockResolvedValue(mockDiscussion);
289287

290288
const result = await generateGitHubWebUrl({
291289
...mockSingleNotification,
@@ -475,7 +473,7 @@ describe('renderer/utils/helpers.ts', () => {
475473
subject: subject,
476474
});
477475

478-
expect(getHtmlUrlSpy).toHaveBeenCalledTimes(0);
476+
expect(getHtmlUrlSpy).toHaveBeenCalledTimes(1);
479477
expect(result).toBe(
480478
`https://github.com/gitify-app/notifications-test/issues?${mockNotificationReferrer}`,
481479
);

0 commit comments

Comments
 (0)