diff --git a/src/renderer/__mocks__/notifications-mocks.ts b/src/renderer/__mocks__/notifications-mocks.ts index 501e5c85a..48a7fbe2d 100644 --- a/src/renderer/__mocks__/notifications-mocks.ts +++ b/src/renderer/__mocks__/notifications-mocks.ts @@ -1,6 +1,7 @@ import { AgentIcon, CopilotIcon, + GitCommitIcon, GitPullRequestIcon, IssueOpenedIcon, TagIcon, @@ -93,7 +94,7 @@ export const mockGitHubCloudGitifyNotifications: GitifyNotification[] = [ }, repository: mockGitHubRepository, display: { - number: '123', + identifier: '123', title: 'I am a robot and this is a test! [#123]', type: 'Open Issue', icon: { @@ -124,7 +125,7 @@ export const mockGitHubCloudGitifyNotifications: GitifyNotification[] = [ }, repository: mockGitHubRepository, display: { - number: '456', + identifier: '456', title: 'Improve the UI [#456]', type: 'Issue', icon: { @@ -175,10 +176,11 @@ export const mockGithubEnterpriseGitifyNotifications: GitifyNotification[] = [ 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/releases/3' as Link, type: 'Release', reviewers: undefined, + tagName: '0.0.1', }, repository: mockEnterpriseRepository, display: { - number: '', + identifier: '0.0.1', title: 'Release 0.0.1', type: 'Release', icon: { @@ -209,7 +211,7 @@ export const mockGithubEnterpriseGitifyNotifications: GitifyNotification[] = [ }, repository: mockEnterpriseRepository, display: { - number: '123', + identifier: '123', title: 'Bump Version [#123]', type: 'Pull Request', icon: { @@ -223,6 +225,44 @@ export const mockGithubEnterpriseGitifyNotifications: GitifyNotification[] = [ export const mockGitifyNotification: GitifyNotification = mockGitHubCloudGitifyNotifications[0]; +/** + * Mock Gitify Notification for a GitHub commit. + * + * Subject type `Commit`, which identifies by its SHA rather than a number. + */ +export const mockCommitGitifyNotification: GitifyNotification = { + account: mockGitHubCloudAccount, + order: 0, + id: '1349837581', + unread: true, + reason: { + code: 'subscribed', + title: 'Updated', + description: "You're watching the repository.", + }, + updatedAt: '2024-03-12T10:00:00Z', + subject: { + title: 'Fix the thing', + url: 'https://api.github.com/repos/gitify-app/notifications-test/commits/d2a86d80e3d24ea9510d5de6c147e53c30f313a8' as Link, + latestCommentUrl: null, + type: 'Commit', + commitSha: 'd2a86d80e3d24ea9510d5de6c147e53c30f313a8', + user: mockSubjectUser, + author: mockSubjectUser, + }, + repository: mockGitHubRepository, + display: { + identifier: 'd2a86d8', + title: 'Fix the thing', + type: 'Commit', + icon: { + type: GitCommitIcon, + color: IconColor.GRAY, + }, + defaultUserType: 'User', + }, +}; + /** * Mock Gitify Notification for a GitHub Copilot cloud agent session. * @@ -248,7 +288,7 @@ export const mockAgentSessionGitifyNotification: GitifyNotification = { }, repository: mockGitHubRepository, display: { - number: '', + identifier: '', title: 'Analyzing and fixing GitHub Actions job failure', type: 'Agent Session Thread', icon: { diff --git a/src/renderer/components/notifications/NotificationHeader.tsx b/src/renderer/components/notifications/NotificationHeader.tsx index 94ee086ba..aeaedd95d 100644 --- a/src/renderer/components/notifications/NotificationHeader.tsx +++ b/src/renderer/components/notifications/NotificationHeader.tsx @@ -45,7 +45,7 @@ export const NotificationHeader: FC = ({ />
- {notification.display.number} + {notification.display.identifier}
diff --git a/src/renderer/components/notifications/NotificationRow.test.tsx b/src/renderer/components/notifications/NotificationRow.test.tsx index 830f7489e..998876bc8 100644 --- a/src/renderer/components/notifications/NotificationRow.test.tsx +++ b/src/renderer/components/notifications/NotificationRow.test.tsx @@ -5,6 +5,7 @@ import { useState } from 'react'; import { renderWithProviders } from '../../__helpers__/test-utils'; import { mockGitHubEnterpriseServerAccount } from '../../__mocks__/account-mocks'; import { + mockCommitGitifyNotification, mockGiteaGitifyNotification, mockGitifyNotification, } from '../../__mocks__/notifications-mocks'; @@ -81,6 +82,32 @@ describe('renderer/components/notifications/NotificationRow.tsx', () => { expect(tree.container).toMatchSnapshot(); }); + it('shows the release tag as the identifier', () => { + const props: NotificationRowProps = { + notification: { + ...mockGitifyNotification, + subject: { ...mockGitifyNotification.subject, type: 'Release', tagName: '0.0.1' }, + display: { ...mockGitifyNotification.display, identifier: '0.0.1' }, + }, + isRepositoryAnimatingExit: false, + }; + + const tree = renderWithProviders(); + + expect(tree.getByText('0.0.1')).toBeInTheDocument(); + }); + + it('shows the commit short SHA as the identifier', () => { + const props: NotificationRowProps = { + notification: mockCommitGitifyNotification, + isRepositoryAnimatingExit: false, + }; + + const tree = renderWithProviders(); + + expect(tree.getByText('d2a86d8')).toBeInTheDocument(); + }); + it('should render itself & its children - notification is read', async () => { const props: NotificationRowProps = { notification: { ...mockGitifyNotification, unread: false }, diff --git a/src/renderer/components/notifications/NotificationRow.tsx b/src/renderer/components/notifications/NotificationRow.tsx index c5623529b..23a35b647 100644 --- a/src/renderer/components/notifications/NotificationRow.tsx +++ b/src/renderer/components/notifications/NotificationRow.tsx @@ -146,7 +146,7 @@ export const NotificationRow: FC = ({ (isGroupByDate() || !showNumber) && 'hidden', )} > - {notification.display.number} + {notification.display.identifier} diff --git a/src/renderer/components/notifications/__snapshots__/NotificationRow.test.tsx.snap b/src/renderer/components/notifications/__snapshots__/NotificationRow.test.tsx.snap index e4658d282..3e1c41d82 100644 --- a/src/renderer/components/notifications/__snapshots__/NotificationRow.test.tsx.snap +++ b/src/renderer/components/notifications/__snapshots__/NotificationRow.test.tsx.snap @@ -1223,7 +1223,7 @@ exports[`renderer/components/notifications/NotificationRow.tsx > should render i data-wrap="nowrap" >