@@ -122,6 +122,53 @@ describe('Header', () => {
122122 expect ( avatarIcon ) . toBeVisible ( ) ;
123123 } ) ;
124124
125+ it ( 'user menu should use avatar icon when hydrated profile image has no image' , async ( ) => {
126+ currentUser = {
127+ ...authenticatedUser ,
128+ avatar : null ,
129+ profileImage : {
130+ hasImage : false ,
131+ imageUrlMedium : '/profile-images/abc123-medium.png' ,
132+ } ,
133+ } ;
134+ const { getByTestId, queryByTestId } = render ( < RootWrapper { ...props } /> ) ;
135+ const avatarIcon = getByTestId ( 'avatar-icon' ) ;
136+
137+ expect ( avatarIcon ) . toBeVisible ( ) ;
138+ expect ( queryByTestId ( 'avatar-image' ) ) . not . toBeInTheDocument ( ) ;
139+ } ) ;
140+
141+ it ( 'user menu should use hydrated profile image when avatar is not present' , async ( ) => {
142+ currentUser = {
143+ ...authenticatedUser ,
144+ avatar : null ,
145+ profileImage : {
146+ hasImage : true ,
147+ imageUrlMedium : '/profile-images/abc123-medium.png' ,
148+ } ,
149+ } ;
150+ const { getByTestId } = render ( < RootWrapper { ...props } /> ) ;
151+ const avatarImage = getByTestId ( 'avatar-image' ) ;
152+
153+ expect ( avatarImage ) . toBeVisible ( ) ;
154+ expect ( avatarImage ) . toHaveAttribute ( 'src' , '/profile-images/abc123-medium.png' ) ;
155+ } ) ;
156+
157+ it ( 'user menu should prefer avatar over hydrated profile image' , async ( ) => {
158+ currentUser = {
159+ ...authenticatedUser ,
160+ profileImage : {
161+ hasImage : true ,
162+ imageUrlMedium : '/profile-images/abc123-medium.png' ,
163+ } ,
164+ } ;
165+ const { getByTestId } = render ( < RootWrapper { ...props } /> ) ;
166+ const avatarImage = getByTestId ( 'avatar-image' ) ;
167+
168+ expect ( avatarImage ) . toBeVisible ( ) ;
169+ expect ( avatarImage ) . toHaveAttribute ( 'src' , authenticatedUser . avatar ) ;
170+ } ) ;
171+
125172 it ( 'should hide nav items if prop isHiddenMainMenu true' , async ( ) => {
126173 const initialProps = { ...props , isHiddenMainMenu : true } ;
127174 const { queryByTestId } = render ( < RootWrapper { ...initialProps } /> ) ;
0 commit comments