diff --git a/src/routes/LoginEnterprise.test.tsx b/src/routes/LoginEnterprise.test.tsx index 2936fe77e..97b313640 100644 --- a/src/routes/LoginEnterprise.test.tsx +++ b/src/routes/LoginEnterprise.test.tsx @@ -23,6 +23,7 @@ describe('routes/LoginEnterprise.tsx', () => { }; beforeEach(() => { + openExternalMock.mockReset(); mockNavigate.mockReset(); jest.spyOn(ipcRenderer, 'send'); @@ -160,10 +161,24 @@ describe('routes/LoginEnterprise.tsx', () => { target: { value: 'abc' }, }); - fireEvent.submit(screen.getByTitle('Login Button')); + fireEvent.submit(screen.getByTitle('Login')); expect(screen.getByText('Invalid hostname.')).toBeTruthy(); expect(screen.getByText('Invalid client id.')).toBeTruthy(); expect(screen.getByText('Invalid client secret.')).toBeTruthy(); }); + + it('should open help docs in the browser', async () => { + render( + + + + + , + ); + + fireEvent.click(screen.getByLabelText('GitHub Docs')); + + expect(openExternalMock).toHaveBeenCalledTimes(1); + }); }); diff --git a/src/routes/LoginEnterprise.tsx b/src/routes/LoginEnterprise.tsx index b38d77f22..52127944c 100644 --- a/src/routes/LoginEnterprise.tsx +++ b/src/routes/LoginEnterprise.tsx @@ -1,6 +1,6 @@ const ipcRenderer = require('electron').ipcRenderer; -import { ArrowLeftIcon } from '@primer/octicons-react'; +import { ArrowLeftIcon, BookIcon, SignInIcon } from '@primer/octicons-react'; import { type FC, useCallback, useContext, useEffect } from 'react'; import { Form, type FormRenderProps } from 'react-final-form'; @@ -12,6 +12,9 @@ import type { AuthOptions } from '../types'; import { getNewOAuthAppURL } from '../utils/auth'; import { openExternalLink } from '../utils/comms'; +const GITHUB_DOCS_URL = + 'https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authenticating-to-the-rest-api-with-an-oauth-app'; + interface IValues { hostname?: string; clientId?: string; @@ -109,14 +112,28 @@ export const LoginEnterpriseRoute: FC = () => { placeholder="ABC123DEF456" /> - +
+
+ +
+
+ +
+
); }; diff --git a/src/routes/LoginWithToken.test.tsx b/src/routes/LoginWithToken.test.tsx index 3c8067721..eb969083f 100644 --- a/src/routes/LoginWithToken.test.tsx +++ b/src/routes/LoginWithToken.test.tsx @@ -124,7 +124,7 @@ describe('routes/LoginWithToken.tsx', () => { target: { value: 'github.com' }, }); - fireEvent.submit(screen.getByTitle('Submit Button')); + fireEvent.submit(screen.getByTitle('Login')); await waitFor(() => expect(mockValidateToken).toHaveBeenCalledTimes(1)); @@ -150,7 +150,7 @@ describe('routes/LoginWithToken.tsx', () => { fireEvent.change(screen.getByLabelText('Hostname'), { target: { value: 'github.com' }, }); - fireEvent.submit(screen.getByTitle('Submit Button')); + fireEvent.submit(screen.getByTitle('Login')); }); await waitFor(() => expect(mockValidateToken).toHaveBeenCalledTimes(1)); @@ -173,9 +173,23 @@ describe('routes/LoginWithToken.tsx', () => { target: { value: '123' }, }); - fireEvent.submit(screen.getByTitle('Submit Button')); + fireEvent.submit(screen.getByTitle('Login')); expect(screen.getByText('Invalid hostname.')).toBeDefined(); expect(screen.getByText('Invalid token.')).toBeDefined(); }); + + it('should open help docs in the browser', async () => { + render( + + + + + , + ); + + fireEvent.click(screen.getByLabelText('GitHub Docs')); + + expect(openExternalMock).toHaveBeenCalledTimes(1); + }); }); diff --git a/src/routes/LoginWithToken.tsx b/src/routes/LoginWithToken.tsx index bd4c4969b..f7d567f21 100644 --- a/src/routes/LoginWithToken.tsx +++ b/src/routes/LoginWithToken.tsx @@ -1,4 +1,4 @@ -import { ArrowLeftIcon } from '@primer/octicons-react'; +import { ArrowLeftIcon, BookIcon, SignInIcon } from '@primer/octicons-react'; import { type FC, useCallback, useContext, useState } from 'react'; import { Form, type FormRenderProps } from 'react-final-form'; @@ -12,6 +12,9 @@ import { Constants } from '../utils/constants'; import { format } from 'date-fns'; +const GITHUB_DOCS_URL = + 'https://docs.github.com/en/enterprise-server@3.13/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens'; + interface IValues { token?: string; hostname?: string; @@ -104,14 +107,28 @@ export const LoginWithToken: FC = () => { )} - +
+
+ +
+
+ +
+
); }; diff --git a/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap b/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap index 50381c371..23943ff52 100644 --- a/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap +++ b/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap @@ -141,14 +141,76 @@ exports[`routes/LoginEnterprise.tsx renders correctly 1`] = ` value="" /> - +
+ +
+
+ +
+ diff --git a/src/routes/__snapshots__/LoginWithToken.test.tsx.snap b/src/routes/__snapshots__/LoginWithToken.test.tsx.snap index cac0708b4..45269da79 100644 --- a/src/routes/__snapshots__/LoginWithToken.test.tsx.snap +++ b/src/routes/__snapshots__/LoginWithToken.test.tsx.snap @@ -129,14 +129,76 @@ exports[`routes/LoginWithToken.tsx renders correctly 1`] = ` - +
+ +
+
+ +
+