File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -287,4 +287,28 @@ describe('DashboardClient', () => {
287287 const generateLink = screen . getByRole ( 'link' , { name : / g e n e r a t e y o u r o w n / i } ) ;
288288 expect ( generateLink . getAttribute ( 'href' ) ) . toBe ( '/' ) ;
289289 } ) ;
290+ // =========================================================================
291+ // ISSUE OBJECTIVE: Verify error is shown when comparing with same username
292+ // =========================================================================
293+ it ( 'shows an error when comparing with the same username (case-insensitive)' , async ( ) => {
294+ render ( < DashboardClient initialData = { mockInitialData } username = "Shivangi1515" /> ) ;
295+
296+ // 1. Open modal
297+ const compareBtn = screen . getByText ( 'Compare Profile' ) ;
298+ fireEvent . click ( compareBtn ) ;
299+
300+ // 2. Type the same username as props.username, but all lowercase to test case-insensitivity
301+ const input = screen . getByPlaceholderText ( 'Enter GitHub Username' ) ;
302+ fireEvent . change ( input , { target : { value : 'shivangi1515' } } ) ;
303+
304+ // 3. Click 'Compare'
305+ const submitBtn = screen . getByText ( 'Compare' ) ;
306+ fireEvent . click ( submitBtn ) ;
307+
308+ // 4. Assert error message 'Cannot compare a profile with itself.' appears
309+ await waitFor ( ( ) => {
310+ // Using Regex /.../i to match the text even if there is an emoji next to it!
311+ expect ( screen . getByText ( / C a n n o t c o m p a r e a p r o f i l e w i t h i t s e l f / i) ) . toBeDefined ( ) ;
312+ } ) ;
313+ } ) ;
290314} ) ;
You can’t perform that action at this time.
0 commit comments