@@ -64,117 +64,88 @@ describe('user profile management', function () {
64
64
65
65
describe ( 'loading /users/me' , function ( ) {
66
66
67
- var usernameSpanSelector = 'span#username' ,
68
- usernameSpan ,
69
- fullnameSpanSelector = 'span#full_name' ,
70
- fullnameSpan ,
71
- emailSpanSelector = 'span#email' ,
72
- emailSpan ,
73
-
74
- fullnameFieldSelector = 'input[type="text"][name="realname"]' ,
67
+ var
68
+ fullnameFieldSelector = 'input[type="text"][name="full_name"]' ,
75
69
fullnameField ,
70
+ usernameFieldSelector = 'input[type="text"][name="username"]' ,
71
+ usernameField ,
76
72
emailFieldSelector = 'input[type="email"][name="email"]' ,
77
73
emailField ,
74
+ passwordFieldSelector = 'input[type="password"][name="password"]' ,
75
+ passwordField ,
78
76
79
- editProfileButtonSelector = 'button#edit_profile' ,
80
- editProfileButton ,
81
-
82
- saveProfileButtonSelector = 'button[type="submit"]#save_profile' ,
77
+ saveProfileButtonSelector = 'button[type="submit"]' ,
83
78
saveProfileButton ,
84
79
85
- cancelButtonSelector = 'button[type="button"]#cancel' ,
86
- cancelButton ;
80
+ changePasswordLinkSelector = 'a.change-password' ,
81
+ changePasswordLink ,
82
+
83
+ confirmationMessageSelector = '.alert.confirmation' ,
84
+ confirmationMessage ;
87
85
88
86
beforeEach ( function ( ) {
89
87
browser . get ( '/users/me' ) ;
90
- browser . wait ( element ( by . css ( '.form-wrapper' ) ) . isDisplayed ) ;
91
-
92
- usernameSpan = element ( by . css ( usernameSpanSelector ) ) ;
93
- fullnameSpan = element ( by . css ( fullnameSpanSelector ) ) ;
94
- emailSpan = element ( by . css ( emailSpanSelector ) ) ;
95
- editProfileButton = element ( by . css ( editProfileButtonSelector ) ) ;
96
- } ) ;
88
+ browser . wait ( element ( by . css ( '.user-profile' ) ) . isDisplayed ) ;
97
89
98
- it ( 'should show the username, full name and email of the current user' , function ( ) {
99
- expect ( usernameSpan . isDisplayed ( ) ) . toBe ( true ) ;
100
- expect ( usernameSpan . getText ( ) ) . toBe ( 'admin' ) ;
90
+ usernameField = element ( by . css ( usernameFieldSelector ) ) ;
91
+ fullnameField = element ( by . css ( fullnameFieldSelector ) ) ;
92
+ emailField = element ( by . css ( emailFieldSelector ) ) ;
101
93
102
- expect ( fullnameSpan . isDisplayed ( ) ) . toBe ( true ) ;
103
- expect ( fullnameSpan . getText ( ) ) . toBe ( 'Admin Joe' ) ;
94
+ saveProfileButton = element ( by . css ( saveProfileButtonSelector ) ) ;
104
95
105
- expect ( emailSpan . isDisplayed ( ) ) . toBe ( true ) ;
106
- expect ( emailSpan . getText ( ) ) . toBe ( '[email protected] ' ) ;
96
+ changePasswordLink = element ( by . css ( changePasswordLinkSelector ) ) ;
107
97
} ) ;
108
98
109
- it ( 'should show "Edit Profile" button ' , function ( ) {
110
- expect ( editProfileButton . isDisplayed ( ) ) . toBe ( true ) ;
111
- } ) ;
99
+ it ( 'should show the editable fields for full name, username and email with the correct values prefilled ' , function ( ) {
100
+ expect ( fullnameField . isDisplayed ( ) ) . toBe ( true ) ;
101
+ expect ( fullnameField . getAttribute ( 'value' ) ) . toBe ( 'Admin Joe' ) ;
112
102
113
- describe ( 'clicking the "Edit Profile" button' , function ( ) {
114
- beforeEach ( function ( ) {
115
- editProfileButton . click ( ) ;
103
+ expect ( usernameField . isDisplayed ( ) ) . toBe ( true ) ;
104
+ expect ( usernameField . getAttribute ( 'value' ) ) . toBe ( 'admin' ) ;
116
105
117
- fullnameField = element ( by . css ( fullnameFieldSelector ) ) ;
118
- emailField = element ( by . css ( emailFieldSelector ) ) ;
106
+ expect ( emailField . isDisplayed ( ) ) . toBe ( true ) ;
107
+ expect ( emailField . getAttribute ( 'value' ) ) . toBe ( '[email protected] ' ) ;
108
+ } ) ;
119
109
120
- saveProfileButton = element ( by . css ( saveProfileButtonSelector ) ) ;
121
- cancelButton = element ( by . css ( cancelButtonSelector ) ) ;
122
- } ) ;
110
+ it ( 'should show "Save Profile" buttons' , function ( ) {
111
+ expect ( saveProfileButton . isDisplayed ( ) ) . toBe ( true ) ;
112
+ } ) ;
123
113
124
- it ( 'should show the editable fields for full name and email with the correct values prefilled ' , function ( ) {
125
- expect ( fullnameField . isDisplayed ( ) ) . toBe ( true ) ;
126
- expect ( fullnameField . getAttribute ( 'value' ) ) . toBe ( 'Admin Joe' ) ;
114
+ it ( 'should show "Change Passowrd" links ' , function ( ) {
115
+ expect ( changePasswordLink . isDisplayed ( ) ) . toBe ( true ) ;
116
+ } ) ;
127
117
128
- expect ( emailField . isDisplayed ( ) ) . toBe ( true ) ;
129
- expect ( emailField . getAttribute ( 'value' ) ) . toBe ( '[email protected] ' ) ;
130
- } ) ;
118
+ describe ( 'changing fullname and email values' , function ( ) {
119
+ beforeEach ( function ( ) {
120
+ fullnameField . clear ( ) ;
121
+ fullnameField . sendKeys ( 'Foo Bar' ) ;
131
122
132
- it ( 'should show "Save Profile" and "Cancel" buttons' , function ( ) {
133
- expect ( saveProfileButton . isDisplayed ( ) ) . toBe ( true ) ;
134
- expect ( cancelButton . isDisplayed ( ) ) . toBe ( true ) ;
123
+ emailField . clear ( ) ;
124
+ emailField . sendKeys ( '[email protected] ' ) ;
135
125
} ) ;
136
126
137
- describe ( 'changing fullname and email values ' , function ( ) {
127
+ describe ( 'clicking the "Save profile" button ' , function ( ) {
138
128
beforeEach ( function ( ) {
139
- fullnameField . clear ( ) ;
140
- fullnameField . sendKeys ( 'Foo Bar' ) ;
141
-
142
- emailField . clear ( ) ;
143
- emailField . sendKeys ( '[email protected] ' ) ;
129
+ saveProfileButton . click ( ) ;
130
+ confirmationMessage = element ( by . css ( confirmationMessageSelector ) ) ;
144
131
} ) ;
145
132
146
- describe ( 'clicking the "Cancel" button' , function ( ) {
147
- beforeEach ( function ( ) {
148
- cancelButton . click ( ) ;
149
- } ) ;
150
- it ( 'should switch again to the non-edit view with the original values' , function ( ) {
151
- expect ( usernameSpan . isDisplayed ( ) ) . toBe ( true ) ;
152
- expect ( usernameSpan . getText ( ) ) . toBe ( 'admin' ) ;
153
-
154
- expect ( fullnameSpan . isDisplayed ( ) ) . toBe ( true ) ;
155
- expect ( fullnameSpan . getText ( ) ) . toBe ( 'Admin Joe' ) ;
156
-
157
- expect ( emailSpan . isDisplayed ( ) ) . toBe ( true ) ;
158
- expect ( emailSpan . getText ( ) ) . toBe ( '[email protected] ' ) ;
159
- } ) ;
133
+ it ( 'should show confirmation message' , function ( ) {
134
+ expect ( confirmationMessage . isDisplayed ( ) ) . toBe ( true ) ;
160
135
} ) ;
136
+ } ) ;
137
+ } ) ;
161
138
162
- describe ( 'clicking the "Save profile" button' , function ( ) {
163
- beforeEach ( function ( ) {
164
- saveProfileButton . click ( ) ;
165
- } ) ;
166
-
167
- it ( 'should switch again to the non-edit view with the just changed values' , function ( ) {
168
- expect ( usernameSpan . isDisplayed ( ) ) . toBe ( true ) ;
169
- expect ( usernameSpan . getText ( ) ) . toBe ( 'admin' ) ;
139
+ describe ( 'clicking the "Change password" button' , function ( ) {
140
+ beforeEach ( function ( ) {
141
+ changePasswordLink . click ( ) ;
142
+ passwordField = element ( by . css ( passwordFieldSelector ) ) ;
143
+ } ) ;
170
144
171
- expect ( fullnameSpan . isDisplayed ( ) ) . toBe ( true ) ;
172
- expect ( fullnameSpan . getText ( ) ) . toBe ( 'Foo Bar' ) ;
173
145
174
- expect ( emailSpan . isDisplayed ( ) ) . toBe ( true ) ;
175
- expect ( emailSpan . getText ( ) ) . toBe ( '[email protected] ' ) ;
176
- } ) ;
177
- } ) ;
146
+ it ( 'should show confirmation message' , function ( ) {
147
+ expect ( passwordField . isDisplayed ( ) ) . toBe ( true ) ;
148
+ expect ( passwordField . getAttribute ( 'value' ) ) . toBe ( '' ) ;
178
149
} ) ;
179
150
} ) ;
180
151
} ) ; // end 'link to user profile in user menu'
0 commit comments