Skip to content

Commit

Permalink
feat(login): add help docs to login flows
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed May 17, 2024
1 parent f75cedb commit 59e0a9b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/routes/LoginEnterprise.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fireEvent, render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import * as TestRenderer from 'react-test-renderer';
const { ipcRenderer } = require('electron');
import { shell } from 'electron';
import { mockedEnterpriseAccounts } from '../__mocks__/mockedData';
import { AppContext } from '../context/App';
import type { AuthState } from '../types';
Expand All @@ -14,6 +15,8 @@ jest.mock('react-router-dom', () => ({
}));

describe('routes/LoginEnterprise.tsx', () => {
const openExternalMock = jest.spyOn(shell, 'openExternal');

const mockAccounts: AuthState = {
enterpriseAccounts: [],
user: null,
Expand Down Expand Up @@ -129,4 +132,18 @@ describe('routes/LoginEnterprise.tsx', () => {
expect(screen.getByText('Invalid client id.')).toBeTruthy();
expect(screen.getByText('Invalid client secret.')).toBeTruthy();
});

it('should open help docs in the browser', async () => {
render(
<AppContext.Provider value={{ accounts: mockAccounts }}>
<MemoryRouter>
<LoginEnterpriseRoute />
</MemoryRouter>
</AppContext.Provider>,
);

fireEvent.click(screen.getByLabelText('GitHub Docs'));

expect(openExternalMock).toHaveBeenCalledTimes(1);
});
});
1 change: 1 addition & 0 deletions src/routes/LoginEnterprise.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const LoginEnterpriseRoute: FC = () => {
<div className="text-xs italic hover:text-blue-500 justify-center items-center">
<button
type="button"
aria-label="GitHub Docs"
className={`px-2 py-1 text-xs ${buttonClasses}`}
onClick={() => openLink(GITHUB_DOCS_URL)}
>
Expand Down
14 changes: 14 additions & 0 deletions src/routes/LoginWithToken.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,18 @@ describe('routes/LoginWithToken.tsx', () => {
expect(screen.getByText('Invalid hostname.')).toBeDefined();
expect(screen.getByText('Invalid token.')).toBeDefined();
});

it('should open help docs in the browser', async () => {
render(
<AppContext.Provider value={{ validateToken: mockValidateToken }}>
<MemoryRouter>
<LoginWithToken />
</MemoryRouter>
</AppContext.Provider>,
);

fireEvent.click(screen.getByLabelText('GitHub Docs'));

expect(openExternalMock).toHaveBeenCalledTimes(1);
});
});
1 change: 1 addition & 0 deletions src/routes/LoginWithToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const LoginWithToken: FC = () => {
<div className="text-xs italic hover:text-blue-500 justify-center items-center">
<button
type="button"
aria-label="GitHub Docs"
className={`px-2 py-1 text-xs ${buttonClasses}`}
onClick={() => openLink(GITHUB_DOCS_URL)}
>
Expand Down
1 change: 1 addition & 0 deletions src/routes/__snapshots__/LoginEnterprise.test.tsx.snap

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

1 change: 1 addition & 0 deletions src/routes/__snapshots__/LoginWithToken.test.tsx.snap

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

0 comments on commit 59e0a9b

Please sign in to comment.