From 6f7f2f07fea8d5378201b4bc64ab74e44befe41a Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Mon, 18 Mar 2024 08:51:17 -0400 Subject: [PATCH 1/3] refactor: add title to unread notifications button --- src/components/Sidebar.tsx | 11 +++++++---- .../__snapshots__/Sidebar.test.tsx.snap | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 38574a812..23372a08e 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -49,16 +49,19 @@ export const Sidebar: React.FC = () => { onClick={onOpenBrowser} /> -
0 ? 'text-green-500' : 'text-white' }`} onClick={onOpenGitHubNotifications} - aria-label={`${notificationsCount} Unread Notifications`} + title={`${notificationsCount} Unread Notifications`} > - + {notificationsCount > 0 && notificationsCount} -
+
diff --git a/src/components/__snapshots__/Sidebar.test.tsx.snap b/src/components/__snapshots__/Sidebar.test.tsx.snap index e9cf5c2ac..6b17ae527 100644 --- a/src/components/__snapshots__/Sidebar.test.tsx.snap +++ b/src/components/__snapshots__/Sidebar.test.tsx.snap @@ -52,13 +52,14 @@ exports[`components/Sidebar.tsx should render itself & its children (logged in) -
4 -
+
-
4 -
+
Date: Mon, 18 Mar 2024 10:42:49 -0400 Subject: [PATCH 2/3] test: update snapshot --- src/components/__snapshots__/Sidebar.test.tsx.snap | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/__snapshots__/Sidebar.test.tsx.snap b/src/components/__snapshots__/Sidebar.test.tsx.snap index 86d27f68a..8db67adcc 100644 --- a/src/components/__snapshots__/Sidebar.test.tsx.snap +++ b/src/components/__snapshots__/Sidebar.test.tsx.snap @@ -59,8 +59,7 @@ exports[`components/Sidebar.tsx should render itself & its children (logged in) -
-
Date: Mon, 18 Mar 2024 10:51:57 -0400 Subject: [PATCH 3/3] test: fix tests --- src/components/Sidebar.test.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Sidebar.test.tsx b/src/components/Sidebar.test.tsx index b9e5a82cd..685b496b3 100644 --- a/src/components/Sidebar.test.tsx +++ b/src/components/Sidebar.test.tsx @@ -137,7 +137,7 @@ describe('components/Sidebar.tsx', () => { describe('should render the notifications icon', () => { it('when there are 0 notifications', () => { - const { getByLabelText } = render( + const { getByTitle } = render( @@ -145,14 +145,14 @@ describe('components/Sidebar.tsx', () => { , ); - const notificationsIcon = getByLabelText('0 Unread Notifications'); + const notificationsIcon = getByTitle('0 Unread Notifications'); expect(notificationsIcon.className).toContain('text-white'); expect(notificationsIcon.childNodes.length).toBe(1); expect(notificationsIcon.childNodes[0].nodeName).toBe('svg'); }); it('when there are more than 0 notifications', () => { - const { getByLabelText } = render( + const { getByTitle } = render( { , ); - const notificationsIcon = getByLabelText('4 Unread Notifications'); + const notificationsIcon = getByTitle('4 Unread Notifications'); expect(notificationsIcon.className).toContain('text-green-500'); expect(notificationsIcon.childNodes.length).toBe(2); expect(notificationsIcon.childNodes[0].nodeName).toBe('svg');