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
62 changes: 38 additions & 24 deletions src/renderer/components/Sidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ describe('renderer/components/Sidebar.tsx', () => {
accounts: [],
});

expect(screen.queryByTestId('sidebar-notifications')).not.toBeInTheDocument();
expect(screen.queryByTestId('sidebar-my-issues')).not.toBeInTheDocument();
expect(screen.queryByTestId('sidebar-my-pull-requests')).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: /^Notifications/ })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: /^My issues/ })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: /^My pull requests/ })).not.toBeInTheDocument();
});

it('navigates home when clicking logo', async () => {
renderWithProviders(<Sidebar />);

await userEvent.click(screen.getByTestId('sidebar-home'));
await userEvent.click(screen.getByRole('button', { name: new RegExp(`^${APPLICATION.NAME}`) }));

expect(navigateMock).toHaveBeenCalledTimes(1);
expect(navigateMock).toHaveBeenCalledWith('/', { replace: true });
Expand All @@ -96,7 +96,7 @@ describe('renderer/components/Sidebar.tsx', () => {
accounts: [mockGitHubCloudAccount],
});

await userEvent.click(screen.getByTestId('sidebar-notifications'));
await userEvent.click(screen.getByRole('button', { name: /^Notifications/ }));

expect(openExternalLinkSpy).toHaveBeenCalledTimes(1);
expect(openExternalLinkSpy).toHaveBeenCalledWith('https://github.com/notifications');
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('renderer/components/Sidebar.tsx', () => {
settings: { ...mockSettings, participating: false },
});

expect(screen.getByTestId('sidebar-focused-mode')).toHaveAttribute(
expect(screen.getByRole('button', { name: /^Toggle focused mode/ })).toHaveAttribute(
'data-variant',
'invisible',
);
Expand All @@ -146,7 +146,10 @@ describe('renderer/components/Sidebar.tsx', () => {
settings: { ...mockSettings, participating: true },
});

expect(screen.getByTestId('sidebar-focused-mode')).toHaveAttribute('data-variant', 'primary');
expect(screen.getByRole('button', { name: /^Toggle focused mode/ })).toHaveAttribute(
'data-variant',
'primary',
);
});

it('toggles participating when clicked', async () => {
Expand All @@ -156,7 +159,7 @@ describe('renderer/components/Sidebar.tsx', () => {
fetchNotifications: fetchNotificationsMock,
});

await userEvent.click(screen.getByTestId('sidebar-focused-mode'));
await userEvent.click(screen.getByRole('button', { name: /^Toggle focused mode/ }));

expect(updateSettingSpy).toHaveBeenCalledTimes(1);
expect(updateSettingSpy).toHaveBeenCalledWith('participating', true);
Expand All @@ -169,7 +172,7 @@ describe('renderer/components/Sidebar.tsx', () => {
accounts: [mockGitHubCloudAccount],
});

await userEvent.click(screen.getByTestId('sidebar-filter-notifications'));
await userEvent.click(screen.getByRole('button', { name: /^Filters/ }));

expect(navigateMock).toHaveBeenCalledTimes(1);
expect(navigateMock).toHaveBeenCalledWith('/filters');
Expand All @@ -181,7 +184,7 @@ describe('renderer/components/Sidebar.tsx', () => {
accounts: [mockGitHubCloudAccount],
});

await userEvent.click(screen.getByTestId('sidebar-filter-notifications'));
await userEvent.click(screen.getByRole('button', { name: /^Filters/ }));

expect(navigateMock).toHaveBeenCalledTimes(1);
expect(navigateMock).toHaveBeenCalledWith('/', { replace: true });
Expand All @@ -194,7 +197,7 @@ describe('renderer/components/Sidebar.tsx', () => {
filters: { reasons: ['assign'] },
});

expect(screen.getByTestId('sidebar-filter-notifications')).toHaveAttribute(
expect(screen.getByRole('button', { name: /^Filters/ })).toHaveAttribute(
'data-variant',
'primary',
);
Expand All @@ -207,7 +210,7 @@ describe('renderer/components/Sidebar.tsx', () => {
accounts: [mockGitHubCloudAccount],
});

await userEvent.click(screen.getByTestId('sidebar-my-issues'));
await userEvent.click(screen.getByRole('button', { name: /^My issues/ }));

expect(openExternalLinkSpy).toHaveBeenCalledTimes(1);
expect(openExternalLinkSpy).toHaveBeenCalledWith('https://github.com/issues');
Expand All @@ -218,7 +221,7 @@ describe('renderer/components/Sidebar.tsx', () => {
accounts: [mockGitHubCloudAccount],
});

await userEvent.click(screen.getByTestId('sidebar-my-pull-requests'));
await userEvent.click(screen.getByRole('button', { name: /^My pull requests/ }));

expect(openExternalLinkSpy).toHaveBeenCalledTimes(1);
expect(openExternalLinkSpy).toHaveBeenCalledWith('https://github.com/pulls');
Expand All @@ -233,7 +236,7 @@ describe('renderer/components/Sidebar.tsx', () => {
status: 'success',
});

await userEvent.click(screen.getByTestId('sidebar-refresh'));
await userEvent.click(screen.getByRole('button', { name: /^Refresh/ }));

expect(fetchNotificationsMock).toHaveBeenCalledTimes(1);
});
Expand All @@ -245,7 +248,7 @@ describe('renderer/components/Sidebar.tsx', () => {
status: 'loading',
});

await userEvent.click(screen.getByTestId('sidebar-refresh'));
await userEvent.click(screen.getByRole('button', { name: /^Refresh/ }));

expect(fetchNotificationsMock).not.toHaveBeenCalled();
});
Expand All @@ -256,8 +259,11 @@ describe('renderer/components/Sidebar.tsx', () => {
status: 'loading',
});

expect(screen.getByTestId('sidebar-refresh')).toHaveAttribute('data-loading', 'true');
expect(screen.getByTestId('sidebar-refresh')).toBeDisabled();
expect(screen.getByRole('button', { name: /^Refresh/ })).toHaveAttribute(
'data-loading',
'true',
);
expect(screen.getByRole('button', { name: /^Refresh/ })).toBeDisabled();
});

it('shows a loading spinner on the refresh icon while a background fetch is in flight, regardless of settled status', () => {
Expand All @@ -267,9 +273,12 @@ describe('renderer/components/Sidebar.tsx', () => {
isFetching: true,
});

expect(screen.getByTestId('sidebar-refresh')).toHaveAttribute('data-loading', 'true');
expect(screen.getByRole('button', { name: /^Refresh/ })).toHaveAttribute(
'data-loading',
'true',
);
expect(tree.container.querySelector('[data-component="Spinner"]')).toBeInTheDocument();
expect(screen.getByTestId('sidebar-refresh')).toBeDisabled();
expect(screen.getByRole('button', { name: /^Refresh/ })).toBeDisabled();
});

it('does not show a loading spinner on the refresh icon when settled and no fetch is in flight', () => {
Expand All @@ -279,8 +288,11 @@ describe('renderer/components/Sidebar.tsx', () => {
isFetching: false,
});

expect(screen.getByTestId('sidebar-refresh')).toHaveAttribute('data-loading', 'false');
expect(screen.getByTestId('sidebar-refresh')).toBeEnabled();
expect(screen.getByRole('button', { name: /^Refresh/ })).toHaveAttribute(
'data-loading',
'false',
);
expect(screen.getByRole('button', { name: /^Refresh/ })).toBeEnabled();
});
});

Expand All @@ -290,7 +302,7 @@ describe('renderer/components/Sidebar.tsx', () => {
accounts: [mockGitHubCloudAccount],
});

await userEvent.click(screen.getByTestId('sidebar-settings'));
await userEvent.click(screen.getByRole('button', { name: /^Settings/ }));

expect(navigateMock).toHaveBeenCalledTimes(1);
expect(navigateMock).toHaveBeenCalledWith('/settings');
Expand All @@ -303,7 +315,7 @@ describe('renderer/components/Sidebar.tsx', () => {
fetchNotifications: fetchNotificationsMock,
});

await userEvent.click(screen.getByTestId('sidebar-settings'));
await userEvent.click(screen.getByRole('button', { name: /^Settings/ }));

expect(fetchNotificationsMock).toHaveBeenCalledTimes(1);
expect(navigateMock).toHaveBeenCalledTimes(1);
Expand All @@ -318,7 +330,9 @@ describe('renderer/components/Sidebar.tsx', () => {
accounts: [],
});

await userEvent.click(screen.getByTestId('sidebar-quit'));
await userEvent.click(
screen.getByRole('button', { name: new RegExp(`^Quit ${APPLICATION.NAME}`) }),
);

expect(quitAppSpy).toHaveBeenCalledTimes(1);
});
Expand Down
9 changes: 0 additions & 9 deletions src/renderer/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export function Sidebar() {
<Stack align="center" direction="vertical" gap="condensed" padding="normal">
<IconButton
aria-label={APPLICATION.NAME}
data-testid="sidebar-home"
description="Home"
icon={<LogoIcon />}
keybindingHint={shortcuts.home.key}
Expand All @@ -56,7 +55,6 @@ export function Sidebar() {
<>
<IconButton
aria-label="Notifications"
data-testid="sidebar-notifications"
description={`${notificationCount} ${fetchReadNotifications ? 'notifications' : 'unread notifications'} ↗`}
icon={BellIcon}
keybindingHint={shortcuts.myNotifications.key}
Expand All @@ -68,7 +66,6 @@ export function Sidebar() {

<IconButton
aria-label="Toggle focused mode"
data-testid="sidebar-focused-mode"
description={
participating ? 'Focused (participating only)' : 'Participating and watching'
}
Expand All @@ -82,7 +79,6 @@ export function Sidebar() {

<IconButton
aria-label="Filters"
data-testid="sidebar-filter-notifications"
description="Filter notifications"
icon={FilterIcon}
keybindingHint={shortcuts.filters.key}
Expand All @@ -94,7 +90,6 @@ export function Sidebar() {

<IconButton
aria-label="My issues ↗"
data-testid="sidebar-my-issues"
icon={IssueOpenedIcon}
keybindingHint={shortcuts.myIssues.key}
onClick={() => shortcuts.myIssues.action()}
Expand All @@ -105,7 +100,6 @@ export function Sidebar() {

<IconButton
aria-label="My pull requests ↗"
data-testid="sidebar-my-pull-requests"
icon={GitPullRequestIcon}
keybindingHint={shortcuts.myPullRequests.key}
onClick={() => shortcuts.myPullRequests.action()}
Expand All @@ -122,7 +116,6 @@ export function Sidebar() {
<>
<IconButton
aria-label="Refresh"
data-testid="sidebar-refresh"
description="Refresh notifications"
loading={isLoading || isFetching}
disabled={isLoading || isFetching}
Expand All @@ -136,7 +129,6 @@ export function Sidebar() {

<IconButton
aria-label="Settings"
data-testid="sidebar-settings"
description="Settings"
icon={GearIcon}
keybindingHint={shortcuts.settings.key}
Expand All @@ -151,7 +143,6 @@ export function Sidebar() {
{!isLoggedIn && (
<IconButton
aria-label={`Quit ${APPLICATION.NAME}`}
data-testid="sidebar-quit"
icon={XCircleIcon}
keybindingHint={shortcuts.quit.key}
onClick={() => shortcuts.quit.action()}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/filters/FilterCheckbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('renderer/components/filters/FilterCheckbox.tsx', () => {
<FilterCheckbox checked={true} counter={3} label="Issues" name="issues" onChange={vi.fn()} />,
);

expect(screen.getByTestId('checkbox-issues')).toBeChecked();
expect(screen.getByRole('checkbox', { name: 'Issues' })).toBeChecked();
expect(screen.getByText('Issues')).toBeInTheDocument();
expect(screen.getByText('3')).toBeInTheDocument();
});
Expand All @@ -28,7 +28,7 @@ describe('renderer/components/filters/FilterCheckbox.tsx', () => {
/>,
);

expect(screen.getByTestId('checkbox-issues')).toBeDisabled();
expect(screen.getByRole('checkbox', { name: 'Issues' })).toBeDisabled();

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

Expand Down
8 changes: 1 addition & 7 deletions src/renderer/components/layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ export function AppLayout({ children }: Readonly<AppLayoutProps>) {
return (
<div className="flex flex-col min-h-screen bg-gitify-background">
{/* Hidden focus sentinel; grabs initial focus via callback ref */}
<button
aria-label="initial focus"
className="sr-only"
data-testid="initial-focus-sentinel"
ref={setFocusRef}
type="button"
/>
<button aria-label="initial focus" className="sr-only" ref={setFocusRef} type="button" />

<Sidebar />

Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ export function LoginWithPersonalAccessTokenForm({
<TextInput
aria-invalid={errors.username ? 'true' : 'false'}
block
data-testid="login-username"
name="username"
onChange={handleInputChange}
placeholder={usernamePlaceholder}
Expand Down Expand Up @@ -254,7 +253,6 @@ export function LoginWithPersonalAccessTokenForm({
<Footer justify="space-between">
<Tooltip direction="ne" text={docsTooltip}>
<Button
data-testid="login-docs"
leadingVisual={BookIcon}
onClick={() => openExternalLink(adapter.documentationUrl)}
size="small"
Expand Down
Loading
Loading