20
20
*/
21
21
22
22
this . Given ( / ^ I a m s i g n e d o u t $ / , function ( ) {
23
- var client = this . client ;
24
- browser . url ( process . env . ROOT_URL ) ;
25
- browser . waitForExist ( ".container" ) ;
26
- browser . waitForVisible ( ".container" ) ;
27
- browser . waitForVisible ( "#login-sign-in-link" ) ;
23
+ client . url ( process . env . ROOT_URL ) ;
24
+ client . waitForExist ( ".container" ) ;
25
+ client . waitForVisible ( ".container" ) ;
26
+ client . waitForVisible ( "#login-sign-in-link" ) ;
28
27
29
- actual = browser . getText ( "#login-sign-in-link" ) ;
28
+ actual = client . getText ( "#login-sign-in-link" ) ;
30
29
expected = "Sign in" ;
31
30
32
31
expect ( actual ) . toContain ( expected ) ;
33
32
} ) ;
34
33
35
34
this . Given ( / ^ I a m o n t h e h o m e p a g e $ / , function ( ) {
36
- return this . client .
37
35
// We navigate into home page
38
- url ( process . env . ROOT_URL ) ;
36
+ client . url ( process . env . ROOT_URL ) ;
39
37
} ) ;
40
38
41
39
this . When ( / ^ I c l i c k o n s i g n i n l i n k $ / , function ( ) {
42
- // Wait
43
- var client = this . client ;
44
40
// We navigate into home page
45
41
client . url ( process . env . ROOT_URL ) ;
46
42
47
43
// Wait for the page to load
48
44
client . waitForExist ( ".container" , 1000 ) ;
49
- client . waitForVisible ( ".container" , 1000 )
50
-
45
+ client . waitForVisible ( ".container" , 1000 ) ;
51
46
// We click the login button
52
47
client . click ( "#login-sign-in-link" ) ;
53
48
} ) ;
54
49
55
- this . When ( / ^ I e n t e r m y a u t h e n t i c a t i o n i n f o r m a t i o n $ / , function ( callback ) {
56
- return loginWithCredentials ( browser , myEmail , wrongPass ) ;
50
+ this . When ( / ^ I e n t e r m y a u t h e n t i c a t i o n i n f o r m a t i o n $ / , function ( ) {
51
+ return loginWithCredentials ( browser , myEmail , myPass )
57
52
} ) ;
58
53
59
- this . Then ( / ^ I s h o u l d b e l o g g e d i n $ / , function ( callback ) {
60
- return this . client .
61
- //We wait if our email address will appear instead of Sign in
62
- waitForExist ( "#login-name-link" , 500 ) .
63
- getText ( "#login-name-link" , function ( error , email ) {
64
- return chai . expect ( email ) . to . contain ( myEmail ) ;
65
- } ) ;
54
+ this . Then ( / ^ I s h o u l d b e l o g g e d i n $ / , function ( ) {
55
+
56
+ //We wait if our email address will appear instead of Sign in
57
+ client . waitForExist ( "#login-name-link" ) ;
58
+
59
+ actual = client . getText ( "#login-name-link" ) ;
60
+ expected = myEmail ;
61
+ expect ( actual ) . toContain ( expected ) ;
62
+
66
63
} ) ;
67
64
68
65
/**
69
66
* Scenario: A user cannot login with invalid information
70
67
*/
71
68
72
69
this . When ( / ^ I e n t e r m y f a l s e a u t h e n t i c a t i o n i n f o r m a t i o n $ / , function ( ) {
73
- return loginWithCredentials ( browser , myEmail , wrongPass ) ;
70
+ return loginWithCredentials ( browser , wrongEmail , wrongPass ) ;
74
71
} ) ;
75
72
76
73
this . Then ( / ^ I s h o u l d s e e a u s e r n o t f o u n d e r r o r $ / , function ( ) {
77
74
// We wait the User not found message to appear
78
- return this . client .
79
- waitForExist ( ".error-message" ) .
80
- getText ( ".error-message" , function ( error , message ) {
81
- return chai . expect ( message ) . to . contain ( "User not found" ) ;
82
- } ) ;
75
+ client . waitForExist ( ".error-message" ) ;
76
+
77
+ actual = client . getText ( ".error-message" ) ;
78
+ expected = "User not found" ;
79
+ expect ( actual ) . toContain ( expected ) ;
80
+
83
81
} ) ;
84
82
85
83
/**
86
84
* Scenario: A user cannot login with invalid email address
87
85
*/
88
86
89
- this . When ( / ^ I e n t e r m y i n v a l i d e m a i l a d d r e s s $ / , function ( callback ) {
90
- return loginWithCredentials ( browser , myEmail , wrongPass ) ;
87
+ this . When ( / ^ I e n t e r m y i n v a l i d e m a i l a d d r e s s $ / , function ( ) {
88
+ return loginWithCredentials ( client , invalidWord , wrongPass ) ;
91
89
} ) ;
92
90
93
- this . Then ( / ^ I s h o u l d s e e a n i n v a l i d e m a i l e r r o r m e s s a g e $ / , function ( callback ) {
91
+ this . Then ( / ^ I s h o u l d s e e a n i n v a l i d e m a i l e r r o r m e s s a g e $ / , function ( ) {
94
92
// We wait the Invalid email message to appear
95
- return this . client .
96
- waitForExist ( ".error-message" ) .
97
- getText ( ".error-message" , function ( error , message ) {
98
- return chai . expect ( message ) . to . contain ( "Invalid email" ) ;
99
- } ) ;
93
+ client . waitForExist ( ".error-message" ) ;
94
+
95
+ actual = client . getText ( ".error-message" ) ;
96
+ expected = "Invalid email" ;
97
+ expect ( actual ) . toContain ( expected ) ;
98
+
100
99
} ) ;
101
100
102
101
/**
105
104
106
105
this . When ( / ^ I e n t e r m y i n v a l i d p a s s w o r d $ / , function ( ) {
107
106
// We enter into sign in fields wrong information
108
- return loginWithCredentials ( browser , myEmail , wrongPass ) ;
107
+ return loginWithCredentials ( client , myEmail , wrongPass ) ;
109
108
} ) ;
110
109
111
110
this . Then ( / ^ I s h o u l d s e e a n i n c o r r e c t p a s s w o r d e r r o r m e s s a g e $ / , function ( ) {
112
111
// We wait the Incorrect password message to appear
113
- browser . waitForExist ( ".error-message" ) ;
114
- actual = browser . getText ( ".error-message" ) ;
112
+ client . waitForExist ( ".error-message" ) ;
113
+
114
+ actual = client . getText ( ".error-message" ) ;
115
115
expected = "Incorrect password" ;
116
116
expect ( actual ) . toBe ( expected ) ;
117
117
} ) ;
124
124
* @param pass
125
125
* @return {*|{phasedRegistrationNames} }
126
126
*/
127
- function loginWithCredentials ( browser , email , pass ) {
128
- browser . waitForExist ( "#login-email" ) ;
127
+ function loginWithCredentials ( client , email , pass ) {
128
+ client . waitForExist ( "#login-email" ) ;
129
129
// We set the values into email and password
130
- browser . setValue ( "#login-email" , email ) ;
131
- browser . setValue ( "#login-password" , pass ) ;
130
+ client . setValue ( "#login-email" , email ) ;
131
+ client . setValue ( "#login-password" , pass ) ;
132
132
133
133
// We click the Sign In button
134
- browser . click ( '#login-buttons-password' )
134
+ client . click ( '#login-buttons-password' )
135
135
}
136
136
} ) ( ) ;
0 commit comments