From 9f3b3328b37144ad5ea53655237fdae16c8c1921 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 20 Mar 2024 20:38:36 -0400 Subject: [PATCH 1/2] fix(avatar): add default icon when no repository avatar available --- src/components/Repository.test.tsx | 11 ++ src/components/Repository.tsx | 8 +- .../AccountNotifications.test.tsx.snap | 2 + .../NotificationRow.test.tsx.snap | 4 + .../__snapshots__/Repository.test.tsx.snap | 115 ++++++++++++++++++ .../__snapshots__/Sidebar.test.tsx.snap | 4 + .../LoginEnterprise.test.tsx.snap | 1 + .../LoginWithToken.test.tsx.snap | 1 + .../__snapshots__/Settings.test.tsx.snap | 4 + 9 files changed, 148 insertions(+), 2 deletions(-) diff --git a/src/components/Repository.test.tsx b/src/components/Repository.test.tsx index 9eaa7aec5..9e4726708 100644 --- a/src/components/Repository.test.tsx +++ b/src/components/Repository.test.tsx @@ -81,4 +81,15 @@ describe('components/Repository.tsx', () => { 'github.com', ); }); + + it('should use default repository icon when avatar is not available', () => { + props.repoNotifications[0].repository.owner.avatar_url = ''; + + const tree = TestRenderer.create( + + + , + ); + expect(tree).toMatchSnapshot(); + }); }); diff --git a/src/components/Repository.tsx b/src/components/Repository.tsx index 2ece71241..6c7a4ce56 100644 --- a/src/components/Repository.tsx +++ b/src/components/Repository.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useContext } from 'react'; -import { ReadIcon, CheckIcon } from '@primer/octicons-react'; +import { ReadIcon, CheckIcon, MarkGithubIcon } from '@primer/octicons-react'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; import { AppContext } from '../context/App'; @@ -42,7 +42,11 @@ export const RepositoryNotifications: React.FC = ({ <>
- + {avatarUrl ? ( + + ) : ( + + )} {repoName}
diff --git a/src/components/__snapshots__/AccountNotifications.test.tsx.snap b/src/components/__snapshots__/AccountNotifications.test.tsx.snap index 7bb967d17..1e14664e4 100644 --- a/src/components/__snapshots__/AccountNotifications.test.tsx.snap +++ b/src/components/__snapshots__/AccountNotifications.test.tsx.snap @@ -12,6 +12,7 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi fill="currentColor" focusable="false" height={20} + role="img" style={ { "display": "inline-block", @@ -45,6 +46,7 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi fill="currentColor" focusable="false" height={20} + role="img" style={ { "display": "inline-block", diff --git a/src/components/__snapshots__/NotificationRow.test.tsx.snap b/src/components/__snapshots__/NotificationRow.test.tsx.snap index b671daa41..dfa20ba0c 100644 --- a/src/components/__snapshots__/NotificationRow.test.tsx.snap +++ b/src/components/__snapshots__/NotificationRow.test.tsx.snap @@ -9,6 +9,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`] title="Open Issue" > + + + +
+ , +
+
+ NotificationRow +
+
+ NotificationRow +
+
, +] +`; + +exports[`components/Repository.tsx should use default repository icon when avatar is not available 1`] = ` +[ +
+
+ + + manosim/gitify + +
+
+ +
+