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
26 changes: 13 additions & 13 deletions src/renderer/components/GlobalShortcuts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ describe('components/GlobalShortcuts.tsx', () => {
});
});

describe('openGitHubNotifications', () => {
const openGitHubNotificationsSpy = vi
.spyOn(links, 'openGitHubNotifications')
describe('openHostNotifications', () => {
const openHostNotificationsSpy = vi
.spyOn(links, 'openHostNotifications')
.mockImplementation(vi.fn());

it('opens primary account GitHub notifications webpage when pressing N while logged in', async () => {
Expand All @@ -44,7 +44,7 @@ describe('components/GlobalShortcuts.tsx', () => {

await userEvent.keyboard('n');

expect(openGitHubNotificationsSpy).toHaveBeenCalledTimes(1);
expect(openHostNotificationsSpy).toHaveBeenCalledTimes(1);
});

it('does not open primary account GitHub notifications webpage when logged out', async () => {
Expand All @@ -54,7 +54,7 @@ describe('components/GlobalShortcuts.tsx', () => {

await userEvent.keyboard('n');

expect(openGitHubNotificationsSpy).not.toHaveBeenCalled();
expect(openHostNotificationsSpy).not.toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -116,8 +116,8 @@ describe('components/GlobalShortcuts.tsx', () => {
});
});

describe('openGitHubIssues', () => {
const openGitHubIssuesSpy = vi.spyOn(links, 'openGitHubIssues').mockImplementation(vi.fn());
describe('openHostIssues', () => {
const openHostIssuesSpy = vi.spyOn(links, 'openHostIssues').mockImplementation(vi.fn());

it('opens primary account GitHub issues webpage when pressing I while logged in', async () => {
renderWithProviders(<GlobalShortcuts />, {
Expand All @@ -126,7 +126,7 @@ describe('components/GlobalShortcuts.tsx', () => {

await userEvent.keyboard('i');

expect(openGitHubIssuesSpy).toHaveBeenCalledTimes(1);
expect(openHostIssuesSpy).toHaveBeenCalledTimes(1);
});

it('does not open primary account GitHub issues webpage when logged out', async () => {
Expand All @@ -136,12 +136,12 @@ describe('components/GlobalShortcuts.tsx', () => {

await userEvent.keyboard('n');

expect(openGitHubIssuesSpy).not.toHaveBeenCalled();
expect(openHostIssuesSpy).not.toHaveBeenCalled();
});
});

describe('openGitHubPulls', () => {
const openGitHubPullsSpy = vi.spyOn(links, 'openGitHubPulls').mockImplementation(vi.fn());
describe('openHostPulls', () => {
const openHostPullsSpy = vi.spyOn(links, 'openHostPulls').mockImplementation(vi.fn());

it('opens primary account GitHub pull requests webpage when pressing N while logged in', async () => {
renderWithProviders(<GlobalShortcuts />, {
Expand All @@ -150,7 +150,7 @@ describe('components/GlobalShortcuts.tsx', () => {

await userEvent.keyboard('p');

expect(openGitHubPullsSpy).toHaveBeenCalledTimes(1);
expect(openHostPullsSpy).toHaveBeenCalledTimes(1);
});

it('does not open primary account GitHub pull requests webpage when logged out', async () => {
Expand All @@ -160,7 +160,7 @@ describe('components/GlobalShortcuts.tsx', () => {

await userEvent.keyboard('n');

expect(openGitHubPullsSpy).not.toHaveBeenCalled();
expect(openHostPullsSpy).not.toHaveBeenCalled();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
});

it('should open my issues when clicked', async () => {
const openGitHubIssuesSpy = vi.spyOn(links, 'openGitHubIssues').mockImplementation(vi.fn());
const openHostIssuesSpy = vi.spyOn(links, 'openHostIssues').mockImplementation(vi.fn());

const props: AccountNotificationsProps = {
account: mockGitHubCloudAccount,
Expand All @@ -139,12 +139,12 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {

await userEvent.click(screen.getByTestId('account-issues'));

expect(openGitHubIssuesSpy).toHaveBeenCalledTimes(1);
expect(openGitHubIssuesSpy).toHaveBeenCalledWith(mockGitHubCloudAccount.hostname);
expect(openHostIssuesSpy).toHaveBeenCalledTimes(1);
expect(openHostIssuesSpy).toHaveBeenCalledWith(mockGitHubCloudAccount.hostname);
});

it('should open my pull requests when clicked', async () => {
const openGitHubPullsSpy = vi.spyOn(links, 'openGitHubPulls').mockImplementation(vi.fn());
const openHostPullsSpy = vi.spyOn(links, 'openHostPulls').mockImplementation(vi.fn());

const props: AccountNotificationsProps = {
account: mockGitHubCloudAccount,
Expand All @@ -157,8 +157,8 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {

await userEvent.click(screen.getByTestId('account-pull-requests'));

expect(openGitHubPullsSpy).toHaveBeenCalledTimes(1);
expect(openGitHubPullsSpy).toHaveBeenCalledWith(mockGitHubCloudAccount.hostname);
expect(openHostPullsSpy).toHaveBeenCalledTimes(1);
expect(openHostPullsSpy).toHaveBeenCalledWith(mockGitHubCloudAccount.hostname);
});

it('should toggle account notifications visibility', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
groupNotificationsByRepository,
isGroupByRepository,
} from '../../utils/notifications/group';
import { openAccountProfile, openGitHubIssues, openGitHubPulls } from '../../utils/system/links';
import { openAccountProfile, openHostIssues, openHostPulls } from '../../utils/system/links';
import { cn } from '../../utils/ui/cn';
import { getChevronDetails } from '../../utils/ui/display';
import { AllRead } from '../AllRead';
Expand Down Expand Up @@ -98,14 +98,14 @@ export const AccountNotifications: FC<AccountNotificationsProps> = (
}
>
<HoverButton
action={() => openGitHubIssues(account.hostname)}
action={() => openHostIssues(account.hostname)}
icon={IssueOpenedIcon}
label="My issues ↗"
testid="account-issues"
/>

<HoverButton
action={() => openGitHubPulls(account.hostname)}
action={() => openHostPulls(account.hostname)}
icon={GitPullRequestIcon}
label="My pull requests ↗"
testid="account-pull-requests"
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/hooks/useShortcutActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useLocation, useNavigate } from 'react-router-dom';

import { getPrimaryAccountHostname } from '../utils/auth/utils';
import { quitApp } from '../utils/system/comms';
import { openGitHubIssues, openGitHubNotifications, openGitHubPulls } from '../utils/system/links';
import { openHostIssues, openHostNotifications, openHostPulls } from '../utils/system/links';
import { useAppContext } from './useAppContext';

type ShortcutName =
Expand Down Expand Up @@ -55,7 +55,7 @@ export function useShortcutActions(): { shortcuts: ShortcutConfigs } {
myNotifications: {
key: 'n',
isAllowed: isLoggedIn,
action: () => openGitHubNotifications(primaryAccountHostname),
action: () => openHostNotifications(primaryAccountHostname),
},
focusedMode: {
key: 'w',
Expand All @@ -76,12 +76,12 @@ export function useShortcutActions(): { shortcuts: ShortcutConfigs } {
myIssues: {
key: 'i',
isAllowed: isLoggedIn,
action: () => openGitHubIssues(primaryAccountHostname),
action: () => openHostIssues(primaryAccountHostname),
},
myPullRequests: {
key: 'p',
isAllowed: isLoggedIn,
action: () => openGitHubPulls(primaryAccountHostname),
action: () => openHostPulls(primaryAccountHostname),
},
refresh: {
key: 'r',
Expand Down
18 changes: 9 additions & 9 deletions src/renderer/utils/system/links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import * as comms from './comms';
import {
openAccountProfile,
openAccountSettings,
openGitHubIssues,
openGitHubNotifications,
openHostIssues,
openHostNotifications,
openGitHubParticipatingDocs,
openGitHubPulls,
openHostPulls,
openGitifyReleaseNotes,
openHost,
openNotification,
Expand All @@ -34,20 +34,20 @@ describe('renderer/utils/links.ts', () => {
);
});

it('openGitHubNotifications', () => {
openGitHubNotifications(mockGitHubCloudAccount.hostname);
it('openHostNotifications', () => {
openHostNotifications(mockGitHubCloudAccount.hostname);

expect(openExternalLinkSpy).toHaveBeenCalledWith('https://github.com/notifications');
});

it('openGitHubIssues', () => {
openGitHubIssues(mockGitHubCloudAccount.hostname);
it('openHostIssues', () => {
openHostIssues(mockGitHubCloudAccount.hostname);

expect(openExternalLinkSpy).toHaveBeenCalledWith('https://github.com/issues');
});

it('openGitHubPulls', () => {
openGitHubPulls(mockGitHubCloudAccount.hostname);
it('openHostPulls', () => {
openHostPulls(mockGitHubCloudAccount.hostname);

expect(openExternalLinkSpy).toHaveBeenCalledWith('https://github.com/pulls');
});
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/utils/system/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ export function openGitifyReleaseNotes(version: string) {
);
}

export function openGitHubNotifications(hostname: Hostname) {
export function openHostNotifications(hostname: Hostname) {
const url = new URL(`https://${hostname}`);
url.pathname = 'notifications';
openExternalLink(url.toString() as Link);
}

export function openGitHubIssues(hostname: Hostname) {
export function openHostIssues(hostname: Hostname) {
const url = new URL(`https://${hostname}`);
url.pathname = 'issues';
openExternalLink(url.toString() as Link);
}

export function openGitHubPulls(hostname: Hostname) {
export function openHostPulls(hostname: Hostname) {
const url = new URL(`https://${hostname}`);
url.pathname = 'pulls';
openExternalLink(url.toString() as Link);
Expand Down
Loading