@@ -71,9 +71,11 @@ describe('UserProfileProfilePanelView', () => {
7171 expect ( screen . queryByRole ( 'button' , { name : 'Manage profile picture' } ) ) . toBeNull ( ) ;
7272
7373 const input = container . querySelector < HTMLInputElement > ( 'input[type="file"]' ) ;
74- expect ( input ) . not . toBeNull ( ) ;
74+ if ( ! input ) {
75+ throw new Error ( 'File picker not found' ) ;
76+ }
7577 const file = new File ( [ 'avatar' ] , 'avatar.png' , { type : 'image/png' } ) ;
76- await user . upload ( input as HTMLInputElement , file ) ;
78+ await user . upload ( input , file ) ;
7779
7880 expect ( onProfilePictureChange ) . toHaveBeenCalledWith ( file ) ;
7981 } ) ;
@@ -85,7 +87,11 @@ describe('UserProfileProfilePanelView', () => {
8587 const { container } = renderView ( { onProfilePictureChange, onProfilePictureReject } ) ;
8688
8789 const oversized = new File ( [ new Uint8Array ( 10 * 1000 * 1000 + 1 ) ] , 'big.png' , { type : 'image/png' } ) ;
88- await user . upload ( container . querySelector < HTMLInputElement > ( 'input[type="file"]' ) as HTMLInputElement , oversized ) ;
90+ const input = container . querySelector < HTMLInputElement > ( 'input[type="file"]' ) ;
91+ if ( ! input ) {
92+ throw new Error ( 'File picker not found' ) ;
93+ }
94+ await user . upload ( input , oversized ) ;
8995
9096 expect ( onProfilePictureChange ) . not . toHaveBeenCalled ( ) ;
9197 expect ( onProfilePictureReject ) . toHaveBeenCalledWith ( [ { file : oversized , reason : 'size' } ] ) ;
@@ -96,7 +102,10 @@ describe('UserProfileProfilePanelView', () => {
96102 it ( 'clears the rejection once an acceptable file is picked' , async ( ) => {
97103 const user = userEvent . setup ( ) ;
98104 const { container } = renderView ( { onProfilePictureChange : vi . fn ( ) } ) ;
99- const input = container . querySelector < HTMLInputElement > ( 'input[type="file"]' ) as HTMLInputElement ;
105+ const input = container . querySelector < HTMLInputElement > ( 'input[type="file"]' ) ;
106+ if ( ! input ) {
107+ throw new Error ( 'File picker not found' ) ;
108+ }
100109
101110 await user . upload ( input , new File ( [ new Uint8Array ( 10 * 1000 * 1000 + 1 ) ] , 'big.png' , { type : 'image/png' } ) ) ;
102111 expect ( screen . getByRole ( 'alert' ) ) . toBeInTheDocument ( ) ;
@@ -105,38 +114,6 @@ describe('UserProfileProfilePanelView', () => {
105114 expect ( screen . queryByRole ( 'alert' ) ) . toBeNull ( ) ;
106115 } ) ;
107116
108- it ( 'offers Upload while the avatar is only a generated default' , ( ) => {
109- renderView ( {
110- hasImage : false ,
111- imageUrl : 'https://img.clerk.com/generated-default.png' ,
112- onProfilePictureChange : vi . fn ( ) ,
113- onRemoveProfilePicture : vi . fn ( ) ,
114- } ) ;
115-
116- expect ( screen . getByRole ( 'button' , { name : 'Upload' } ) ) . toBeInTheDocument ( ) ;
117- expect ( screen . queryByRole ( 'button' , { name : 'Manage profile picture' } ) ) . toBeNull ( ) ;
118- } ) ;
119-
120- it ( 'offers change and remove in a menu once a profile picture is set' , async ( ) => {
121- const onProfilePictureChange = vi . fn ( ) ;
122- const onRemoveProfilePicture = vi . fn ( ) ;
123- const user = userEvent . setup ( ) ;
124- renderView ( {
125- hasImage : true ,
126- imageUrl : 'https://example.com/avatar.png' ,
127- onProfilePictureChange,
128- onRemoveProfilePicture,
129- } ) ;
130-
131- expect ( screen . queryByRole ( 'button' , { name : 'Upload' } ) ) . toBeNull ( ) ;
132- await user . click ( screen . getByRole ( 'button' , { name : 'Manage profile picture' } ) ) ;
133-
134- expect ( screen . getByRole ( 'menuitem' , { name : 'Change avatar' } ) ) . toBeInTheDocument ( ) ;
135- await user . click ( screen . getByRole ( 'menuitem' , { name : 'Remove avatar' } ) ) ;
136-
137- expect ( onRemoveProfilePicture ) . toHaveBeenCalledOnce ( ) ;
138- } ) ;
139-
140117 it ( 'breaks out both contact types when multiple accounts are allowed' , ( ) => {
141118 renderView ( {
142119 emails :
[ { id :
'email_1' , value :
'[email protected] ' , isDefault :
true } ] ,
0 commit comments