Skip to content

Commit d601507

Browse files
committed
Fix e2e test for updated user profile view
1 parent c888829 commit d601507

File tree

2 files changed

+55
-84
lines changed

2 files changed

+55
-84
lines changed

server/www/templates/users/me.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<main class="page-content" role="main">
1+
<main class="page-content user-profile" role="main">
22

33
<div class="main-col">
44
<h1 class="inline">{{title}}</h1>
@@ -53,7 +53,7 @@ <h1 class="inline">{{title}}</h1>
5353
class="alert error"
5454
translate="{{'user.valid.email.' + error}}"></p>
5555

56-
<p ng-hide="state.changingPassword"><a href class="cta" ng-click="state.changingPassword = !state.changePachangingPasswordssword" translate>user_profile.update_password</a></p>
56+
<p ng-hide="state.changingPassword"><a href class="cta change-password" ng-click="state.changingPassword = !state.changePachangingPasswordssword" translate>user_profile.update_password</a></p>
5757

5858
<div ng-if="state.changingPassword">
5959
<label class="input-label"

test/e2e/user-profile-e2e-spec.js

Lines changed: 53 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -64,117 +64,88 @@ describe('user profile management', function () {
6464

6565
describe('loading /users/me', function () {
6666

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"]',
7569
fullnameField,
70+
usernameFieldSelector = 'input[type="text"][name="username"]',
71+
usernameField,
7672
emailFieldSelector = 'input[type="email"][name="email"]',
7773
emailField,
74+
passwordFieldSelector = 'input[type="password"][name="password"]',
75+
passwordField,
7876

79-
editProfileButtonSelector = 'button#edit_profile',
80-
editProfileButton,
81-
82-
saveProfileButtonSelector = 'button[type="submit"]#save_profile',
77+
saveProfileButtonSelector = 'button[type="submit"]',
8378
saveProfileButton,
8479

85-
cancelButtonSelector = 'button[type="button"]#cancel',
86-
cancelButton;
80+
changePasswordLinkSelector = 'a.change-password',
81+
changePasswordLink,
82+
83+
confirmationMessageSelector = '.alert.confirmation',
84+
confirmationMessage;
8785

8886
beforeEach(function () {
8987
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);
9789

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));
10193

102-
expect(fullnameSpan.isDisplayed()).toBe(true);
103-
expect(fullnameSpan.getText()).toBe('Admin Joe');
94+
saveProfileButton = element(by.css(saveProfileButtonSelector));
10495

105-
expect(emailSpan.isDisplayed()).toBe(true);
106-
expect(emailSpan.getText()).toBe('[email protected]');
96+
changePasswordLink = element(by.css(changePasswordLinkSelector));
10797
});
10898

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');
112102

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');
116105

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+
});
119109

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+
});
123113

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+
});
127117

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');
131122

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]');
135125
});
136126

137-
describe('changing fullname and email values', function () {
127+
describe('clicking the "Save profile" button', function () {
138128
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));
144131
});
145132

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);
160135
});
136+
});
137+
});
161138

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+
});
170144

171-
expect(fullnameSpan.isDisplayed()).toBe(true);
172-
expect(fullnameSpan.getText()).toBe('Foo Bar');
173145

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('');
178149
});
179150
});
180151
}); // end 'link to user profile in user menu'

0 commit comments

Comments
 (0)