From a477b9ab08f28a6c18da157e32c6037d51caf951 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Mon, 18 Mar 2024 08:40:31 -0400 Subject: [PATCH] feat: ensure all buttons have label and accessibility text --- src/components/Sidebar.test.tsx | 12 +++++----- src/components/Sidebar.tsx | 14 +++++++---- .../__snapshots__/Sidebar.test.tsx.snap | 6 +++-- src/routes/Login.tsx | 9 ++++--- src/routes/LoginEnterprise.tsx | 10 +++++--- src/routes/LoginWithToken.tsx | 10 +++++--- src/routes/Settings.test.tsx | 24 +++++++++---------- src/routes/Settings.tsx | 23 +++++++++++------- src/routes/__snapshots__/Login.test.tsx.snap | 3 +++ .../LoginEnterprise.test.tsx.snap | 5 ++-- .../LoginWithToken.test.tsx.snap | 5 ++-- .../__snapshots__/Settings.test.tsx.snap | 11 +++++---- 12 files changed, 81 insertions(+), 51 deletions(-) diff --git a/src/components/Sidebar.test.tsx b/src/components/Sidebar.test.tsx index 6582f917c..b9e5a82cd 100644 --- a/src/components/Sidebar.test.tsx +++ b/src/components/Sidebar.test.tsx @@ -61,7 +61,7 @@ describe('components/Sidebar.tsx', () => { }); it('should refresh the notifications', () => { - const { getByLabelText } = render( + const { getByTitle } = render( @@ -71,19 +71,19 @@ describe('components/Sidebar.tsx', () => { , ); fetchNotifications.mockReset(); - fireEvent.click(getByLabelText('Refresh Notifications')); + fireEvent.click(getByTitle('Refresh Notifications')); expect(fetchNotifications).toHaveBeenCalledTimes(1); }); it('go to the settings route', () => { - const { getByLabelText } = render( + const { getByTitle } = render( , ); - fireEvent.click(getByLabelText('Settings')); + fireEvent.click(getByTitle('Settings')); expect(mockNavigate).toHaveBeenNthCalledWith(1, '/settings'); }); @@ -108,14 +108,14 @@ describe('components/Sidebar.tsx', () => { }); it('should quit the app', () => { - const { getByLabelText } = render( + const { getByTitle } = render( , ); - fireEvent.click(getByLabelText('Quit App')); + fireEvent.click(getByTitle('Quit Gitify')); expect(ipcRenderer.send).toHaveBeenCalledTimes(1); expect(ipcRenderer.send).toHaveBeenCalledWith('app-quit'); }); diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 38574a812..c29be0c75 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -66,17 +66,21 @@ export const Sidebar: React.FC = () => { <> )} @@ -94,8 +97,9 @@ export const Sidebar: React.FC = () => { {!isLoggedIn && ( diff --git a/src/components/__snapshots__/Sidebar.test.tsx.snap b/src/components/__snapshots__/Sidebar.test.tsx.snap index e9cf5c2ac..c26224da6 100644 --- a/src/components/__snapshots__/Sidebar.test.tsx.snap +++ b/src/components/__snapshots__/Sidebar.test.tsx.snap @@ -86,9 +86,10 @@ exports[`components/Sidebar.tsx should render itself & its children (logged in) className="py-4 px-3" > diff --git a/src/routes/LoginEnterprise.tsx b/src/routes/LoginEnterprise.tsx index eef567b9f..af7bd5615 100644 --- a/src/routes/LoginEnterprise.tsx +++ b/src/routes/LoginEnterprise.tsx @@ -85,9 +85,9 @@ export const LoginEnterpriseRoute: React.FC = () => { @@ -108,10 +108,14 @@ export const LoginEnterpriseRoute: React.FC = () => {

Login with GitHub Enterprise

diff --git a/src/routes/LoginWithToken.tsx b/src/routes/LoginWithToken.tsx index d14285bb2..a90609cf7 100644 --- a/src/routes/LoginWithToken.tsx +++ b/src/routes/LoginWithToken.tsx @@ -95,9 +95,9 @@ export const LoginWithToken: React.FC = () => { @@ -120,10 +120,14 @@ export const LoginWithToken: React.FC = () => {

Login with an access token

diff --git a/src/routes/Settings.test.tsx b/src/routes/Settings.test.tsx index 933dd2483..fedbd5c71 100644 --- a/src/routes/Settings.test.tsx +++ b/src/routes/Settings.test.tsx @@ -46,10 +46,10 @@ describe('routes/Settings.tsx', () => { it('should press the logout', async () => { const logoutMock = jest.fn(); - let getByLabelText; + let getByTitle; await act(async () => { - const { getByLabelText: getByLabelTextLocal } = render( + const { getByTitle: getByLabelTextLocal } = render( { , ); - getByLabelText = getByLabelTextLocal; + getByTitle = getByLabelTextLocal; }); - fireEvent.click(getByLabelText('Logout')); + fireEvent.click(getByTitle('Logout')); expect(logoutMock).toHaveBeenCalledTimes(1); @@ -265,10 +265,10 @@ describe('routes/Settings.tsx', () => { }); it('should go to the enterprise login route', async () => { - let getByLabelText; + let getByTitle; await act(async () => { - const { getByLabelText: getByLabelTextLocal } = render( + const { getByTitle: getByTitleLocal } = render( { , ); - getByLabelText = getByLabelTextLocal; + getByTitle = getByTitleLocal; }); - fireEvent.click(getByLabelText('Login with GitHub Enterprise')); + fireEvent.click(getByTitle('Login with GitHub Enterprise')); expect(mockNavigate).toHaveBeenNthCalledWith(1, '/login-enterprise', { replace: true, }); }); it('should quit the app', async () => { - let getByLabelText; + let getByTitle; await act(async () => { - const { getByLabelText: getByLabelTextLocal } = render( + const { getByTitle: getByTitleLocal } = render( @@ -302,10 +302,10 @@ describe('routes/Settings.tsx', () => { , ); - getByLabelText = getByLabelTextLocal; + getByTitle = getByTitleLocal; }); - fireEvent.click(getByLabelText('Quit Gitify')); + fireEvent.click(getByTitle('Quit Gitify')); expect(ipcRenderer.send).toHaveBeenCalledWith('app-quit'); }); diff --git a/src/routes/Settings.tsx b/src/routes/Settings.tsx index 78478e2f5..9ee9585c5 100644 --- a/src/routes/Settings.tsx +++ b/src/routes/Settings.tsx @@ -84,10 +84,14 @@ export const SettingsRoute: React.FC = () => {

Settings

@@ -165,26 +169,29 @@ export const SettingsRoute: React.FC = () => {
diff --git a/src/routes/__snapshots__/Login.test.tsx.snap b/src/routes/__snapshots__/Login.test.tsx.snap index 64aacb10f..50030a864 100644 --- a/src/routes/__snapshots__/Login.test.tsx.snap +++ b/src/routes/__snapshots__/Login.test.tsx.snap @@ -59,6 +59,7 @@ exports[`routes/Login.tsx should render itself & its children 1`] = ` aria-label="Login with GitHub" className="w-48 py-2 my-2 bg-gray-300 font-semibold rounded text-xs text-center dark:text-black hover:bg-gray-500 hover:text-white focus:outline-none" onClick={[Function]} + title="Login with GitHub" > Login to GitHub @@ -66,6 +67,7 @@ exports[`routes/Login.tsx should render itself & its children 1`] = ` aria-label="Login with GitHub Enterprise" className="w-48 py-2 my-2 bg-gray-300 font-semibold rounded text-xs text-center dark:text-black hover:bg-gray-500 hover:text-white focus:outline-none" onClick={[Function]} + title="Login with GitHub Enterprise" > Login to GitHub Enterprise @@ -73,6 +75,7 @@ exports[`routes/Login.tsx should render itself & its children 1`] = ` aria-label="Login with Personal Token" className="bg-none hover:text-gray-800 dark:text-gray-100 dark:hover:text-gray-300 mt-4 focus:outline-none" onClick={[Function]} + title="Login with Personal Token" > or login with a personal token diff --git a/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap b/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap index badaf802b..8e139ef8a 100644 --- a/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap +++ b/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap @@ -8,12 +8,13 @@ exports[`routes/LoginEnterprise.js renders correctly 1`] = ` className="flex justify-between items-center mt-4 py-2 mx-8" >