@@ -15,98 +15,104 @@ describe('Login Flow', () => {
15
15
test ( 'Login form is rendered correctly' , async ( ) => {
16
16
render ( < Login ssoerror = "" jwt = "" refreshjwt = "" userId = "" withPassword = "" /> ) ;
17
17
18
- const headingElement = screen . getByRole ( 'heading' , {
19
- name : 'login_page_title' ,
20
- } ) ;
21
- expect ( headingElement ) . toBeInTheDocument ( ) ;
22
-
23
- const textboxElement = screen . getByRole ( 'textbox' ) ;
24
- expect ( textboxElement ) . toBeInTheDocument ( ) ;
25
-
26
- const buttonElement = screen . getByRole ( 'button' , {
27
- name : 'button_initiate_login' ,
28
- } ) ;
29
- expect ( buttonElement ) . toBeInTheDocument ( ) ;
30
-
31
- const noAccountPromptElement = screen . getByText ( 'prompt_no_account' ) ;
32
- expect ( noAccountPromptElement ) . toBeInTheDocument ( ) ;
18
+ // Check for the main description
19
+ expect (
20
+ screen . getByText (
21
+ 'Sign in to monitor, trace, and troubleshoot your applications effortlessly.' ,
22
+ ) ,
23
+ ) . toBeInTheDocument ( ) ;
24
+
25
+ // Email input
26
+ const emailInput = screen . getByTestId ( 'email' ) ;
27
+ expect ( emailInput ) . toBeInTheDocument ( ) ;
28
+ expect ( emailInput ) . toHaveAttribute ( 'type' , 'email' ) ;
29
+
30
+ // Next button
31
+ const nextButton = screen . getByRole ( 'button' , { name : / n e x t / i } ) ;
32
+ expect ( nextButton ) . toBeInTheDocument ( ) ;
33
+
34
+ // No account prompt (default: canSelfRegister is false)
35
+ expect (
36
+ screen . getByText (
37
+ "Don't have an account? Contact your admin to send you an invite link." ,
38
+ ) ,
39
+ ) . toBeInTheDocument ( ) ;
33
40
} ) ;
34
41
35
- test ( ` Display "invalid_email" if email is not provided` , async ( ) => {
42
+ test ( ' Display error if email is not provided' , async ( ) => {
36
43
render ( < Login ssoerror = "" jwt = "" refreshjwt = "" userId = "" withPassword = "" /> ) ;
37
44
38
- const buttonElement = screen . getByText ( 'button_initiate_login' ) ;
39
- fireEvent . click ( buttonElement ) ;
45
+ const nextButton = screen . getByRole ( 'button' , { name : / n e x t / i } ) ;
46
+ fireEvent . click ( nextButton ) ;
40
47
41
48
await waitFor ( ( ) =>
42
49
expect ( errorNotification ) . toHaveBeenCalledWith ( {
43
- message : 'invalid_email ' ,
50
+ message : 'Please enter a valid email address ' ,
44
51
} ) ,
45
52
) ;
46
53
} ) ;
47
54
48
- test ( 'Display invalid_config if invalid email is provided and next clicked' , async ( ) => {
55
+ test ( 'Display error if invalid email is provided and next clicked' , async ( ) => {
49
56
render ( < Login ssoerror = "" jwt = "" refreshjwt = "" userId = "" withPassword = "" /> ) ;
50
57
51
- const textboxElement = screen . getByRole ( 'textbox ') ;
52
- fireEvent . change ( textboxElement , {
58
+ const emailInput = screen . getByTestId ( 'email ') ;
59
+ fireEvent . change ( emailInput , {
53
60
target : { value : 'failEmail@signoz.io' } ,
54
61
} ) ;
55
62
56
- const buttonElement = screen . getByRole ( 'button' , {
57
- name : 'button_initiate_login' ,
58
- } ) ;
59
- fireEvent . click ( buttonElement ) ;
63
+ const nextButton = screen . getByRole ( 'button' , { name : / n e x t / i } ) ;
64
+ fireEvent . click ( nextButton ) ;
60
65
61
66
await waitFor ( ( ) =>
62
67
expect ( errorNotification ) . toHaveBeenCalledWith ( {
63
- message : 'invalid_config' ,
68
+ message :
69
+ 'Invalid configuration detected, please contact your administrator' ,
64
70
} ) ,
65
71
) ;
66
72
} ) ;
67
73
68
- test ( 'providing shaheer@signoz.io as email and pressing next, should make the login_with_sso button visible' , async ( ) => {
74
+ test ( 'providing shaheer@signoz.io as email and pressing next, should make the Login with SSO button visible' , async ( ) => {
69
75
render ( < Login ssoerror = "" jwt = "" refreshjwt = "" userId = "" withPassword = "" /> ) ;
70
76
act ( ( ) => {
71
77
fireEvent . change ( screen . getByTestId ( 'email' ) , {
72
78
target : { value : 'shaheer@signoz.io' } ,
73
79
} ) ;
74
-
75
80
fireEvent . click ( screen . getByTestId ( 'initiate_login' ) ) ;
76
81
} ) ;
77
82
78
83
await waitFor ( ( ) => {
79
- expect ( screen . getByText ( 'login_with_sso' ) ) . toBeInTheDocument ( ) ;
84
+ expect ( screen . getByText ( / l o g i n w i t h s s o / i ) ) . toBeInTheDocument ( ) ;
80
85
} ) ;
81
86
} ) ;
82
87
83
88
test ( 'Display email, password, forgot password if password=Y' , ( ) => {
84
89
render ( < Login ssoerror = "" jwt = "" refreshjwt = "" userId = "" withPassword = "Y" /> ) ;
85
90
86
- const emailTextBox = screen . getByTestId ( 'email' ) ;
87
- expect ( emailTextBox ) . toBeInTheDocument ( ) ;
91
+ const emailInput = screen . getByTestId ( 'email' ) ;
92
+ expect ( emailInput ) . toBeInTheDocument ( ) ;
88
93
89
- const passwordTextBox = screen . getByTestId ( 'password' ) ;
90
- expect ( passwordTextBox ) . toBeInTheDocument ( ) ;
94
+ const passwordInput = screen . getByTestId ( 'password' ) ;
95
+ expect ( passwordInput ) . toBeInTheDocument ( ) ;
91
96
92
- const forgotPasswordLink = screen . getByText ( 'forgot_password ' ) ;
97
+ const forgotPasswordLink = screen . getByText ( 'Forgot password? ' ) ;
93
98
expect ( forgotPasswordLink ) . toBeInTheDocument ( ) ;
94
99
} ) ;
95
100
96
- test ( 'Display tooltip with "prompt_forgot_password" if forgot password is clicked while password=Y' , async ( ) => {
101
+ test ( 'Display tooltip with correct message if forgot password is hovered while password=Y' , async ( ) => {
97
102
render ( < Login ssoerror = "" jwt = "" refreshjwt = "" userId = "" withPassword = "Y" /> ) ;
98
- const forgotPasswordLink = screen . getByText ( 'forgot_password ' ) ;
103
+ const forgotPasswordLink = screen . getByText ( 'Forgot password? ' ) ;
99
104
100
105
act ( ( ) => {
101
106
fireEvent . mouseOver ( forgotPasswordLink ) ;
102
107
} ) ;
103
108
104
109
await waitFor ( ( ) => {
105
- const forgotPasswordTooltip = screen . getByRole ( 'tooltip' , {
106
- name : 'prompt_forgot_password' ,
107
- } ) ;
108
- expect ( forgotPasswordLink ) . toBeInTheDocument ( ) ;
109
- expect ( forgotPasswordTooltip ) . toBeInTheDocument ( ) ;
110
+ // Tooltip text is static in the new UI
111
+ expect (
112
+ screen . getByText (
113
+ 'Ask your admin to reset your password and send you a new invite link' ,
114
+ ) ,
115
+ ) . toBeInTheDocument ( ) ;
110
116
} ) ;
111
117
} ) ;
112
118
} ) ;
0 commit comments