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
1 change: 1 addition & 0 deletions src/__mocks__/state-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const mockSettings: SettingsState = {
showAccountHostname: false,
delayNotificationState: false,
showPills: true,
showNumber: true,
keyboardShortcut: true,
groupBy: GroupBy.REPOSITORY,
filterReasons: [],
Expand Down
20 changes: 20 additions & 0 deletions src/components/NotificationRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ describe('components/NotificationRow.tsx', () => {
expect(tree).toMatchSnapshot();
});

it('should render itself & its children - hide numbers', async () => {
jest
.spyOn(global.Date, 'now')
.mockImplementation(() => new Date('2024').valueOf());

const props = {
notification: mockSingleNotification,
account: mockGitHubCloudAccount,
};

const tree = render(
<AppContext.Provider
value={{ settings: { ...mockSettings, showNumber: false } }}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});

describe('notification interactions', () => {
it('should open a notification in the browser - click', () => {
const removeNotificationFromState = jest.fn();
Expand Down
18 changes: 17 additions & 1 deletion src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ export const NotificationRow: FC<INotificationRow> = ({
notification.subject.type,
]);

const notificationNumber = notification.subject?.number
? `#${notification.subject.number}`
: '';

const notificationTitle =
`${notification.subject.title} ${notificationNumber}`.trim();

const groupByDate = settings.groupBy === 'DATE';

return (
Expand Down Expand Up @@ -102,9 +109,18 @@ export const NotificationRow: FC<INotificationRow> = ({
<div
className="mb-1 truncate text-sm"
role="main"
title={notification.subject.title}
title={notificationTitle}
>
{notification.subject.title}
<span
className={cn(
'text-xxs ml-1',
Opacity.READ,
!settings.showNumber && 'hidden',
)}
>
{notificationNumber}
</span>
</div>

<NotificationFooter notification={notification} />
Expand Down
12 changes: 12 additions & 0 deletions src/components/__snapshots__/AccountNotifications.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading