Skip to content

refactor: remove now redundant mark as read on click functionality #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
50 changes: 0 additions & 50 deletions src/components/NotificationRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,56 +54,6 @@ describe('components/Notification.js', () => {
expect(shell.openExternal).toHaveBeenCalledTimes(1);
});

it('should open a notification in browser & mark it as read', () => {
const markNotification = jest.fn();

const props = {
notification: mockedSingleNotification,
hostname: 'github.com',
};

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

fireEvent.click(getByRole('main'));
expect(shell.openExternal).toHaveBeenCalledTimes(1);
expect(markNotification).toHaveBeenCalledTimes(1);
});

it('should mark a notification as read', () => {
const markNotification = jest.fn();

const props = {
notification: mockedSingleNotification,
hostname: 'github.com',
};

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

fireEvent.click(getByTitle('Mark as Read'));
expect(markNotification).toHaveBeenCalledTimes(1);
});

it('should unsubscribe from a notification thread', () => {
const unsubscribeNotification = jest.fn();

Expand Down
16 changes: 1 addition & 15 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useContext } from 'react';
import { formatDistanceToNow, parseISO } from 'date-fns';
import { CheckIcon, MuteIcon } from '@primer/octicons-react';
import { MuteIcon } from '@primer/octicons-react';

import {
formatReason,
Expand Down Expand Up @@ -84,20 +84,6 @@ export const NotificationRow: React.FC<IProps> = ({
</button>
</div>
</div>

<div className="flex justify-center items-center w-8">
<button
className="focus:outline-none"
title="Mark as Read"
onClick={() => markNotification(notification.id, hostname)}
>
<CheckIcon
className="hover:text-green-500"
size={20}
aria-label="Mark as Read"
/>
</button>
</div>
</div>
);
};
33 changes: 0 additions & 33 deletions src/components/__snapshots__/NotificationRow.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,5 @@ exports[`components/Notification.js should render itself & its children 1`] = `
</button>
</div>
</div>
<div
className="flex justify-center items-center w-8"
>
<button
className="focus:outline-none"
onClick={[Function]}
title="Mark as Read"
>
<svg
aria-hidden="false"
aria-label="Mark as Read"
className="hover:text-green-500"
fill="currentColor"
focusable="false"
height={20}
role="img"
style={
{
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
}
viewBox="0 0 16 16"
width={20}
>
<path
d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"
/>
</svg>
</button>
</div>
</div>
`;
28 changes: 0 additions & 28 deletions src/routes/Settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,34 +182,6 @@ describe('routes/Settings.tsx', () => {
expect(updateSetting).toHaveBeenCalledWith('showNotifications', false);
});

it('should toggle the onClickMarkAsRead checkbox', async () => {
let getByLabelText;

await act(async () => {
const { getByLabelText: getByLabelTextLocal } = render(
<AppContext.Provider
value={{
settings: mockSettings,
accounts: mockAccounts,
updateSetting,
}}
>
<MemoryRouter>
<SettingsRoute />
</MemoryRouter>
</AppContext.Provider>,
);
getByLabelText = getByLabelTextLocal;
});

fireEvent.click(getByLabelText('Mark as read on click'), {
target: { checked: true },
});

expect(updateSetting).toHaveBeenCalledTimes(1);
expect(updateSetting).toHaveBeenCalledWith('markOnClick', false);
});

it('should toggle the openAtStartup checkbox', async () => {
let getByLabelText;

Expand Down
6 changes: 0 additions & 6 deletions src/routes/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ export const SettingsRoute: React.FC = () => {
updateSetting('showNotifications', evt.target.checked)
}
/>
<FieldCheckbox
name="onClickMarkAsRead"
label="Mark as read on click"
checked={settings.markOnClick}
onChange={(evt) => updateSetting('markOnClick', evt.target.checked)}
/>
{!isLinux && (
<FieldCheckbox
name="openAtStartUp"
Expand Down
23 changes: 0 additions & 23 deletions src/routes/__snapshots__/Settings.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,6 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = `
</label>
</div>
</div>
<div
class="flex items-start mt-1 mb-3"
>
<div
class="flex items-center h-5"
>
<input
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded"
id="onClickMarkAsRead"
type="checkbox"
/>
</div>
<div
class="ml-3 text-sm"
>
<label
class="font-medium text-gray-700 dark:text-gray-200"
for="onClickMarkAsRead"
>
Mark as read on click
</label>
</div>
</div>
<div
class="flex items-start mt-1 mb-3"
>
Expand Down