Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 22 additions & 0 deletions src/__mocks__/mockedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-20T18:33:39Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -310,6 +311,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-21T03:30:42Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -321,6 +323,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-21T18:26:27Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -330,6 +333,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-23T00:57:58Z',
author: {
login: 'reply-user',
url: 'https://github.com/reply-user',
type: 'User',
},
},
Expand All @@ -341,6 +345,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-23T00:57:49Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -352,6 +357,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-27T01:22:20Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -361,6 +367,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-05T17:43:52Z',
author: {
login: 'reply-user',
url: 'https://github.com/reply-user',
type: 'User',
},
},
Expand All @@ -372,6 +379,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-04T20:39:44Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -381,6 +389,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-05T17:41:04Z',
author: {
login: 'reply-user',
url: 'https://github.com/reply-user',
type: 'User',
},
},
Expand All @@ -392,6 +401,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-05T11:05:42Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -401,6 +411,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-05T17:41:44Z',
author: {
login: 'reply-user',
url: 'https://github.com/reply-user',
type: 'User',
},
},
Expand All @@ -423,6 +434,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-20T18:33:39Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -434,6 +446,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-21T03:30:42Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -445,6 +458,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-21T18:26:27Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -454,6 +468,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-23T00:57:58Z',
author: {
login: 'reply-user',
url: 'https://github.com/reply-user',
type: 'User',
},
},
Expand All @@ -465,6 +480,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-23T00:57:49Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -476,6 +492,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-02-27T01:22:20Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -485,6 +502,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-05T17:43:52Z',
author: {
login: 'reply-user',
url: 'https://github.com/reply-user',
type: 'User',
},
},
Expand All @@ -496,6 +514,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-04T20:39:44Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -505,6 +524,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-05T17:41:04Z',
author: {
login: 'reply-user',
url: 'https://github.com/reply-user',
type: 'User',
},
},
Expand All @@ -516,6 +536,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-05T11:05:42Z',
author: {
login: 'comment-user',
url: 'https://github.com/comment-user',
type: 'User',
},
replies: {
Expand All @@ -525,6 +546,7 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
createdAt: '2022-03-05T17:41:44Z',
author: {
login: 'reply-user',
url: 'https://github.com/reply-user',
type: 'User',
},
},
Expand Down
32 changes: 32 additions & 0 deletions src/components/NotificationRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AppContext } from '../context/App';
import { mockedSingleNotification } from '../__mocks__/mockedData';
import { NotificationRow } from './NotificationRow';
import { mockAccounts, mockSettings } from '../__mocks__/mock-state';
import { shell } from 'electron';

describe('components/NotificationRow.tsx', () => {
beforeEach(() => {
Expand Down Expand Up @@ -148,4 +149,35 @@ describe('components/NotificationRow.tsx', () => {
fireEvent.click(getByTitle('Unsubscribe'));
expect(unsubscribeNotification).toHaveBeenCalledTimes(1);
});

it('should open notification user profile', () => {
const props = {
notification: {
...mockedSingleNotification,
subject: {
...mockedSingleNotification.subject,
user: {
login: 'some-user',
html_url: 'https://github.com/some-user',
type: 'User',
},
},
},
hostname: 'github.com',
};

const { getByTitle } = render(
<AppContext.Provider
value={{
settings: { ...mockSettings },
accounts: mockAccounts,
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);

fireEvent.click(getByTitle('View User Profile'));
expect(shell.openExternal).toHaveBeenCalledTimes(1);
});
});
30 changes: 23 additions & 7 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { formatForDisplay, openInBrowser } from '../utils/helpers';
import { Notification } from '../typesGithub';
import { AppContext } from '../context/App';
import { openExternalLink } from '../utils/comms';

interface IProps {
hostname: string;
Expand Down Expand Up @@ -79,21 +80,36 @@ export const NotificationRow: React.FC<IProps> = ({
<NotificationIcon size={18} aria-label={notification.subject.type} />
</div>

<div
className="flex-1 overflow-hidden cursor-pointer"
onClick={() => pressTitle()}
role="main"
>
<div className="flex-1 overflow-hidden">
<div
className="mb-1 text-sm whitespace-nowrap overflow-ellipsis overflow-hidden"
className="mb-1 text-sm whitespace-nowrap overflow-ellipsis overflow-hidden cursor-pointer"
role="main"
onClick={() => pressTitle()}
title={notification.subject.title}
>
{notification.subject.title}
</div>

<div className="text-xs text-capitalize whitespace-nowrap overflow-ellipsis overflow-hidden">
<span title={reason.description}>{reason.type}</span> -{' '}
<span title={updatedLabel}>{updatedLabel}</span>
<span title={updatedLabel}>
Updated {updatedAt}
{notification.subject.user && (
<>
{' '}
by{' '}
<span
className="cursor-pointer"
title="View User Profile"
onClick={() =>
openExternalLink(notification.subject.user.html_url)
}
>
{notification.subject.user.login}
</span>
</>
)}
</span>
</div>
</div>

Expand Down
11 changes: 6 additions & 5 deletions src/components/__snapshots__/NotificationRow.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`]
</svg>
</div>
<div
className="flex-1 overflow-hidden cursor-pointer"
onClick={[Function]}
role="main"
className="flex-1 overflow-hidden"
>
<div
className="mb-1 text-sm whitespace-nowrap overflow-ellipsis overflow-hidden"
className="mb-1 text-sm whitespace-nowrap overflow-ellipsis overflow-hidden cursor-pointer"
onClick={[Function]}
role="main"
title="I am a robot and this is a test!"
>
I am a robot and this is a test!
Expand All @@ -58,7 +58,8 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`]
<span
title="Updated in over 3 years"
>
Updated in over 3 years
Updated
in over 3 years
</span>
</div>
</div>
Expand Down
18 changes: 16 additions & 2 deletions src/hooks/useNotifications.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,25 +308,39 @@ describe('hooks/useNotifications.ts', () => {
merged: true,
user: {
login: 'some-user',
html_url: 'https://github.com/some-user',
type: 'User',
},
});
nock('https://api.github.com')
.get('/3/comments')
.reply(200, { user: { login: 'some-commenter', type: 'User' } });
.reply(200, {
user: {
login: 'some-commenter',
html_url: 'https://github.com/some-commenter',
type: 'User',
},
});
nock('https://api.github.com')
.get('/4')
.reply(200, {
state: 'closed',
merged: false,
user: {
login: 'some-user',
html_url: 'https://github.com/some-user',
type: 'User',
},
});
nock('https://api.github.com')
.get('/4/comments')
.reply(200, { user: { login: 'some-commenter', type: 'User' } });
.reply(200, {
user: {
login: 'some-commenter',
html_url: 'https://github.com/some-commenter',
type: 'User',
},
});

const { result } = renderHook(() => useNotifications(true));

Expand Down
2 changes: 2 additions & 0 deletions src/typesGithub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ export interface User {

export interface SubjectUser {
login: string;
html_url: string;
type: string;
}

export interface DiscussionAuthor {
login: string;
url: string;
type: string;
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export async function fetchDiscussion(
createdAt
author {
login
url
type
}
}
Expand Down
Loading