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
41 changes: 11 additions & 30 deletions src/renderer/components/notifications/NotificationTitle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,17 @@ import { mockSettings } from '../../__mocks__/state-mocks';
import { NotificationTitle } from './NotificationTitle';

describe('renderer/components/notifications/NotificationTitle.tsx', () => {
it('should render plain text without code blocks', () => {
const tree = renderWithProviders(<NotificationTitle title="Simple notification title" />);

expect(tree.container).toMatchSnapshot();
});

it('should render text with single inline code block', () => {
const tree = renderWithProviders(
<NotificationTitle title="refactor: migrate deprecated atlaskit `xcss`" />,
);

expect(tree.container).toMatchSnapshot();
});

it('should render text with multiple inline code blocks', () => {
const tree = renderWithProviders(
<NotificationTitle title="Replace `foo` with `bar` in config" />,
);

expect(tree.container).toMatchSnapshot();
});

it('should render text with code block at the start', () => {
const tree = renderWithProviders(<NotificationTitle title="`useState` hook implementation" />);

expect(tree.container).toMatchSnapshot();
});

it('should render text with code block at the end', () => {
const tree = renderWithProviders(<NotificationTitle title="Fix issue with `render`" />);
it.each([
['should render plain text without code blocks', 'Simple notification title'],
[
'should render text with single inline code block',
'refactor: migrate deprecated atlaskit `xcss`',
],
['should render text with multiple inline code blocks', 'Replace `foo` with `bar` in config'],
['should render text with code block at the start', '`useState` hook implementation'],
['should render text with code block at the end', 'Fix issue with `render`'],
])('%s', (_name, title) => {
const tree = renderWithProviders(<NotificationTitle title={title} />);

expect(tree.container).toMatchSnapshot();
});
Expand Down
43 changes: 1 addition & 42 deletions src/renderer/components/settings/SystemSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('renderer/components/settings/SystemSettings.tsx', () => {
['checkbox-keyboardShortcut', 'keyboardShortcut'],
['checkbox-showNotifications', 'showNotifications'],
['checkbox-showUpdateNotifications', 'showUpdateNotifications'],
['checkbox-playSound', 'playSound'],
['checkbox-openAtStartup', 'openAtStartup'],
['checkbox-keepWindowOnBlur', 'keepWindowOnBlur'],
] as const)('should toggle %s checkbox', async (testId, setting) => {
Expand Down Expand Up @@ -211,27 +212,7 @@ describe('renderer/components/settings/SystemSettings.tsx', () => {
});
});

it('should toggle the showNotifications checkbox', async () => {
await act(async () => {
renderWithProviders(<SystemSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-showNotifications'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('showNotifications');
});

describe('playSound', () => {
it('should toggle the playSound checkbox', async () => {
renderWithProviders(<SystemSettings />);

await userEvent.click(screen.getByTestId('checkbox-playSound'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('playSound');
});

it('volume controls should not be shown if playSound checkbox is false', async () => {
renderWithProviders(<SystemSettings />, {
settings: { ...mockSettings, playSound: false },
Expand Down Expand Up @@ -277,26 +258,4 @@ describe('renderer/components/settings/SystemSettings.tsx', () => {
expect(updateSettingSpy).toHaveBeenCalledWith('notificationVolume', 20);
});
});

it('should toggle the openAtStartup checkbox', async () => {
await act(async () => {
renderWithProviders(<SystemSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-openAtStartup'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('openAtStartup');
});

it('should toggle the keepWindowOnBlur checkbox', async () => {
await act(async () => {
renderWithProviders(<SystemSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-keepWindowOnBlur'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('keepWindowOnBlur');
});
});
28 changes: 7 additions & 21 deletions src/renderer/routes/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,17 @@ describe('renderer/routes/Login.tsx', () => {
expect(navigateMock).toHaveBeenCalledWith('/', { replace: true });
});

it('should login with github', async () => {
it.each([
['login-github', '/login/github/device-flow'],
['login-pat', '/login/github/personal-access-token'],
['login-oauth-app', '/login/github/oauth-app'],
])('navigates %s', async (testId, route) => {
renderWithProviders(<LoginRoute />);

await userEvent.click(screen.getByTestId('login-github'));
await userEvent.click(screen.getByTestId(testId));

expect(navigateMock).toHaveBeenCalledTimes(1);
expect(navigateMock).toHaveBeenCalledWith('/login/github/device-flow');
});

it('should navigate to login with personal access token', async () => {
renderWithProviders(<LoginRoute />);

await userEvent.click(screen.getByTestId('login-pat'));

expect(navigateMock).toHaveBeenCalledTimes(1);
expect(navigateMock).toHaveBeenCalledWith('/login/github/personal-access-token');
});

it('should navigate to login with oauth app', async () => {
renderWithProviders(<LoginRoute />);

await userEvent.click(screen.getByTestId('login-oauth-app'));

expect(navigateMock).toHaveBeenCalledTimes(1);
expect(navigateMock).toHaveBeenCalledWith('/login/github/oauth-app');
expect(navigateMock).toHaveBeenCalledWith(route);
});

it('should navigate to login with Gitea personal access token', async () => {
Expand Down
46 changes: 12 additions & 34 deletions src/renderer/utils/forges/github/handlers/checkSuite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,19 @@ describe('renderer/utils/notifications/handlers/checkSuite.ts', () => {
});
});

it('failed check suite state', async () => {
const mockNotification = mockPartialGitifyNotification({
title: 'Demo workflow run failed for main branch',
type: 'CheckSuite',
});

const result = await checkSuiteHandler.enrich(mockNotification);

expect(result).toEqual({
state: 'FAILURE',
user: undefined,
htmlUrl:
'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Afailure+branch%3Amain',
});
});

it('failed at startup check suite state', async () => {
it.each([
['failed check suite state', 'Demo workflow run failed for main branch'],
[
'failed at startup check suite state',
'Demo workflow run failed at startup for main branch',
],
[
'multiple attempts failed check suite state',
'Demo workflow run, Attempt #3 failed for main branch',
],
])('%s', async (_name, title) => {
const mockNotification = mockPartialGitifyNotification({
title: 'Demo workflow run failed at startup for main branch',
type: 'CheckSuite',
});

const result = await checkSuiteHandler.enrich(mockNotification);

expect(result).toEqual({
state: 'FAILURE',
user: undefined,
htmlUrl:
'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Afailure+branch%3Amain',
});
});

it('multiple attempts failed check suite state', async () => {
const mockNotification = mockPartialGitifyNotification({
title: 'Demo workflow run, Attempt #3 failed for main branch',
title,
type: 'CheckSuite',
});

Expand Down
Loading