Skip to content

Commit b858ce1

Browse files
authored
feat: Add link to GitHub Notifications page (#473)
1 parent 1a02658 commit b858ce1

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

src/components/Sidebar.test.tsx

+24-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,27 @@ describe('components/Sidebar.tsx', () => {
8282
expect(pushMock).toHaveBeenCalledTimes(1);
8383
});
8484

85-
it('open the gitify repo in browser', () => {
85+
it('opens github in the notifications page', () => {
86+
const { getByLabelText } = render(
87+
<AppContext.Provider
88+
value={{
89+
isLoggedIn: true,
90+
notifications: mockedAccountNotifications,
91+
}}
92+
>
93+
<MemoryRouter>
94+
<Sidebar />
95+
</MemoryRouter>
96+
</AppContext.Provider>
97+
);
98+
fireEvent.click(getByLabelText('4 Unread Notifications'));
99+
expect(shell.openExternal).toHaveBeenCalledTimes(1);
100+
expect(shell.openExternal).toHaveBeenCalledWith(
101+
'https://github.com/notifications'
102+
);
103+
});
104+
105+
it('opens the gitify repo in browser', () => {
86106
const { getByLabelText } = render(
87107
<AppContext.Provider value={{ isLoggedIn: true, notifications: [] }}>
88108
<MemoryRouter>
@@ -92,5 +112,8 @@ describe('components/Sidebar.tsx', () => {
92112
);
93113
fireEvent.click(getByLabelText('View project on GitHub'));
94114
expect(shell.openExternal).toHaveBeenCalledTimes(1);
115+
expect(shell.openExternal).toHaveBeenCalledWith(
116+
'https://github.com/manosim/gitify'
117+
);
95118
});
96119
});

src/components/Sidebar.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export const Sidebar: React.FC = () => {
2020
shell.openExternal(`https://github.com/${Constants.REPO_SLUG}`);
2121
}, []);
2222

23+
const onOpenGitHubNotifications = useCallback(() => {
24+
shell.openExternal(`https://github.com/notifications`);
25+
}, []);
26+
2327
const quitApp = useCallback(() => {
2428
ipcRenderer.send('app-quit');
2529
}, []);
@@ -43,7 +47,11 @@ export const Sidebar: React.FC = () => {
4347
/>
4448

4549
{notificationsCount > 0 && (
46-
<div className="flex justify-around self-stretch items-center my-1 py-1 px-2 text-green-500 text-xs font-extrabold">
50+
<div
51+
className="flex justify-around self-stretch items-center my-1 py-1 px-2 text-green-500 text-xs font-extrabold cursor-pointer"
52+
onClick={onOpenGitHubNotifications}
53+
aria-label={`${notificationsCount} Unread Notifications`}
54+
>
4755
<Octicons.BellIcon size={12} />
4856
{notificationsCount}
4957
</div>

src/components/__snapshots__/Sidebar.test.tsx.snap

+6-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ exports[`components/Sidebar.tsx should render itself & its children (logged in)
5252
</g>
5353
</svg>
5454
<div
55-
className="flex justify-around self-stretch items-center my-1 py-1 px-2 text-green-500 text-xs font-extrabold"
55+
aria-label="4 Unread Notifications"
56+
className="flex justify-around self-stretch items-center my-1 py-1 px-2 text-green-500 text-xs font-extrabold cursor-pointer"
57+
onClick={[Function]}
5658
>
5759
<svg
5860
aria-hidden="true"
@@ -195,7 +197,9 @@ exports[`components/Sidebar.tsx should render itself & its children (logged out)
195197
</g>
196198
</svg>
197199
<div
198-
className="flex justify-around self-stretch items-center my-1 py-1 px-2 text-green-500 text-xs font-extrabold"
200+
aria-label="4 Unread Notifications"
201+
className="flex justify-around self-stretch items-center my-1 py-1 px-2 text-green-500 text-xs font-extrabold cursor-pointer"
202+
onClick={[Function]}
199203
>
200204
<svg
201205
aria-hidden="true"

0 commit comments

Comments
 (0)